Fixed #7464 -- Fixed the psycopg2 backend to handle SafeString values as

parameters. Based on a patch from Digitalxero@gmail.com.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@8532 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Malcolm Tredinnick 2008-08-25 04:13:27 +00:00
parent 62b39322f3
commit 29d2160213
2 changed files with 6 additions and 3 deletions

View File

@ -10,8 +10,8 @@ from django.db.backends.postgresql.client import DatabaseClient
from django.db.backends.postgresql.creation import DatabaseCreation
from django.db.backends.postgresql.version import get_version
from django.db.backends.postgresql_psycopg2.introspection import DatabaseIntrospection
from django.utils.safestring import SafeUnicode, SafeString
from django.utils.safestring import SafeUnicode
try:
import psycopg2 as Database
import psycopg2.extensions
@ -23,6 +23,7 @@ DatabaseError = Database.DatabaseError
IntegrityError = Database.IntegrityError
psycopg2.extensions.register_type(psycopg2.extensions.UNICODE)
psycopg2.extensions.register_adapter(SafeString, psycopg2.extensions.QuotedString)
psycopg2.extensions.register_adapter(SafeUnicode, psycopg2.extensions.QuotedString)
class DatabaseFeatures(BaseDatabaseFeatures):

View File

@ -49,8 +49,10 @@ u'Default headline'
>>> d.seconds < 5
True
# make sure that SafeUnicode fields work
>>> from django.utils.safestring import SafeUnicode
# make sure that SafeString/SafeUnicode fields work
>>> from django.utils.safestring import SafeUnicode, SafeString
>>> a.headline = SafeUnicode(u'SafeUnicode Headline')
>>> a.save()
>>> a.headline = SafeString(u'SafeString Headline')
>>> a.save()
"""}