OK, it looks like we did add this at some point, though I could not find a unit
test where I would expect. So I added one in the latest tip. Here it is:
class OrderByTest(QueryTest, AssertsCompiledSQL):
def test_cancel_order_by(self):
s = create_session()
q = s.query(User).order_by(User.id)
self.assert_compile(q,
"SELECT users.id AS users_id, users.name AS users_name FROM users
ORDER BY users.id",
use_default_dialect=True)
q = q.order_by(None)
self.assert_compile(q,
"SELECT users.id AS users_id, users.name AS users_name FROM
users",
use_default_dialect=True)
and it passes. So how to reproduce the failure I assume you are getting ?
On Jun 17, 2010, at 3:14 AM, Andi Albrecht wrote:
> It's not different at all. I've just noticed that on the one hand it
> *is* possible to use query.order_by(None) to remove any previously set
> ordering, but on the other hand that _no_select_modifiers() in
> sqlalchemy/orm/query.py checks for False (and not None). It would be
> clearer to me if either order_by(False) would work too or - even
> better - if _no_select_modifiers() would allow None for _order_by.
>
> Andi
>
> On Wed, Jun 16, 2010 at 3:30 PM, Michael Bayer <[email protected]>
> wrote:
>> its not really provided right now, the same way saying query.filter(None)
>> won't reset any existing WHERE criterion, or join(None) doesn't remove all
>> joins. This issue has come up before. How is order_by() different ?
>>
>>
>> On Jun 16, 2010, at 8:05 AM, Andi Albrecht wrote:
>>
>>> Hi,
>>>
>>> I'm a bit curious about how to unset an order_by in 0.6.
>>>
>>> query.order_by(None) should do it, but in sqlalchemy/orm/query.py in
>>> _no_select_modifiers() the notset value for the _order_by attribute is
>>> False. In turn, the order_by() method doesn't seem to accept False.
>>>
>>> What would be a proper way to unset an order_by? In my case the
>>> order_by is set when classes are mapped.
>>>
>>> Best regards,
>>>
>>> Andi
>>>
>>> --
>>> 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.
>>>
>>
>> --
>> 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.
>>
>>
>
> --
> 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.
>
--
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.