ScopedSession.mapper: query attribute on inherited classes

Issue #746 resolved
Former user created an issue

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)

  1. Log in to comment