~james-w/ubuntu/lucid/python-django/fix-contrib-auth

« back to all changes in this revision

Viewing changes to django/db/backends/oracle/base.py

  • Committer: Bazaar Package Importer
  • Author(s): Krzysztof Klimonda
  • Date: 2009-10-12 19:22:16 UTC
  • mfrom: (1.1.9 upstream) (4.4.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091012192216-l4wb7fp72wow19zp
Tags: 1.1.1-1ubuntu1
* Merge python-django 1.1.1-1 from debian unstable (LP: #447617)
  for security and bug fixes, all Ubuntu changes merged by Debian.
* Add to debian/patches:
  - 20_python2.6.3_regression.patch - backported upstream commit 11620
    to make Django work with Python 2.6.3 properly. (LP: #445639)

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
IntegrityError = Database.IntegrityError
37
37
 
38
38
 
 
39
# Check whether cx_Oracle was compiled with the WITH_UNICODE option.  This will
 
40
# also be True in Python 3.0.
 
41
if int(Database.version.split('.', 1)[0]) >= 5 and not hasattr(Database, 'UNICODE'):
 
42
    convert_unicode = force_unicode
 
43
else:
 
44
    convert_unicode = smart_str
 
45
 
 
46
 
39
47
class DatabaseFeatures(BaseDatabaseFeatures):
40
48
    empty_fetchmany_value = ()
41
49
    needs_datetime_string_cast = False
170
178
        return "RETURNING %s INTO %%s", (InsertIdVar(),)
171
179
 
172
180
    def savepoint_create_sql(self, sid):
173
 
        return "SAVEPOINT " + self.quote_name(sid)
 
181
        return convert_unicode("SAVEPOINT " + self.quote_name(sid))
174
182
 
175
183
    def savepoint_rollback_sql(self, sid):
176
 
        return "ROLLBACK TO SAVEPOINT " + self.quote_name(sid)
 
184
        return convert_unicode("ROLLBACK TO SAVEPOINT " + self.quote_name(sid))
177
185
 
178
186
    def sql_flush(self, style, tables, sequences):
179
187
        # Return a list of 'TRUNCATE x;', 'TRUNCATE y;',
304
312
    def _cursor(self):
305
313
        cursor = None
306
314
        if not self._valid_connection():
307
 
            conn_string = self._connect_string()
 
315
            conn_string = convert_unicode(self._connect_string())
308
316
            self.connection = Database.connect(conn_string, **self.settings_dict['DATABASE_OPTIONS'])
309
317
            cursor = FormatStylePlaceholderCursor(self.connection)
310
318
            # Set oracle date to ansi date format.  This only needs to execute
355
363
        if hasattr(param, 'bind_parameter'):
356
364
            self.smart_str = param.bind_parameter(cursor)
357
365
        else:
358
 
            self.smart_str = smart_str(param, cursor.charset, strings_only)
 
366
            self.smart_str = convert_unicode(param, cursor.charset,
 
367
                                             strings_only)
359
368
        if hasattr(param, 'input_size'):
360
369
            # If parameter has `input_size` attribute, use that.
361
370
            self.input_size = param.input_size
423
432
        # is being passed to SQL*Plus.
424
433
        if query.endswith(';') or query.endswith('/'):
425
434
            query = query[:-1]
426
 
        query = smart_str(query, self.charset) % tuple(args)
 
435
        query = convert_unicode(query % tuple(args), self.charset)
427
436
        self._guess_input_sizes([params])
428
437
        try:
429
438
            return self.cursor.execute(query, self._param_generator(params))
445
454
        # is being passed to SQL*Plus.
446
455
        if query.endswith(';') or query.endswith('/'):
447
456
            query = query[:-1]
448
 
        query = smart_str(query, self.charset) % tuple(args)
 
457
        query = convert_unicode(query % tuple(args), self.charset)
449
458
        formatted = [self._format_params(i) for i in params]
450
459
        self._guess_input_sizes(formatted)
451
460
        try: