I'm attaching a test case to show a problem I recently ran into. It seams If I load a group of objects with options(eagerload('someproperty')) where someproperty can be null, I still get all the options.
If I use a select statement and pass that the the instances method with options(contains_eager('someproperty')), the instances returned are only the ones that had the property. It doesn't seem to me that this is how it is supposed to be though. Should I file a bug or am I missing some detail on intended behavior? -Dennis --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---
from sqlalchemy import * e=create_engine('sqlite://memory') ts=Table('ts',e, Column ( 'id',Integer,primary_key=True), Column ( 'dat',Integer,nullable=False)) ts.create() to_oneornone=Table('other',e, Column ( 'ts_id', Integer,ForeignKey('ts.id'), primary_key=True, nullable=False ), Column ( 'other_dat', Integer, nullable=False ) ) to_oneornone.create() class T(object): pass T.mapper=mapper(T,ts) class To(object):pass To.mapper=mapper(To,to_oneornone,properties={'ts':relation(T,backref=backref('other',uselist=False))}) s=create_session() for x in range(10): t=T() t.dat=x s.save(t) if x % 2 == 0: # test every other T has an optional data o=To() o.other_dat=x t.other=o s.save(t) s.flush() s.clear() somedata=s.query(T).options(eagerload('other')).select() print 'Number results should be 10: ', len(somedata) s.clear() sel=select([ts,to_oneornone], from_obj=[ts.outerjoin(to_oneornone)]) print "Raw select also is 10: " , len(sel.execute().fetchall() ) print "Instances should also be 10: ", len(s.query(T).options(contains_eager('other')).instances(sel.execute()))