Opened 17 years ago
Closed 11 years ago
#4492 closed Cleanup/optimization (fixed)
Provide tests for mixed-case column names
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Normal | Keywords: | postgresql psycopg |
Cc: | mir@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | yes | UI/UX: | no |
Description
Django generates this query, which gives this error:
SELECT setval('"product_item_relatedItems_id_seq"', (SELECT max("id") FROM product_item_relatedItems)); psycopg.ProgrammingError: ERROR: relation "product_item_relateditems" does not exist
I'm attaching a patch to generate this query instead:
SELECT setval('"product_item_relatedItems_id_seq"', (SELECT max("id") FROM "product_item_relatedItems"));
Attachments (6)
Change History (24)
by , 17 years ago
Attachment: | add-quote_name.diff added |
---|
comment:1 by , 17 years ago
by , 17 years ago
Attachment: | add-quote_name-psycopg2.diff added |
---|
comment:2 by , 17 years ago
Cc: | added |
---|
comment:3 by , 17 years ago
To reproduce:
- Create a model with a mixed-case ManyToManyField:
class Item(models.Model): relatedItems = models.ManyToManyField('self', blank=True, null=True)
- Load a fixture:
- fields: relatedItems: [] model: product.item pk: '1'
- You'll get a backtrace here:
psycopg2.ProgrammingError: relation "product_item_relateditems" does not exist
comment:5 by , 17 years ago
Summary: | SELECT fails for mix-cased column name using postgresql → quote_name missing in postgresql backends |
---|
comment:6 by , 17 years ago
Cc: | added |
---|---|
Triage Stage: | Unreviewed → Ready for checkin |
John, can you bring this up on the developer mailing list? Everything looks good to me, but I don't have the expertise needed here, so I hesitate to put this into "ready for checkin".
I wouldn't mind anybody to advance the stage of this ticket if they think so.
comment:7 by , 17 years ago
Triage Stage: | Ready for checkin → Unreviewed |
---|
reverting my accidental state change.
comment:8 by , 17 years ago
Patch needs improvement: | set |
---|---|
Summary: | quote_name missing in postgresql backends → Provide tests for mixed-case column names |
Triage Stage: | Unreviewed → Accepted |
comment:9 by , 17 years ago
Cc: | removed |
---|
comment:10 by , 16 years ago
Patch needs improvement: | unset |
---|
comment:12 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → Cleanup/optimization |
comment:15 by , 11 years ago
Easy pickings: | set |
---|
comment:16 by , 11 years ago
I just want to clarify: it says tests are needed, but the appropriate checkbox is not ticked. So, is it the tests that are needed or is there something more to this ticket?
p.s.: I'm sprinting django on PyCon UK and I'm looking at this ticket because I have dealt with this problem before. So I know what the issue was, I can write the appropriate tests, but I also want to make it right so that my first contribution wouldn't end up a failure :)
comment:17 by , 11 years ago
https://github.com/django/django/pull/1667
Please review
comment:18 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
On further investigation, I think we have tests to cover this. In particular, if I comment out the fix from [6507], I get a failure in test_generic_relation (backends.tests.SequenceResetTest)
, and here are some models with mixed case column names:
aggregation_regress/models.py: Entry = models.CharField(unique=True, max_length=50) aggregation_regress/models.py: Clue = models.CharField(max_length=150)
I noticed that the psycopg2 backend has the same issue, so here is an additional patch.