Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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
  • Loading branch information...
commit 29d216021375446223a36901ab0ec60b6e3eadf9 1 parent 62b3932
@malcolmt malcolmt authored
View
3  django/db/backends/postgresql_psycopg2/base.py
@@ -10,8 +10,8 @@
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 @@
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
6 tests/modeltests/field_defaults/models.py
@@ -49,8 +49,10 @@ def __unicode__(self):
>>> 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()
"""}

0 comments on commit 29d2160

Please sign in to comment.
Something went wrong with that request. Please try again.