Code

Opened 6 years ago

Closed 6 years ago

Last modified 3 years ago

#7109 closed (fixed)

__dict__ substitution in Field.db_type() does no quoting

Reported by: ikelly Owned by: mtredinnick
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:

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.

Attachments (0)

Change History (7)

comment:1 Changed 6 years ago by ikelly

(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 6 years ago by mtredinnick

  • Needs documentation unset
  • Needs tests unset
  • Owner changed from nobody to mtredinnick
  • Patch needs improvement unset

comment:3 Changed 6 years ago by gav

  • Keywords qsrf-cleanup added

comment:4 Changed 6 years ago by jacob

  • milestone set to 1.0

comment:5 Changed 6 years ago by mtredinnick

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 Changed 6 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from new to closed

(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 Changed 3 years ago by jacob

  • milestone 1.0 deleted

Milestone 1.0 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.