Re: [sqlalchemy] Trying to get filtering and ordering to work with hybrid properties in single table inheritance

2017-11-03 Thread Tucker Beck
Things seem to be working with this as it is now. Adding the __clause_element__ in the comparator seems to make the need for the expression go away. Thanks so much, Mike. I'm always impressed that you take the time to answer questions so helpfully! On Tuesday, October 31, 2017 at 10:37:14 AM

Re: [sqlalchemy] Trying to get filtering and ordering to work with hybrid properties in single table inheritance

2017-10-31 Thread Mike Bayer
the correlate_except tells it exactly what to "correlate" and what not to, preventing that "auto-correlation" error. try it out and then show me how you'd like the SQL to be adjusted given a particular Query. On Tue, Oct 31, 2017 at 1:32 PM, Tucker Beck wrote: > I'll try

Re: [sqlalchemy] Trying to get filtering and ordering to work with hybrid properties in single table inheritance

2017-10-31 Thread Tucker Beck
I'll try this out. The comparator was put in so that queries comparing the hybrid_type_name against a string would do a proper sub-select against the EntityType table. If we didn't provide the comparator, the hybrid expression was used and the resulting query was orders of magnitude slower. Does

Re: [sqlalchemy] Trying to get filtering and ordering to work with hybrid properties in single table inheritance

2017-10-31 Thread Mike Bayer
that error can be fixed using correlate_except: @classmethod def hybrid_type_name_subquery(cls): return select([HybridType.name]).\ where(HybridType.id == cls.hybrid_type_id).\ correlate_except(HybridType).as_scalar() but now that we're looking at your

Re: [sqlalchemy] Trying to get filtering and ordering to work with hybrid properties in single table inheritance

2017-10-31 Thread Tucker Beck
Thanks so much for getting back so fast, Mike! For some background: we started with the expression, but then discovered that the performance we were getting was pretty bad on queries when the table was large and we were filtering by the hybrid attribute. Postgres was doing a sequence-scan, and

Re: [sqlalchemy] Trying to get filtering and ordering to work with hybrid properties in single table inheritance

2017-10-30 Thread Mike Bayer
On Mon, Oct 30, 2017 at 6:43 PM, Tucker Beck wrote: > I wrestled through getting a model heirarchy to work with single-table > inheritance that is polymorphic on a hybrid attribute on this mailing list a > while ago. > > see:

[sqlalchemy] Trying to get filtering and ordering to work with hybrid properties in single table inheritance

2017-10-30 Thread Tucker Beck
I wrestled through getting a model heirarchy to work with single-table inheritance that is polymorphic on a hybrid attribute on this mailing list a while ago. see: https://groups.google.com/d/topic/sqlalchemy/KJXSHwbhbLA/discussion The problem I'm running into now is that it doesn't seem to