mirror of
https://github.com/django/django.git
synced 2025-07-05 02:09:13 +00:00
boulder-oracle-sprint: Fixed unicode bind param handling. Only 3 tests fail
now... git-svn-id: http://code.djangoproject.com/svn/django/branches/boulder-oracle-sprint@4085 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
677aa10cdf
commit
174463e62c
@ -74,6 +74,14 @@ class FormatStylePlaceholderCursor(Database.Cursor):
|
|||||||
def _rewrite_args(self, query, params=None):
|
def _rewrite_args(self, query, params=None):
|
||||||
if params is None:
|
if params is None:
|
||||||
params = []
|
params = []
|
||||||
|
else:
|
||||||
|
# cx_Oracle can't handle unicode parameters, so cast to str for now
|
||||||
|
for i, param in enumerate(params):
|
||||||
|
if type(param) == unicode:
|
||||||
|
try:
|
||||||
|
params[i] = param.encode('utf-8')
|
||||||
|
except UnicodeError:
|
||||||
|
params[i] = str(param)
|
||||||
args = [(':arg%d' % i) for i in range(len(params))]
|
args = [(':arg%d' % i) for i in range(len(params))]
|
||||||
query = query % tuple(args)
|
query = query % tuple(args)
|
||||||
# cx_Oracle cannot execute a query with the closing ';'
|
# cx_Oracle cannot execute a query with the closing ';'
|
||||||
|
@ -81,8 +81,6 @@ def destroy_test_db(settings, connection, backend, old_database_name, verbosity=
|
|||||||
settings.DATABASE_NAME = old_database_name
|
settings.DATABASE_NAME = old_database_name
|
||||||
#settings.DATABASE_USER = 'old_user'
|
#settings.DATABASE_USER = 'old_user'
|
||||||
#settings.DATABASE_PASSWORD = 'old_password'
|
#settings.DATABASE_PASSWORD = 'old_password'
|
||||||
settings.DATABASE_USER = 'mboersma'
|
|
||||||
settings.DATABASE_PASSWORD = 'password'
|
|
||||||
|
|
||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
time.sleep(1) # To avoid "database is being accessed by other users" errors.
|
time.sleep(1) # To avoid "database is being accessed by other users" errors.
|
||||||
|
@ -199,14 +199,15 @@ def get_query_set_class(DefaultQuerySet):
|
|||||||
limit_and_offset_clause = "WHERE rn > %s" % (offset)
|
limit_and_offset_clause = "WHERE rn > %s" % (offset)
|
||||||
|
|
||||||
if len(limit_and_offset_clause) > 0:
|
if len(limit_and_offset_clause) > 0:
|
||||||
full_query = """SELECT * FROM
|
fmt = \
|
||||||
(SELECT %s
|
"""SELECT * FROM
|
||||||
%s,
|
(SELECT %s%s,
|
||||||
ROW_NUMBER() %s AS rn
|
ROW_NUMBER()%s AS rn
|
||||||
%s
|
%s)
|
||||||
)
|
%s"""
|
||||||
%s
|
full_query = fmt % (distinct, select_clause,
|
||||||
""" % (distinct, select_clause, order_by_clause, " ".join(sql), limit_and_offset_clause)
|
order_by_clause, ' '.join(sql).strip(),
|
||||||
|
limit_and_offset_clause)
|
||||||
else:
|
else:
|
||||||
full_query = None
|
full_query = None
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user