Ticket #3454: patch

File patch, 1.1 KB (added by (removed), 18 years ago)

use text_factory instead of row_factory for unicode conversion

  • django/db/backends/sqlite3/base.py

    === modified file 'django/db/backends/sqlite3/base.py'
     
    2626Database.register_converter("timestamp", util.typecast_timestamp)
    2727Database.register_converter("TIMESTAMP", util.typecast_timestamp)
    2828
    29 def utf8rowFactory(cursor, row):
    30     def utf8(s):
    31         if type(s) == unicode:
    32             return s.encode("utf-8")
    33         else:
    34             return s
    35     return [utf8(r) for r in row]
     29def utf8_cast(s):
     30    return s.decode("utf-8")
    3631
    3732try:
    3833    # Only exists in Python 2.4+
     
    5954            # Register extract and date_trunc functions.
    6055            self.connection.create_function("django_extract", 2, _sqlite_extract)
    6156            self.connection.create_function("django_date_trunc", 2, _sqlite_date_trunc)
     57        self.connection.text_factory = utf8_cast
    6258        cursor = self.connection.cursor(factory=SQLiteCursorWrapper)
    63         cursor.row_factory = utf8rowFactory
    6459        if settings.DEBUG:
    6560            return util.CursorDebugWrapper(cursor, self)
    6661        else:
Back to Top