Re: [sqlalchemy] Eager-load a CTE via relationship or column property

2016-06-03 Thread Mike Bayer
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

Re: [sqlalchemy] Eager-load a CTE via relationship or column property

2016-06-03 Thread Adrian
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 =

Re: [sqlalchemy] Eager-load a CTE via relationship or column property

2016-06-03 Thread Mike Bayer
you would first set up a traditional adjacency list relationship as in http://docs.sqlalchemy.org/en/latest/orm/self_referential.html?highlight=adjacency%20list. Second, as you run this query you can retrieve Category objects fully, however they will be in a straight down list. As you

[sqlalchemy] Eager-load a CTE via relationship or column property

2016-06-03 Thread Adrian
I have a Category model that has (among other things) a `id` and `parent_id` since my categories are organized in a tree. @property def chain_query(self): """Get a query object for the category chain. The query retrieves the root category first and then all the