zzzeek / test_sqlalchemy

0 stars 0 forks source link

eager loading overhaul #68

Closed sqlalchemy-bot closed 18 years ago

sqlalchemy-bot commented 18 years ago

Issue created by Michael Bayer (zzzeek)


eager loading continues to be subject to gotchas, still doenst detect "circular" eager loads if you make an eager load mapper, with a property, with ia backref on that property, then eagerload that backref, i.e.

Place._mapper = mapper(Place, place)
Transition.mapper = mapper(Transition, transition, properties = dict(
   inputs = relation(Place._mapper, input_arc, lazy=False, backref='outputs'),
   )
)

Place.mapper = Place._mapper.options(
    eagerload('outputs')
)

loading from Place.mapper will descend into Transition's mapper back to Places again, and even with aliases turned on in the relations it still puts the tables into the join criterion too many times and the query breaks. EagerLoader code is also sprawling at this point.

so we are going to simplify again, have eagerloader just aliasize all of its criterion every time to simplify a lot of the "alias" gymnastics, and upon init create its own "chain" of eager loaders, it will build them all from scratch each time to avoid conflicts with other eager loaders, and will detect cycles via the primary class or table being mapped to, and at the point of circular create a lazyloader to break the cycle.

so, we will no longer need 'use_alias', we will no longer raise an exception if a 'cycle' is detected. it will just work the first time in all cases.

sqlalchemy-bot commented 18 years ago

Michael Bayer (zzzeek) wrote:


committed in changeset:1010, the Place/Transition test passes with flying colors

sqlalchemy-bot commented 18 years ago

Changes by Michael Bayer (zzzeek): set state to "resolved"