Re: [sqlalchemy] DISTINCT with LIMIT problem

2013-05-31 Thread Kent
Thanks very much! I got it to work apparently fine using from_self(). I didn't seem to need anything special for eager loads to continue to function... were you only expecting I'd have troubles with eager loads if I used subquery()? On 5/30/2013 6:29 PM, Michael Bayer wrote: On May 30,

Re: [sqlalchemy] DISTINCT with LIMIT problem

2013-05-31 Thread Charlie Clark
Am 30.05.2013, 23:19 Uhr, schrieb Kent jkentbo...@gmail.com: For example, a query may look like this: select distinct count(*) over () as recordcount, tablea.colx, tableb.coly from tablea, tableb where limit 100 This doesn't *quite* work because the analytical window function

Re: [sqlalchemy] DISTINCT with LIMIT problem

2013-05-31 Thread Kent
I allow the user to join with other tables for the purpose of filtering (even though the joined tables won't be selected). Cartesian is probably the wrong term for the effect, but in the end, I get duplicate rows. I could get rid of the need for distinct by extensively using EXISTS clauses

[sqlalchemy] DISTINCT with LIMIT problem

2013-05-30 Thread Kent
We use func.count().over() in order to help support result pagination. When attempting to limit the result set, I have found that if other tables are being joined (for the where clause, but not selected), then I need to add DISTINCT to the query or else the Cartesian result of my query messes

Re: [sqlalchemy] DISTINCT with LIMIT problem

2013-05-30 Thread Michael Bayer
On May 30, 2013, at 5:19 PM, Kent jkentbo...@gmail.com wrote: Solution A: Group by all columns (yielding the same effect as distinct), but which makes the window analytical function process after the group by and yields the correct count (17 instead of 72): are all

Re: [sqlalchemy] DISTINCT with LIMIT problem

2013-05-30 Thread Kent
Thank you, I'll try that, but quick concern: I specifically skipped trying to use .subquery() because the docs say Eager JOIN generation within the query is disabled. Doesn't that mean I won't get my joinedload() results from the inner query? Or does that refer to the outer query having

Re: [sqlalchemy] DISTINCT with LIMIT problem

2013-05-30 Thread Michael Bayer
On May 30, 2013, at 6:06 PM, Kent jkentbo...@gmail.com wrote: Thank you, I'll try that, but quick concern: I specifically skipped trying to use .subquery() because the docs say Eager JOIN generation within the query is disabled. Doesn't that mean I won't get my joinedload() results from