add raise_on_sql feature

Issue #3812 resolved
Mike Bayer repo owner created an issue

not sure if we want this. raise_on_sql means, lazyload if the load means pulling from the identity map or checking for NULL elements in the join condition, otherwise if we are definitely emitting SQL then raise. POC at https://gerrit.sqlalchemy.org/#/c/203/. It also includes some changes to the strategy system that should be a good idea, in that we can pass through the strategy_keys to the strategy object itself and allow them to function as options.

Comments (1)

  1. Mike Bayer reporter

    Enhance "raise" strategy to include "raise_on_sql" option

    The "raise_on_sql" option differentiates from "raise" in that firing a lazy loader is OK as long as it does a simple get from identity map. Whereas "raise" is more useful for the case that objects are to be detached.

    As part of this, refactors the strategy initiation logic a bit so that a LoaderStrategy itself knows what "key" was used to create it, thus allowing variants of a single strategy based on what the "lazy" argument is. To achieve this we have to also get rid of _get_strategy_by_cls().

    Everything here is internal with the one exception of an apparently undocumented, but not underscored, "strategy_class" key on relationship(). Though it's not clear what "strategy_class" accomplishes; at this point the strategy system is extensible using Property.strategy_for().

    Fixes: #3812 Change-Id: I812ad878ea5cf764e15f6f71cb39eee78a645d88

    → <<cset 95d4cd304204>>

  2. Log in to comment