diff options
author | Adrian Moennich <adrian@planetcoding.net> | 2015-08-11 23:08:28 +0200 |
---|---|---|
committer | Adrian Moennich <adrian@planetcoding.net> | 2015-08-12 18:39:43 +0200 |
commit | 6d334da16553c91cbe82de7134042dbe3c511630 (patch) | |
tree | db66cc1463a64ec7cb2d9f986521d3d567e659da /lib/sqlalchemy/orm/relationships.py | |
parent | 5198b1de31029cc985102cd13569086a7056c2f1 (diff) | |
download | sqlalchemy-pr/193.tar.gz |
Add raise/raiseload relationship loading strategypr/193
- available via `lazy='raise'` or by setting the `raiseload` strategy
via `options()`
- behaves almost like `lazy='noload'`, but instead of returning `None`
it raises `InvalidRequestError`
- based on code from Mike Bayer that was posted to the sqlalchemy
mailing list: https://groups.google.com/forum/#!topic/sqlalchemy/X_wA8K97smE
Diffstat (limited to 'lib/sqlalchemy/orm/relationships.py')
-rw-r--r-- | lib/sqlalchemy/orm/relationships.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/sqlalchemy/orm/relationships.py b/lib/sqlalchemy/orm/relationships.py index da0730f46..251930873 100644 --- a/lib/sqlalchemy/orm/relationships.py +++ b/lib/sqlalchemy/orm/relationships.py @@ -524,6 +524,10 @@ class RelationshipProperty(StrategizedProperty): support "write-only" attributes, or attributes which are populated in some manner specific to the application. + * ``raise`` - no loading should occur at any time, and accessing + the attribute will fail with an + :exc:`~sqlalchemy.exc.InvalidRequestError`. + * ``dynamic`` - the attribute will return a pre-configured :class:`.Query` object for all read operations, onto which further filtering operations can be |