Code

Opened 7 years ago

Closed 5 years ago

Last modified 5 years ago

#5543 closed (fixed)

cursor.callproc with oracle backend does not work

Reported by: stefan@… Owned by: mboersma
Component: Database layer (models, ORM) Version: master
Severity: Keywords: oracle Oracle db backend cursor callproc
Cc: ikelly Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: yes
Easy pickings: UI/UX:

Description

When using cx_oracle standalone, in order to call stored procedures, it is possible to call them using callproc(), which does some jobs including using bind variables for you. However, in django's FormatStylePlaceholderCursor wrapper class, there is no callproc(). That means that calling callproc() as a member of a FormatStylePlaceholderCursor cursor will call the original cx_oracle callproc(). This in turn uses django's execute(). It is probably expecting the behaviour of the original execute.
In this case the query is however not to be changed. Maybe a solution is to add a callproc function to the wrapper class and let it duplicate cx_oracle's callproc so it works with djangos parameters.

The error raised is:

 File "/usr/lib/python2.5/site-packages/django/db/backends/oracle/base.py" in execute
  483. query = smart_str(query, self.charset) % tuple(args)

  TypeError at /test/ora_django/
  not all arguments converted during string formatting

Attachments (1)

base.py.diff (6.7 KB) - added by hklv 6 years ago.
Patch for Django-1.0/django/db/backends/oracle/base.py. Adds support for Oracle stored procedures and functions ("callproc" and "callfunc" method ). Added a "commit" method. Fixed a typo in the _format_params method.

Download all attachments as: .zip

Change History (8)

comment:1 Changed 7 years ago by Simon G. <dev@…>

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Design decision needed

comment:2 Changed 7 years ago by mboersma

  • Cc ian.g.kelly@… added
  • Keywords Oracle, added
  • Owner changed from nobody to mboersma
  • Status changed from new to assigned

comment:3 Changed 7 years ago by ikelly

  • Keywords oracle Oracle db cursor callproc added; oracle, Oracle, db, removed
  • Triage Stage changed from Design decision needed to Accepted

cx_Oracle's callproc is written in C and might not be straightforward to reproduce in Python, code duplication issues aside. I suggest we have the execute (and executemany?) method inspect the query to determine the style of placeholder used. This could be as simple as throwing a try..except around the query reformatting.

comment:4 Changed 6 years ago by ikelly

  • Cc ikelly added; ian.g.kelly@… removed

Changed 6 years ago by hklv

Patch for Django-1.0/django/db/backends/oracle/base.py. Adds support for Oracle stored procedures and functions ("callproc" and "callfunc" method ). Added a "commit" method. Fixed a typo in the _format_params method.

comment:5 Changed 5 years ago by ikelly

  • Has patch set
  • Needs tests set
  • Patch needs improvement set

comment:6 Changed 5 years ago by mboersma

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

(In [9767]) Fixed #5543: callproc() and friends now work with Oracle and our FormatStylePlaceholderCursor.

comment:7 Changed 5 years ago by mboersma

(In [9768]) [1.0.X] Fixed #5543: callproc() and friends now work with Oracle and our FormatStylePlaceholderCursor.

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.