Opened 12 years ago
Closed 7 years ago
#20487 closed Bug (fixed)
oracle: case mixup causes ORA-00918: column ambiguously defined error
Reported by: | Owned by: | Shai Berger | |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.5 |
Severity: | Normal | Keywords: | oracle ORA-00918 |
Cc: | shai@…, carsten.fuchs@… | Triage Stage: | Ready for checkin |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
a model's fields, which have a common related model, led to the issue.
Here is an example:
class Institution(models.Model): name = models.CharField('full name', max_length=50) class Personel(models.Model): institution = models.ForeignKey(Institution) class Protocol(models.Model): Institution = models.ForeignKey('Institution', blank=True, null=True) class StudyAssignment(models.Model): personel = models.ForeignKey(Personel) protocol = models.ForeignKey(Protocol)
which generated sql
SELECT * FROM ( SELECT ROWNUM AS "_RN", "_SUB".* FROM ( SELECT "STUDY_ASSIGNMENT"."ID", "STUDY_ASSIGNMENT"."PERSONEL_ID", "STUDY_ASSIGNMENT"."PROTOCOL_ID", "PERSONEL"."ID" AS Col3 , "PERSONEL"."INSTITUTION_ID" , "INSTITUTION"."ID" AS Col5, "INSTITUTION"."NAME", "PROTOCOL"."ID" AS Col7 , "PROTOCOL"."INSTITUTION_ID" , T5."ID" AS Col9, T5."NAME" AS Col10 FROM "STUDY_ASSIGNMENT" INNER JOIN "PERSONEL" ON ("STUDY_ASSIGNMENT"."PERSONEL_ID" = "PERSONEL"."ID") INNER JOIN "INSTITUTION" ON ("PERSONEL"."INSTITUTION_ID" = "INSTITUTION"."ID") INNER JOIN "PROTOCOL" ON ("STUDY_ASSIGNMENT"."PROTOCOL_ID" = "PROTOCOL"."ID") INNER JOIN "INSTITUTION" T5 ON ("PROTOCOL"."INSTITUTION_ID" = T5."ID") ORDER BY "STUDY_ASSIGNMENT"."ID" DESC ) "_SUB" WHERE ROWNUM <= 21 ) WHERE "_RN" > 0;
To call model StudyAssignment through django admin. Both "PERSONEL"."INSTITUTION_ID" and "PROTOCOL"."INSTITUTION_ID" led to the issue.
Attachments (1)
Change History (11)
comment:1 by , 12 years ago
comment:2 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:3 by , 12 years ago
Resolution: | fixed |
---|---|
Status: | closed → new |
comment:4 by , 12 years ago
Cc: | added |
---|---|
Keywords: | oracle added |
Owner: | changed from | to
Status: | new → assigned |
Summary: | ORA-00918: column ambiguously defined error → oracle: case mixup causes ORA-00918: column ambiguously defined error |
Triage Stage: | Unreviewed → Accepted |
comment:5 by , 10 years ago
Cc: | added |
---|
comment:6 by , 7 years ago
I couldn't reproduce this issue on stable/1.7.x
-> master
. I think we can add a test and close this ticket.
by , 7 years ago
Attachment: | 20487.diff added |
---|
comment:8 by , 7 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Added some cosmetic comments on the PR, but it's mostly good to go.
comment:10 by , 7 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Note:
See TracTickets
for help on using tickets.
Fixed the issues through changing the field name Institution of class Protocol to lower case