Commit f9840980 authored by Serge S. Koval's avatar Serge S. Koval Committed by GitHub

Merge pull request #1379 from jmagnusson/is_hybrid_property-callable-fix

Fix regression with late-evaluation relationships no longer working with filters
parents 226f2360 b71634c3
import types
from sqlalchemy import tuple_, or_, and_, inspect
from sqlalchemy.ext.declarative.clsregistry import _class_resolver
from sqlalchemy.ext.hybrid import hybrid_property
......@@ -201,6 +203,8 @@ def is_hybrid_property(model, attr_name):
last_model = attr.property.argument
if isinstance(last_model, _class_resolver):
last_model = model._decl_class_registry[last_model.arg]
elif isinstance(last_model, types.FunctionType):
last_model = last_model()
last_name = names[-1]
return last_name in get_hybrid_properties(last_model)
else:
......
......@@ -84,7 +84,7 @@ def create_models(db):
# Relation
model1_id = db.Column(db.Integer, db.ForeignKey(Model1.id))
model1 = db.relationship(Model1, backref='model2')
model1 = db.relationship(lambda: Model1, backref='model2')
db.create_all()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment