On Friday, February 28, 2014 12:41:46 PM UTC-5, Michael Bayer wrote:

nope.   get() means, “the SELECT may not happen”.  eager loads are always 
> secondary to the fact that the row is being loaded.  if you want to 
> definitely load the row, say filter_by(id…).first().   


Poking at the source this may sort of do most of what you want if you say 
> query.populate_existing().get(1).  the components to make this operation 
> occur are there but they aren’t put together into a tested API (test 
> coverage and documentation are the main things that make it slow to add 
> things like this officially). 
>

Boo.

I have an "internal api" that handles most ( soon to be all ) the 
SqlAlchemy management.  With the amount of code we have right now, it was 
the best way to minimize and manage the impact of constantly evolving 
changes to the schema or product requiresments.

There are times we want to use `filter()`, but for a handful of things -- 
namely calculating Permissions/Authentication for ACLs -- we're switching 
to use `get()`.  I only want to hit the DB once on these.  The queries are 
dynamically generated; most don't have eagerloads.  some do.

.populate_existing will re-fetch the item, no matter what.   I don't want 
to re-fetch the 'core' table if it is already loaded; I just want to fetch 
the misc attributes if they haven't been loaded yet.

i'll just 'touch' the properties in my code if they're needed after the 
'get'.  that will load them.  

 

-- 
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.

Reply via email to