King Simon-NFHD78 wrote: > Huy wrote: > >> Hi, >> >> When using the generative limit() offset() or order_by calls >> on mapper >> query, the sql generated looks weird. >> >> I get something like >> >> select table1.* table2.* >> from (select table1a.id from table1a limit 20 offset 0 order by >> table1.col) as table_row, table1 join table2 (on...) >> .... >> >> Notice how the limit and offset is in that subselect ? Is >> this by design. >> The query results are not what I would expect either because the >> subselect doesn't join to the main table (table1). >> >> Hope what I"m describing makes sense. >> >> > > If the outer query involved eager loading of many-to-many properties, > the number of rows returned would not necessarily be the same as the > number of entities being loaded. By doing the limit and offset in the > inner query, it guarantees that you will get exactly the expected number > of entities. > > At least, that's my understanding. Hope that helps Hi Simon,
That makes perfect sense, but why is the inner query joined not joined with the main table from the outer query ? because this is not done, I get a cartesian product between the inner result with the outer result. Thanks Huy --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---