From 6f6e2c48ba0be827ee434891f54eb2173edf9bfc Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 18 Apr 2016 16:18:31 -0400 Subject: 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 --- lib/sqlalchemy/ext/hybrid.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'lib/sqlalchemy/ext') 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) -- cgit v1.2.1