An error would be swell. I'd already moved on to the saner solution you mentioned, but was curous about the dont-say-limit-just-say-slice advice I had seen, since I'd reflexively written it that way against an ordered index query.
On Aug 24, 7:21 am, "Michael Bayer" <[email protected]> wrote: > john smallberries wrote: > > > I just tried limiting a query to the final 10 items of a 30010 item > > table using this slice notation: > > q = some.Session.query() > > items = q[-10:] > > the resulting mysql query had no limit or offset clause. Changing the > > form to > > items = q[q.count()-10:] > > produced: > > select from data LIMIT 30000, 18446744073709551615 > > (which worked fine in practice). Changing the form to > > items = q[q.count()-10:q.count()] > > produced the desired: > > select from data LIMIT 30000, 10 > > > Is that the expected behavior for negative indices? > > I am using SA 0.5.4p2 > > I sort of thought that negative indexes would be raising an error by now > since they are somewhat nonsensical in SQL, and SQLA is not going to issue > a COUNT for you in a case like that. you really should be ordering in > reverse if you want to get the last N rows of a result. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [email protected] 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 -~----------~----~----~----~------~----~------~--~---
