#17429 closed Bug (fixed)
if ordering = None incorrect result
Reported by: | Owned by: | bigkevmcd | |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.3 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Model:
Code highlighting:
class SomeModel(models.Model): value = models.DecimalField(max_digits=5, decimal_places=2) class Meta: ordering = None In [4]: SomeModel.objects.create(value=1) Out[4]: <SomeModel: SomeModel object> In [5]: SomeModel.objects.create(value=2) Out[5]: <SomeModel: SomeModel object> In [6]: SomeModel.objects.count() Out[6]: 2 In [7]: SomeModel.objects.all() Out[7]: []
Attachments (1)
Change History (6)
comment:1 by , 13 years ago
Triage Stage: | Unreviewed → Accepted |
---|
by , 13 years ago
Attachment: | bug_17429.patch added |
---|
comment:2 by , 13 years ago
Has patch: | set |
---|---|
Owner: | changed from | to
follow-up: 5 comment:3 by , 13 years ago
Would it be better to set ordering to () if ordering is None in Model setup? That way this same bug will not raise its head in other places of the code.
comment:5 by , 13 years ago
Replying to anonymous:
Would it be better to set ordering to () if ordering is None in Model setup? That way this same bug will not raise its head in other places of the code.
I think it's best to at least put some safe-guarding in SQLCompiler.get_ordering()
as that was done in [17334]. If you see any place in the code where more safe-guarding is required, please open a new ticket. Thanks!
Simple test and patch for this (it was throwing an error because None is not iterable)