Opened 17 years ago

Closed 16 years ago

Last modified 16 years ago

#5543 closed (fixed)

cursor.callproc with oracle backend does not work

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

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 16 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 by Simon G. <dev@…>, 17 years ago

Triage Stage: UnreviewedDesign decision needed

comment:2 by Matt Boersma, 17 years ago

Cc: ian.g.kelly@… added
Keywords: Oracle added
Owner: changed from nobody to Matt Boersma
Status: newassigned

comment:3 by Erin Kelly, 17 years ago

Keywords: cursor callproc added
Triage Stage: Design decision neededAccepted

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

Cc: Erin Kelly added; ian.g.kelly@… removed

by hklv, 16 years ago

Attachment: base.py.diff added

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

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

comment:6 by Matt Boersma, 16 years ago

Resolution: fixed
Status: assignedclosed

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

comment:7 by Matt Boersma, 16 years ago

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

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