Re: [sqlalchemy] Where clause when using polymorphic_identity on base class

2019-06-27 Thread Dmytro Starosud
I see, thank you, Mike. So, looks like I just wanted strange thing: having class to be distinct from itself. Thank you for clarifying! Dmytro вт, 25 черв. 2019 о 19:26 Mike Bayer пише: > > > On Fri, Jun 21, 2019, at 7:22 AM, Dmytro Starosud wrote: > > Base class A1 contains

Re: [sqlalchemy] Where clause when using polymorphic_identity on base class

2019-06-25 Thread Mike Bayer
On Fri, Jun 21, 2019, at 7:22 AM, Dmytro Starosud wrote: > Base class `A1` contains `polymorphic_identity` (along with > `polymorphic_on`), but `Query(A1)`doesn't produce where clause, whereas > `Query(A2)` (where `A2` is subclass of `A1` with its own > `polymorphic_identity`) does. > Tried

Re: [sqlalchemy] Where clause when using polymorphic_identity on base class

2019-06-25 Thread Dmytro Starosud
Thank you Simon. I think you're right. I should better ask another question, instead of enrolling XY problem here (in short I need to add particular filter to each model). But let's wrap up with this one. Did I understand correctly that I *cannot* have two following things simultaneously: 1.

Re: [sqlalchemy] Where clause when using polymorphic_identity on base class

2019-06-21 Thread Simon King
The extra base class is only needed once per inheritance hierarchy. Do you have a hundred of those? Do you mind if I ask what kind of data you are storing, and how you are structuring your class hierarchy? Thanks, Simon On Fri, Jun 21, 2019 at 1:30 PM Dmytro Starosud wrote: > > Thanks for your

Re: [sqlalchemy] Where clause when using polymorphic_identity on base class

2019-06-21 Thread Dmytro Starosud
Thanks for your reply! > you could probably insert another class as the parent of A1, with no polymorphic identity. This is what I would like to avoid. Otherwise I would need to write some metaclass machinery to inject base class for all hundred models I have. Originally I am going to add this

Re: [sqlalchemy] Where clause when using polymorphic_identity on base class

2019-06-21 Thread Simon King
>From a quick test, this appears to be special behaviour for the base class in an inheritance hierarchy. If you extend your test like this: from sqlalchemy import Column, Integer, String from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import Query, configure_mappers

[sqlalchemy] Where clause when using polymorphic_identity on base class

2019-06-21 Thread Dmytro Starosud
Base class A1 contains polymorphic_identity (along with polymorphic_on), but Query(A1)doesn't produce where clause, whereas Query(A2) (where A2 is subclass of A1 with its own polymorphic_identity) does. Tried looking in docs with no success. I think I am just missing something. from