Ticket #10566: 10566-2.diff
File 10566-2.diff, 4.3 KB (added by , 16 years ago) |
---|
-
django/db/backends/oracle/base.py
35 35 IntegrityError = Database.IntegrityError 36 36 37 37 38 # Check whether cx_Oracle was compiled with the WITH_UNICODE option. This will 39 # also be True in Python 3.0. 40 if int(Database.version.split('.', 1)[0]) >= 5 and not hasattr(Database, 'UNICODE'): 41 convert_unicode = force_unicode 42 else: 43 convert_unicode = smart_str 44 45 38 46 class DatabaseFeatures(BaseDatabaseFeatures): 39 47 empty_fetchmany_value = () 40 48 needs_datetime_string_cast = False … … 169 177 return "RETURNING %s INTO %%s", (InsertIdVar(),) 170 178 171 179 def savepoint_create_sql(self, sid): 172 return "SAVEPOINT " + self.quote_name(sid)180 return convert_unicode("SAVEPOINT " + self.quote_name(sid)) 173 181 174 182 def savepoint_rollback_sql(self, sid): 175 return "ROLLBACK TO SAVEPOINT " + self.quote_name(sid)183 return convert_unicode("ROLLBACK TO SAVEPOINT " + self.quote_name(sid)) 176 184 177 185 def sql_flush(self, style, tables, sequences): 178 186 # Return a list of 'TRUNCATE x;', 'TRUNCATE y;', … … 302 310 def _cursor(self): 303 311 cursor = None 304 312 if not self._valid_connection(): 305 conn_string = self._connect_string()313 conn_string = convert_unicode(self._connect_string()) 306 314 self.connection = Database.connect(conn_string, **self.settings_dict['DATABASE_OPTIONS']) 307 315 cursor = FormatStylePlaceholderCursor(self.connection) 308 316 # Set oracle date to ansi date format. This only needs to execute … … 352 360 if hasattr(param, 'bind_parameter'): 353 361 self.smart_str = param.bind_parameter(cursor) 354 362 else: 355 self.smart_str = smart_str(param, cursor.charset, strings_only) 363 self.smart_str = convert_unicode(param, cursor.charset, 364 strings_only) 356 365 if hasattr(param, 'input_size'): 357 366 # If parameter has `input_size` attribute, use that. 358 367 self.input_size = param.input_size 359 368 elif isinstance(param, basestring) and len(param) > 4000: 360 # Mark any string param greater than 4000 characters as a n NCLOB.361 self.input_size = Database. NCLOB369 # Mark any string param greater than 4000 characters as a CLOB. 370 self.input_size = Database.CLOB 362 371 else: 363 372 self.input_size = None 364 373 … … 420 429 # is being passed to SQL*Plus. 421 430 if query.endswith(';') or query.endswith('/'): 422 431 query = query[:-1] 423 query = smart_str(query, self.charset) % tuple(args)432 query = convert_unicode(query % tuple(args), self.charset) 424 433 self._guess_input_sizes([params]) 425 434 try: 426 435 return self.cursor.execute(query, self._param_generator(params)) … … 442 451 # is being passed to SQL*Plus. 443 452 if query.endswith(';') or query.endswith('/'): 444 453 query = query[:-1] 445 query = smart_str(query, self.charset) % tuple(args)454 query = convert_unicode(query % tuple(args), self.charset) 446 455 formatted = [self._format_params(i) for i in params] 447 456 self._guess_input_sizes(formatted) 448 457 try: -
tests/regressiontests/backends/tests.py
4 4 5 5 import unittest 6 6 7 from django.db import connection7 from django.db import backend, connection 8 8 from django.conf import settings 9 9 10 10 … … 14 14 # If the backend is Oracle, test that we can call a standard 15 15 # stored procedure through our cursor wrapper. 16 16 if settings.DATABASE_ENGINE == 'oracle': 17 convert_unicode = backend.convert_unicode 17 18 cursor = connection.cursor() 18 cursor.callproc( 'DBMS_SESSION.SET_IDENTIFIER',19 [ '_django_testing!',])19 cursor.callproc(convert_unicode('DBMS_SESSION.SET_IDENTIFIER'), 20 [convert_unicode('_django_testing!'),]) 20 21 return True 21 22 else: 22 23 return True