Ticket #7921: sqlite3-str.diff

File sqlite3-str.diff, 902 bytes (added by Martin v. Löwis, 16 years ago)

Patch to convert str objects into Unicoe before passing them to SQLite

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

     
    3737Database.register_converter("TIMESTAMP", util.typecast_timestamp)
    3838Database.register_converter("decimal", util.typecast_decimal)
    3939Database.register_adapter(decimal.Decimal, util.rev_typecast_decimal)
     40if Database.version_info >= (2,4,1):
     41    # Starting in 2.4.1, the str type is not accepted anymore, therefore,
     42    # we convert all str objects to Unicode
     43    # As registering a adapter for a primitive type causes a small
     44    # slow-down, this adapter is only registered for sqlite3 versions
     45    # needing it.
     46    Database.register_adapter(str, lambda s:s.decode('utf-8'))
    4047
    4148class DatabaseFeatures(BaseDatabaseFeatures):
    4249    supports_constraints = False
Back to Top