diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-04-18 16:18:31 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-04-18 16:20:20 -0400 |
| commit | 6f6e2c48ba0be827ee434891f54eb2173edf9bfc (patch) | |
| tree | 49e1271767c5ae3980e768c573f9cba4d7634049 /lib/sqlalchemy/ext | |
| parent | 243b222a232da0da0ac42386f3f38364750b1fcc (diff) | |
| download | sqlalchemy-6f6e2c48ba0be827ee434891f54eb2173edf9bfc.tar.gz | |
Propagate hybrid properties / info
Keystone and others depend on the .property attribute being
"mirrored" when a @hybrid_property is linked directly to a
mapped attribute. Restore this linkage and also create a defined
behavior for the .info dictionary; it is that of the hybrid itself.
Add this behavioral change to the migration notes.
Change-Id: I8ac34ef52039387230c648866c5ca15d381f7fee
References: #3653
Diffstat (limited to 'lib/sqlalchemy/ext')
| -rw-r--r-- | lib/sqlalchemy/ext/hybrid.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/sqlalchemy/ext/hybrid.py b/lib/sqlalchemy/ext/hybrid.py index 18516eae3..2f473fd31 100644 --- a/lib/sqlalchemy/ext/hybrid.py +++ b/lib/sqlalchemy/ext/hybrid.py @@ -771,7 +771,7 @@ class hybrid_property(interfaces.InspectionAttrInfo): producing method.""" def _expr(cls): - return ExprComparator(expr(cls)) + return ExprComparator(expr(cls), self) util.update_wrapper(_expr, expr) self.expr = _expr @@ -819,10 +819,21 @@ class Comparator(interfaces.PropComparator): class ExprComparator(Comparator): + def __init__(self, expression, hybrid): + self.expression = expression + self.hybrid = hybrid def __getattr__(self, key): return getattr(self.expression, key) + @property + def info(self): + return self.hybrid.info + + @property + def property(self): + return self.expression.property + def operate(self, op, *other, **kwargs): return op(self.expression, *other, **kwargs) |
