Opened 16 years ago

Closed 16 years ago

Last modified 12 years ago

#7109 closed (fixed)

__dict__ substitution in Field.db_type() does no quoting

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

Description

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 by Erin Kelly, 16 years ago

(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 by Malcolm Tredinnick, 16 years ago

Owner: changed from nobody to Malcolm Tredinnick

comment:3 by George Vilches, 16 years ago

Keywords: qsrf-cleanup added

comment:4 by Jacob, 16 years ago

milestone: 1.0

comment:5 by Malcolm Tredinnick, 16 years ago

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/creation.py. 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 creation.py files as well.

comment:6 by Malcolm Tredinnick, 16 years ago

Resolution: fixed
Status: newclosed

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

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 creation.py, 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 by Jacob, 12 years ago

milestone: 1.0

Milestone 1.0 deleted

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