#13293 closed (fixed)
r12900 breaks extra() with additional select clauses (Only applies to MySQL SQLCompiler)
Reported by: | Matthias Kestenholz | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Keywords: | MySQL | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
[12900] breaks the following query:
Page.objects.filter(...).extra(select={'_url_length': 'LENGTH(_cached_url)'}).order_by('-_url_length')[0]
LENGTH(_cached_url) is prepended to the list of fields which should be selected, which makes the row tuple one element longer than the fields tuple:
http://code.djangoproject.com/browser/django/trunk/django/db/backends/mysql/compiler.py#L6
Note that this bug only manifests itself under the following conditions:
- The first model field is an AutoField
- The second field is a (Null)?BooleanField
- The retrieved model has a PK of 1L (0L would also work, but auto incrementing primary key fields never have a value of 0L)
The resulting model instance has True instead of 1L as its PK.
Attachments (1)
Change History (6)
by , 15 years ago
Attachment: | 13293.patch added |
---|
comment:1 by , 15 years ago
Has patch: | set |
---|---|
Keywords: | MySQL added |
Summary: | r12900 breaks extra() with additional select clauses → r12900 breaks extra() with additional select clauses (Only applies to MySQL SQLCompiler) |
comment:3 by , 15 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:4 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
Now with a regression test