Opened 9 years ago

Closed 8 years ago

Last modified 8 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: master
Severity: Keywords: oracle Oracle db backend cursor callproc
Cc: Ian Kelly 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 8 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 9 years ago by Simon G. <dev@…>

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Triage Stage: UnreviewedDesign decision needed

comment:2 Changed 9 years ago by Matt Boersma

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

comment:3 Changed 9 years ago by Ian Kelly

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 Changed 9 years ago by Ian Kelly

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

Changed 8 years ago by hklv

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 Changed 8 years ago by Ian Kelly

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

comment:6 Changed 8 years ago by Matt Boersma

Resolution: fixed
Status: assignedclosed

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

comment:7 Changed 8 years ago by Matt Boersma

(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