Ticket #5996: pg_safeunicode.diff

File pg_safeunicode.diff, 1.3 KB (added by remco@…, 17 years ago)

Unit test + fix

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

     
    66
    77from django.db.backends import BaseDatabaseWrapper, BaseDatabaseFeatures
    88from django.db.backends.postgresql.operations import DatabaseOperations as PostgresqlDatabaseOperations
     9from django.utils.safestring import SafeUnicode
    910try:
    1011    import psycopg2 as Database
    1112    import psycopg2.extensions
     
    1718IntegrityError = Database.IntegrityError
    1819
    1920psycopg2.extensions.register_type(psycopg2.extensions.UNICODE)
     21psycopg2.extensions.register_adapter(SafeUnicode, psycopg2.extensions.QuotedString)
    2022
    2123class DatabaseFeatures(BaseDatabaseFeatures):
    2224    needs_datetime_string_cast = False
  • tests/modeltests/field_defaults/models.py

     
    4848>>> d = now - a.pub_date
    4949>>> d.seconds < 5
    5050True
     51
     52# make sure that SafeUnicode fields work
     53>>> from django.utils.safestring import SafeUnicode
     54>>> a.headline = SafeUnicode(u'SafeUnicode Headline')
     55>>> a.save()
    5156"""}
Back to Top