Opened 8 years ago
Closed 8 years ago
#28206 closed Bug (fixed)
Raw queries with Oracle impossible when using uppercase column names
Reported by: | Dmitry Shachnev | Owned by: | Mariusz Felisiak |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Normal | Keywords: | Oracle |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
When one has a model with a custom column name in uppercase, say:
class Man(Model): id = models.AutoField(primary_key=True, db_column="F_MAN_ID")
Then it is impossible to use RawQuerySets with this model on Oracle, you will always get the “InvalidQuery: Raw query must include the primary key” error.
The problem is that column_name_converter()
converts the column names to lowercase, so even if you use F_MAN_ID
in your query, the self.columns
list in the RawQuerySet instance will contain the lowercase column name. And because of case differences the f.column in self.columns
check in resolve_model_init_order
method will return False.
We are currently using Django 1.8 in production, but I looked at the Django code and it’s the same between 1.8 and 1.11, so I have put 1.11 into the Version field.
Attachments (1)
Change History (6)
by , 8 years ago
Attachment: | 28206.diff added |
---|
comment:1 by , 8 years ago
Keywords: | Oracle added |
---|---|
Triage Stage: | Unreviewed → Accepted |
Version: | 1.11 → master |
comment:2 by , 8 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:4 by , 8 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Test