- marked as critical
ScopedSession.mapper: query attribute on inherited classes
Issue #746
resolved
orm.scoping._ScopedExt.instrument_class has:
if not hasattr(class_, 'query'):
class_.query = query()
so a subclass gets its parent's query attribute! This causes unexpected behaviour: especially when using polymorphic loading: Subclass.query.all()
returns all of the base class's known instances!
perhaps setattr unconditionally (the user chose to use ScopedSession.mapper), unless there is a way to check for attributes on the actual class and not the superclasses?
Comments (3)
-
repo owner -
repo owner - changed status to resolved
-
repo owner - removed milestone
Removing milestone: 0.4.0 (automated comment)
- Log in to comment
yeah thats a bug. all it has to do is check
"query" in class_.__dict__
instead.