On Thu, Feb 20, 2014 at 5:22 PM, Jonathan Vanasco <jonat...@findmeon.com> wrote: > this seems to work, but I want to just make sure this is the intended > behavior. > > a = dbSession.query( Something ).filter( Something.primary_key == 1 > ).first() > b = dbSession.query( Something ).get( 1 ) > c = dbSession.query( Something ).get( 1 ) > d = dbSession.query( Something ).get( 1 ) > e = dbSession.query( Something ).get( 1 ) > > in the above example , we will only hit the database once , because the > 'filter' populates the local session map with the primary key. right ?
Only as long as you keep a reference to the object returned by the first query, since the identity map is a weak map. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/groups/opt_out.