Opened 17 years ago
Closed 16 years ago
#4736 closed (fixed)
manually named primary key columns not properly quoted
Reported by: | Antti Kaihola | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | 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
If the database column for a primary key is named manually using db_column=
and the name contains capital letters, objects can't be saved (at least on PostgreSQL) since the column name is not properly quoted in django.db.models.save()
.
PostgreSQL or psycopg2 seems to convert unquoted column names to all lower case, and this has to be protected with quotes.
Attachments (4)
Change History (8)
by , 17 years ago
Attachment: | manual_pk_quote.diff added |
---|
comment:1 by , 17 years ago
Needs tests: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
Sounds like a valid bug to me, want to add a test case?
by , 17 years ago
Attachment: | pg_capital_pk_test.diff added |
---|
revised test case for primary key db_column with upper case in the name
comment:2 by , 17 years ago
Hmm, the test I just submitted now passes. Maybe this has already been fixed?
by , 17 years ago
Attachment: | manual_pk_quote_6137.2.dff added |
---|
now uses the new qn() function for quoting
comment:3 by , 17 years ago
Needs tests: | unset |
---|
Ok I'm not sure why the test passes also without my patch. Might be PostgreSQL versions. I'm testing with 8.2 now, and I might have been using 8.0 or 8.1 when I submitted this ticket.
Anyway, looking at the code it seems to me that the qn() is really meant to be used there.
comment:4 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
All field objects are handed through to the backend and treated consistently now (post queryset-refactor merge), so this doesn't appear to be an issue any longer.
adds manual pk column name quoting to the save() method