Django

Code

Ticket #7109 (closed: fixed)

Opened 4 months ago

Last modified 2 months ago

__dict__ substitution in Field.db_type() does no quoting

Reported by: ikelly Assigned to: mtredinnick
Milestone: 1.0 Component: Database wrapper
Version: SVN Keywords: qsrf-cleanup oracle
Cc: Triage Stage: Unreviewed
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

Change History

04/28/08 12:31:09 changed 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

04/28/08 19:49:40 changed by mtredinnick

  • owner changed from nobody to mtredinnick.
  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

06/10/08 11:00:05 changed by gav

  • keywords changed from oracle to qsrf-cleanup oracle.

06/16/08 12:10:45 changed by jacob

  • milestone set to 1.0.

06/25/08 22:01:32 changed 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.

06/25/08 22:11:33 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to fixed.

(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).


Add/Change #7109 (__dict__ substitution in Field.db_type() does no quoting)




Change Properties
Action