Ticket #10566: 10566.diff

File 10566.diff, 2.9 KB (added by Erin Kelly, 16 years ago)
  • django/db/backends/oracle/base.py

     
    3131IntegrityError = Database.IntegrityError
    3232
    3333
     34# Check whether cx_Oracle was compiled with the WITH_UNICODE option.  This will
     35# also be True in Python 3.0.
     36if int(Database.version.split('.', 1)[0]) >= 5 and not hasattr(Database, 'UNICODE'):
     37    convert_unicode = force_unicode
     38else:
     39    convert_unicode = smart_str
     40
     41
    3442class DatabaseFeatures(BaseDatabaseFeatures):
    3543    empty_fetchmany_value = ()
    3644    needs_datetime_string_cast = False
     
    165173        return "RETURNING %s INTO %%s", (InsertIdVar(),)
    166174
    167175    def savepoint_create_sql(self, sid):
    168         return "SAVEPOINT " + self.quote_name(sid)
     176        return convert_unicode("SAVEPOINT " + self.quote_name(sid))
    169177
    170178    def savepoint_rollback_sql(self, sid):
    171         return "ROLLBACK TO SAVEPOINT " + self.quote_name(sid)
     179        return convert_unicode("ROLLBACK TO SAVEPOINT " + self.quote_name(sid))
    172180
    173181    def sql_flush(self, style, tables, sequences):
    174182        # Return a list of 'TRUNCATE x;', 'TRUNCATE y;',
     
    298306    def _cursor(self):
    299307        cursor = None
    300308        if not self._valid_connection():
    301             conn_string = self._connect_string()
     309            conn_string = convert_unicode(self._connect_string())
    302310            self.connection = Database.connect(conn_string, **self.settings_dict['DATABASE_OPTIONS'])
    303311            cursor = FormatStylePlaceholderCursor(self.connection)
    304312            # Set oracle date to ansi date format.  This only needs to execute
     
    348356        if hasattr(param, 'bind_parameter'):
    349357            self.smart_str = param.bind_parameter(cursor)
    350358        else:
    351             self.smart_str = smart_str(param, cursor.charset, strings_only)
     359            self.smart_str = convert_unicode(param, cursor.charset,
     360                                             strings_only)
    352361        if hasattr(param, 'input_size'):
    353362            # If parameter has `input_size` attribute, use that.
    354363            self.input_size = param.input_size
     
    416425        # is being passed to SQL*Plus.
    417426        if query.endswith(';') or query.endswith('/'):
    418427            query = query[:-1]
    419         query = smart_str(query, self.charset) % tuple(args)
     428        query = convert_unicode(query % tuple(args), self.charset)
    420429        self._guess_input_sizes([params])
    421430        try:
    422431            return self.cursor.execute(query, self._param_generator(params))
     
    438447        # is being passed to SQL*Plus.
    439448        if query.endswith(';') or query.endswith('/'):
    440449            query = query[:-1]
    441         query = smart_str(query, self.charset) % tuple(args)
     450        query = convert_unicode(query % tuple(args), self.charset)
    442451        formatted = [self._format_params(i) for i in params]
    443452        self._guess_input_sizes(formatted)
    444453        try:
Back to Top