Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>1) From the <a href="http://www.sqlalchemy.org/docs/orm/session.html#frequently-asked-questions" rel="nofollow">Session documentation</a>:</p> <blockquote> <p>[The Session] is somewhat used as a cache, in that it implements the identity map pattern, and stores objects keyed to their primary key. However, it doesn’t do any kind of query caching. ... It’s only when you say query.get({some primary key}) that the Session doesn’t have to issue a query.</p> </blockquote> <p>2.1) You are correct, relationships are not modified when you refresh an object.</p> <p>2.2) Yes, the group will be in the identity map.</p> <p>2.3) I believe your best bet will be to attempt to reload the entire group.items in a single query. From my experience it is usually much quicker to issue one large request than several smaller ones. The only time it would make sense to only reload a specific group.item is there was exactly one of them that needed to be loaded. Though in that case you are doing one large query instead of one small one so you don't actually reduce the number of queries.</p> <p>I have not tried it, but I believe you should be able to use the <a href="http://www.sqlalchemy.org/docs/orm/mapper_config.html?highlight=identity#sqlalchemy.orm.util.identity_key" rel="nofollow">sqlalchemy.orm.util.identity_key</a> method to determine whether an object is in sqlalchemy's identiy map. I would be interested to find out what calling identiy_key(Group, 83) returns.</p> <p>Initial Question) If I understand correctly you have an object that you fetched from the database where some of its relationships were eagerloaded and you would like to fetch the rest of the relationships with a single query? I believe you may be able to use the <a href="http://www.sqlalchemy.org/docs/orm/session.html#sqlalchemy.orm.session.Session.refresh" rel="nofollow">Session.refresh()</a> method passing in the the names of the relationships that you want to load.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload