On 2/25/06, Ned Batchelder <ned nedbatchelder.com>
wrote:
> If I specify an 'ordering' attribute in my model's
META class, it gets
> used even for single-object selects, for example,
get_object.
>
> So there are SQL queries like this:
>
> SELECT field, field FROM app_model WHERE id = 50 ORDER
BY date DESC
>
> Surely the ORDER BY clause can be omitted? Is the
magic-removal branch
> already fixing this?
Thanks for pointing this out. You can remove the ORDER BY
clause
entirely by passing an empty tuple or list as the order_by
argument to
get_object():
someapp.get_object(pk=50, order_by=())
But that's a pretty lame hack.
It would be easy to change the behavior for get_object() so
that it
doesn't use the ordering clause from the model. My only
hesitation is
that it would slightly change the meaning of get_object(),
because
some people might be using, for example,
get_object(limit=1), relying
on the fact that get_object() would be using the model's
ordering.
However, I think this is an acceptable change, as long as we
document
the change on the backwards-incompatible changes page. Any
objections
before I check in that change to trunk?
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-users googlegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribe googlegroups.com
For more options, visit this group at http://gr
oups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---
|