2 messages in com.googlegroups.sqlalchemy[sqlalchemy] count() does not seem to...
FromSent OnAttachments
Justin21 Dec 2007 08:03 
Michael Bayer21 Dec 2007 08:16 
Subject:[sqlalchemy] count() does not seem to work correctly with relationships
From:Justin (just@gmail.com)
Date:12/21/2007 08:03:46 AM
List:com.googlegroups.sqlalchemy

DB = sqlite

I don't now if this is a bug or an issue with my mapper config, but the count() method does not work correctly through relationships. Given this mapper:

mapper(Branch, branches, properties={ 'reports':dynamic_loader(Report, backref='branch') })

b = sess.query(Branch).first()

print len(b.reports.all()) # returns the correct number or reports for this branch. print b.reports.count() # ignores the relationship returns the total number of reports in the database.

Thanks,