On 06/03/2016 11:18 AM, Adrian wrote:
I think there's a misunderstanding - I don't want to manually populate
the relationship, I want to avoid spamming queries if I get e.g. 10
categories and need the parent chains for all of them.

Here's a pseudo-ish example of what I'd like to do (without queries in
the loop):

categories = Category.query.filter(Category.id.in_([1, 2, 3, 4, 5,
6])).options(...)
for category in categories:
    print category, category.parent_list

Would you like "parent_list" to be populated, or not? I showed you how to pre-populate it so that it wont lazy load.

if you want it to just do nothing, set lazy=None for it, but I don't think that's what you want here. It looks like you want it to have something inside of it.






--
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
<mailto:sqlalchemy+unsubscr...@googlegroups.com>.
To post to this group, send email to sqlalchemy@googlegroups.com
<mailto:sqlalchemy@googlegroups.com>.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

--
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 https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to