Discussion:
Session.query(..).all() default "ORDER BY"?
jerryji
2007-12-24 05:46:07 UTC
Permalink
Hi,

My simple Session.query(model.SomeClass).all() is producing an SQL
query statement with an unwanted "ORDER BY some_table.primary_key".
How can this be turned off/overwritten?

Thanks in advance and Merry X'mas!

Jerry
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To post to this group, send email to ***@googlegroups.com
To unsubscribe from this group, send email to sqlalchemy-***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---
Michael Bayer
2007-12-24 19:19:27 UTC
Permalink
Post by jerryji
Hi,
My simple Session.query(model.SomeClass).all() is producing an SQL
query statement with an unwanted "ORDER BY some_table.primary_key".
How can this be turned off/overwritten?
Thanks in advance and Merry X'mas!
ordering by primary key or OID is a configurable default. You can setup
your mapper with mapper(....., order_by=None) (same applies to
relation()), or at the query level as
query(SomeClass).order_by(None).all().

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To post to this group, send email to ***@googlegroups.com
To unsubscribe from this group, send email to sqlalchemy-***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---
jerryji
2007-12-25 02:35:00 UTC
Permalink
It worked great, thanks Michael!

Jerry
Post by Michael Bayer
Post by jerryji
Hi,
My simple Session.query(model.SomeClass).all() is producing an SQL
query statement with an unwanted "ORDER BY some_table.primary_key".
How can this be turned off/overwritten?
Thanks in advance and Merry X'mas!
ordering by primary key or OID is a configurable default. You can setup
your mapper with mapper(....., order_by=None) (same applies to
relation()), or at the query level as
query(SomeClass).order_by(None).all().
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To post to this group, send email to ***@googlegroups.com
To unsubscribe from this group, send email to sqlalchemy-***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Continue reading on narkive:
Loading...