Code

Opened 4 years ago

Closed 4 years ago

Last modified 3 years ago

#13076 closed (invalid)

Oracle backend: Error ORA-01036 when using extra() with params

Reported by: aprilmay Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Keywords: Oracle extra
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

The extra function on query_set give an error when using it with "params" (using Oracle 9i, cx_Oracle 5.0.2).

MyModel.objects.extra(where=["DESCRIPTION like '%s'"], params=["something"])

throws:

DatabaseError: ORA-01036: illegal variable name/number

Note: the following works

MyModel.objects.extra(where=["DESCRIPTION like 'something'"])

Attachments (0)

Change History (2)

comment:1 Changed 4 years ago by kmtracey

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

Don't attempt to do your own quoting in the where clause when you are supplying parameters. That is, remove the quotes around '%s'; the backend will handle quoting and any escaping necessary for the parameters you pass. See: http://docs.djangoproject.com/en/dev/ref/models/querysets/#extra-select-none-where-none-params-none-tables-none-order-by-none-select-params-none

comment:2 Changed 3 years ago by jacob

  • milestone 1.2 deleted

Milestone 1.2 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.