Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

boulder-oracle-sprint: Fixed unicode bind param handling. Only 3 test…

…s fail

now...


git-svn-id: http://code.djangoproject.com/svn/django/branches/boulder-oracle-sprint@4085 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 174463e62c732b33842e454f9763c5b066fc5af4 1 parent 677aa10
Boulder Sprinters authored
View
8 django/db/backends/oracle/base.py
@@ -74,6 +74,14 @@ class FormatStylePlaceholderCursor(Database.Cursor):
def _rewrite_args(self, query, params=None):
if params is None:
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))]
query = query % tuple(args)
# cx_Oracle cannot execute a query with the closing ';'
View
2  django/db/backends/oracle/creation.py
@@ -81,8 +81,6 @@ def destroy_test_db(settings, connection, backend, old_database_name, verbosity=
settings.DATABASE_NAME = old_database_name
#settings.DATABASE_USER = 'old_user'
#settings.DATABASE_PASSWORD = 'old_password'
- settings.DATABASE_USER = 'mboersma'
- settings.DATABASE_PASSWORD = 'password'
cursor = connection.cursor()
time.sleep(1) # To avoid "database is being accessed by other users" errors.
View
17 django/db/backends/oracle/query.py
@@ -199,14 +199,15 @@ def _get_sql_clause(self):
limit_and_offset_clause = "WHERE rn > %s" % (offset)
if len(limit_and_offset_clause) > 0:
- full_query = """SELECT * FROM
- (SELECT %s
- %s,
- ROW_NUMBER() %s AS rn
- %s
- )
- %s
- """ % (distinct, select_clause, order_by_clause, " ".join(sql), limit_and_offset_clause)
+ fmt = \
+"""SELECT * FROM
+ (SELECT %s%s,
+ ROW_NUMBER()%s AS rn
+ %s)
+%s"""
+ full_query = fmt % (distinct, select_clause,
+ order_by_clause, ' '.join(sql).strip(),
+ limit_and_offset_clause)
else:
full_query = None
Please sign in to comment.
Something went wrong with that request. Please try again.