Opened 12 years ago

Closed 12 years ago

#6664 closed (fixed)

Strange effect of invalid ordering in qs-rf

Reported by: Petr Marhoun <petr.marhoun@…> Owned by: nobody
Component: Database layer (models, ORM) Version: queryset-refactor
Severity: Keywords: qs-rf
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


I have tried very simple model (with 20 objects):

class A(models.Model):
    value = models.IntegerField()

And this code:

>>> A.objects.count()
>>> len(list(A.objects.order_by('value')))
>>> len(list(A.objects.order_by('nonsense'))) # Should it be an exception?
>>> A.objects.order_by('nonsense')
TypeError: Cannot resolve keyword 'nonsense' into field. Choices are: id, value

Change History (2)

comment:1 Changed 12 years ago by Malcolm Tredinnick

Triage Stage: UnreviewedAccepted

This is a cool error: when calling list(), Python tries to work with pre-iterator-protocol objects as well. Which means it quietly swallows TypeError (only). Sadly, that was precisely the exception we were raising in this case. I'm going to change the exception type to something less confusing. (Thanks to Jacob for guessing what was going wrong here.)

comment:2 Changed 12 years ago by Malcolm Tredinnick

Resolution: fixed
Status: newclosed

Fixed in [7163]

Note: See TracTickets for help on using tickets.
Back to Top