Re: [sqlalchemy] Polymorphic AbstractConcreteBase , eager load , conditions , etc

2018-03-08 Thread Mike Bayer
just to add, getting full flexibility in abstract concrete loading is possibly technically feasible, I have some ideas here, but would require a lot of effort on my part. i have ideas how to get what you want but it's nothing trivial or that I have any near-term availability to work on. But

Re: [sqlalchemy] Polymorphic AbstractConcreteBase , eager load , conditions , etc

2018-03-07 Thread Mike Bayer
you can use multiple types, but the question is if you want to *load* multiple subtypes *at the same time* while not loading othersif you need to load sub-groups of subtypes all at once then AbstractConcreteBase is going to create lots of problems for you and it probably can't handle this use

Re: [sqlalchemy] Polymorphic AbstractConcreteBase , eager load , conditions , etc

2018-03-07 Thread Mike Bayer
if you only need to load against one sub-type at a time, then you shouldn't use any polymorphic features or concrete inheritance. Make your OrderItem just a non-mapped mixin class, then OrderItemTest and whatever else are just normal mapped-to-one-table classes. On Wed, Mar 7, 2018 at 5:39 PM,

Re: [sqlalchemy] Polymorphic AbstractConcreteBase , eager load , conditions , etc

2018-03-07 Thread Mike Bayer
On Wed, Mar 7, 2018 at 4:19 PM, Harshvardhan Gupta wrote: > Calling configure_mappers() fixes the issue. > > However, the next thing I tried was to do joined load ( for eager loading ) > , and it fails. > > This is what I tried : > > > order = >

Re: [sqlalchemy] Polymorphic AbstractConcreteBase , eager load , conditions , etc

2018-03-07 Thread Harshvardhan Gupta
Calling configure_mappers() fixes the issue. However, the next thing I tried was to do joined load ( for eager loading ) , and it fails. This is what I tried : order = db.session.query(Order).join(Order.items.of_type(order_items)).

Re: [sqlalchemy] Polymorphic AbstractConcreteBase , eager load , conditions , etc

2018-03-07 Thread Mike Bayer
my test doesn't have that problem, try calling configure_mappers() first. Try running the test case I have as given. On Wed, Mar 7, 2018 at 4:02 PM, Harshvardhan Gupta wrote: > Thanks for the reply. > > Sorry, I will be more careful when i sent code snippets. > > I tried

Re: [sqlalchemy] Polymorphic AbstractConcreteBase , eager load , conditions , etc

2018-03-07 Thread Harshvardhan Gupta
Thanks for the reply. Sorry, I will be more careful when i sent code snippets. I tried this out after you asked me to remove flat =True, so the code looks like this now : pjoin = polymorphic_union({ 'order_test_item': OrderTestItem.__table__, }, 'type', 'pjoin') # I dont think

Re: [sqlalchemy] Polymorphic AbstractConcreteBase , eager load , conditions , etc

2018-03-07 Thread Mike Bayer
found a few mentions of "flat=True" that fail to specify that this flag should **not** be used when selectable= is set, pushing extra verbiage to that effect now. most likely with_polymorphic() should raise an error if both flags are set. On Wed, Mar 7, 2018 at 3:48 PM, Mike Bayer

Re: [sqlalchemy] Polymorphic AbstractConcreteBase , eager load , conditions , etc

2018-03-07 Thread Mike Bayer
here's a full MCVE, which with "flat=True" reproduces your issue exactly (send me this next time). The issue is the "flat=True", take that out because it isn't compatible with a concrete union - it implies the "aliased" flag and that gets in the way of what the polymorphic_union() function is

Re: [sqlalchemy] Polymorphic AbstractConcreteBase , eager load , conditions , etc

2018-03-07 Thread Harshvardhan Gupta
Thanks for replying. I forgot to show the error. It is this: 1054, "Unknown column 'pjoin.order_id' in 'on clause'") [SQL: "SELECT `order`.id AS order_id, `order`.rp_id AS order_rp_id, `order`.user_id AS order_user_id \nFROM `order` INNER JOIN (SELECT order_test_item.order_id AS order_id,

Re: [sqlalchemy] Polymorphic AbstractConcreteBase , eager load , conditions , etc

2018-03-07 Thread Mike Bayer
On Tue, Mar 6, 2018 at 8:36 PM, Harshvardhan Gupta wrote: > I tried to use AbstractConcreteBase for polymorphic relationships , but I am > getting errors. The examples in sqlalchemy cover normal polymorphism well, > but not those with Abstract Base classes. > > > I have

[sqlalchemy] Polymorphic AbstractConcreteBase , eager load , conditions , etc

2018-03-06 Thread Harshvardhan Gupta
I tried to use AbstractConcreteBase for polymorphic relationships , but I am getting errors. The examples in sqlalchemy cover normal polymorphism well, but not those with Abstract Base classes. I have already asked a question on stack overflow