mirror of
https://github.com/django/django.git
synced 2025-07-05 18:29:11 +00:00
[boulder-oracle-sprint] Cleaned up oracle backend somewhat:
* query format style conversion should now work * removed hardcoded "print" statements * uppercase quoted identifiers (which Oracle seems to require) git-svn-id: http://code.djangoproject.com/svn/django/branches/boulder-oracle-sprint@3967 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
5e8d740caa
commit
f70998c1b8
@ -69,30 +69,30 @@ class FormatStylePlaceholderCursor(Database.Cursor):
|
|||||||
you'll need to use "%%s".
|
you'll need to use "%%s".
|
||||||
"""
|
"""
|
||||||
def execute(self, query, params=None):
|
def execute(self, query, params=None):
|
||||||
if params is None: params = []
|
if params is None:
|
||||||
query = self.convert_arguments(query, len(params))
|
params = []
|
||||||
|
args = [(':arg%s' % i) for i in range(num_params)]
|
||||||
|
query = query % tuple(args)
|
||||||
|
|
||||||
# cx can not execute the query with the closing ';'
|
# cx can not execute the query with the closing ';'
|
||||||
if query.endswith(';') :
|
if query.endswith(';'):
|
||||||
query = query[0:len(query)-1]
|
query = query[0:len(query)-1]
|
||||||
print query
|
return Database.Cursor.execute(self, query, params)
|
||||||
print params
|
|
||||||
return Database.Cursor.execute(self, query, params)
|
|
||||||
|
|
||||||
def executemany(self, query, params=None):
|
def executemany(self, query, params=None):
|
||||||
if params is None: params = []
|
if params is None: params = []
|
||||||
query = self.convert_arguments(query, len(params[0]))
|
query = self.convert_arguments(query, len(params[0]))
|
||||||
# cx can not execute the query with the closing ';'
|
# cx can not execute the query with the closing ';'
|
||||||
if query.endswith(';') :
|
if query.endswith(';') :
|
||||||
query = query[0:len(query)-1]
|
query = query[0:len(query)-1]
|
||||||
return Database.Cursor.executemany(self, query, params)
|
return Database.Cursor.executemany(self, query, params)
|
||||||
|
|
||||||
def convert_arguments(self, query, num_params):
|
|
||||||
# replace occurances of "%s" with ":arg" - Oracle requires colons for parameter placeholders.
|
|
||||||
args = [':arg' for i in range(num_params)]
|
|
||||||
return query % tuple(args)
|
|
||||||
|
|
||||||
def quote_name(name):
|
def quote_name(name):
|
||||||
return name
|
if name.startswith('"') and name.endswith('"'):
|
||||||
|
return name # Quoting once is enough.
|
||||||
|
|
||||||
|
# Oracle requires that quoted names be uppercase.
|
||||||
|
return '"%s"' % name.upper()
|
||||||
|
|
||||||
dictfetchone = util.dictfetchone
|
dictfetchone = util.dictfetchone
|
||||||
dictfetchmany = util.dictfetchmany
|
dictfetchmany = util.dictfetchmany
|
||||||
|
Loading…
x
Reference in New Issue
Block a user