summaryrefslogtreecommitdiff
path: root/django/db/backends/utils.py
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2017-08-12 21:06:49 +0200
committerGitHub <noreply@github.com>2017-08-12 21:06:49 +0200
commit489421b01562494ab506de5d30ea97d7b6b5df30 (patch)
tree3ccf4b471f71c44e48e17dd028bcdb7e2262cc8b /django/db/backends/utils.py
parent47ccefeada926ffbccaa354dec7a987a7e7ca701 (diff)
Fixed #23546 -- Added kwargs support for CursorWrapper.callproc() on Oracle.
Thanks Shai Berger, Tim Graham and Aymeric Augustin for reviews and Renbi Yu for the initial patch.
Diffstat (limited to 'django/db/backends/utils.py')
-rw-r--r--django/db/backends/utils.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/django/db/backends/utils.py b/django/db/backends/utils.py
index 8d3a8ab4b3..9634807a87 100644
--- a/django/db/backends/utils.py
+++ b/django/db/backends/utils.py
@@ -6,6 +6,7 @@ import re
from time import time
from django.conf import settings
+from django.db.utils import NotSupportedError
from django.utils.encoding import force_bytes
from django.utils.timezone import utc
@@ -45,13 +46,23 @@ class CursorWrapper:
# The following methods cannot be implemented in __getattr__, because the
# code must run when the method is invoked, not just when it is accessed.
- def callproc(self, procname, params=None):
+ def callproc(self, procname, params=None, kparams=None):
+ # Keyword parameters for callproc aren't supported in PEP 249, but the
+ # database driver may support them (e.g. cx_Oracle).
+ if kparams is not None and not self.db.features.supports_callproc_kwargs:
+ raise NotSupportedError(
+ 'Keyword parameters for callproc are not supported on this '
+ 'database backend.'
+ )
self.db.validate_no_broken_transaction()
with self.db.wrap_database_errors:
- if params is None:
+ if params is None and kparams is None:
return self.cursor.callproc(procname)
- else:
+ elif kparams is None:
return self.cursor.callproc(procname, params)
+ else:
+ params = params or ()
+ return self.cursor.callproc(procname, params, kparams)
def execute(self, sql, params=None):
self.db.validate_no_broken_transaction()