Giter VIP home page Giter VIP logo

falcon-sqla's People

Contributors

caselit avatar vytas7 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

falcon-sqla's Issues

Revise write_engine_if_flushing implementation

As communicated by @CaselIT , automatically choosing a write engine if the session is currently flushing (automatically enabled by default, see SessionOptions.write_engine_if_flushing) is apparently not bullet proof (as explained in sqlalchemy/sqlalchemy#5407 (comment) ).

This was implemented along the lines of a DIY recipe from SQLAlchemy docs. Revise what the options are. If we fail to improve this to cover the majority of common scenarios, it might be worth changing the default to False to not give a false sense of safety.

In any case, falcon-sqla, if configured, is normally choosing read/write engines according to the HTTP method for the Falcon request in question, and write_engine_if_flushing is provided just as an edge case fallback, so the impact of this bug should be somewhat limited.

Allow customization of session closure

The default logic, commit on success, rollback on failure is a sensible one

if req_succeeded:
session.commit()
else:
session.rollback()

maybe it could be useful to add the ability of a resource to customize this logic.
I'm not sure how to best implement it. Probably a function in the resource class that returns what to do (commit, rollback, nothing) is the best solution.

Write a tutorial

Split off from #7.

Write a short tutorial on how this could be used with a Falcon application in order to reduce the amount of boilerplate code.

Improve tests

The test suite, although hitting 100% branch coverage, is a bit chaotic at the time of writing.
I've cleaned up DB fixtures in conftest.py, so they're probably good enough as-is.

Clean up the tests, add more cases logically testing typical usage rather than just hitting all lines.

Improve engine selection

Currently when read_from_rw_engines or write_to_rw_engines are False and no engine is read-only or write-only all the engine are used.

def _filter_by_role(self, engines, role):
filtered = tuple(engine for engine in engines
if self._engines.get(engine) == role)
return filtered or engines

This behavior is quite strange, since the option is not respected.

Raising an error in this case would probably be more appropriate, the problem with the exception is that by adding the engines one by one it's easy to encounter an error while adding them.

I'm not sure how to best support this scenario.
One option is to make the engine selection lazy, so that only on the first use we check for this, the user does not have an immediate feedback with this approach

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.