Opened 9 years ago

Closed 8 years ago

Last modified 5 years ago

#7109 closed (fixed)

__dict__ substitution in Field.db_type() does no quoting

Reported by: Ian Kelly Owned by: Malcolm Tredinnick
Component: Database layer (models, ORM) Version: master
Severity: Keywords: qsrf-cleanup oracle
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


For example, a BooleanField named "public" would generate the following syncdb SQL in Oracle:

"PUBLIC" NUMBER(1) CHECK (public IN (0,1))

Since the use of the SQL keyword "public" in the check constraint is not quoted, Oracle throws an error.

Change History (7)

comment:1 Changed 9 years ago by Ian Kelly

(In [7501]) Renamed a field in the queries test schema that was preventing the tests from running in Oracle. I've opened #7109 to address the general problem. Refs #7109

comment:2 Changed 9 years ago by Malcolm Tredinnick

Owner: changed from nobody to Malcolm Tredinnick

comment:3 Changed 8 years ago by George Vilches

Keywords: qsrf-cleanup added

comment:4 Changed 8 years ago by Jacob

milestone: 1.0

comment:5 Changed 8 years ago by Malcolm Tredinnick

It's probably unwise to quote every value we pass in db_type, since numerical values like max_length might have unintended side-effects somewhere if they are quotes (is VARCHAR2("2") valid everywhere, for example?).

I'm about to commit some code that will only quote variables beginning with "qn_" in their name, which means %(column)s becomes%(qn_column)s in oracle/ It looks like column is the only case that needs quoting here, but please check this, Ian and obviously adjust any others I may have missed. For now, I'll only change the Oracle backend's creation file, since the other database don't seem to need this extra level of quoting. If they do, it's just a matter of doing the variable rename in their files as well.

comment:6 Changed 8 years ago by Malcolm Tredinnick

Resolution: fixed
Status: newclosed

(In [7743]) Fixed #7109 -- Quote certain values before passing them for substitution in

This fixes a problem with using reserved words for field names in Oracle. Only
affects Oracle at the moment, but the same changes could easily be used by
other backends if they are required (requires changing, only).

This commit also reverts [7501] so that if the fix doesn't work, it will show
up in the tests (and if it does work, the tests will prevent us from breaking
it again).

comment:7 Changed 5 years ago by Jacob

milestone: 1.0

Milestone 1.0 deleted

Note: See TracTickets for help on using tickets.
Back to Top