Browse files

Fixed #20007 -- Configured psycopg2 to return UnicodeArrays

Thanks hogbait for the report.
  • Loading branch information...
1 parent 926bc42 commit ded40142a92813a8901faa4a6ca398e6679152f6 @EricBoersma EricBoersma committed with timgraham Sep 6, 2013
Showing with 22 additions and 0 deletions.
  1. +1 −0 AUTHORS
  2. +1 −0 django/db/backends/postgresql_psycopg2/base.py
  3. +20 −0 tests/backends/tests.py
View
1 AUTHORS
@@ -120,6 +120,7 @@ answer newbie questions, and generally made Django that much better:
Craig Blaszczyk <masterjakul@gmail.com>
David Blewett <david@dawninglight.net>
Artem Gnilov <boobsd@gmail.com>
+ Eric Boersma <eric.boersma@gmail.com>
Mat??as Bordese
Nate Bragg <jonathan.bragg@alum.rpi.edu>
Sean Brant
View
1 django/db/backends/postgresql_psycopg2/base.py
@@ -31,6 +31,7 @@
IntegrityError = Database.IntegrityError
psycopg2.extensions.register_type(psycopg2.extensions.UNICODE)
+psycopg2.extensions.register_type(psycopg2.extensions.UNICODEARRAY)
psycopg2.extensions.register_adapter(SafeBytes, psycopg2.extensions.QuotedString)
psycopg2.extensions.register_adapter(SafeText, psycopg2.extensions.QuotedString)
View
20 tests/backends/tests.py
@@ -963,3 +963,23 @@ def equal(value, max_d, places, result):
'0.1')
equal('0.1234567890', 12, 0,
'0')
+
+@unittest.skipUnless(
+ connection.vendor == 'postgresql',
+ "This test applies only to PostgreSQL")
+class UnicodeArrayTestCase(TestCase):
+
+ def select(self, val):
+ cursor = connection.cursor()
+ cursor.execute("select %s", (val,))
+ return cursor.fetchone()[0]
+
+ def test_select_ascii_array(self):
+ a = ["awef"]
+ b = self.select(a)
+ self.assertEqual(a[0], b[0])
+
+ def test_select_unicode_array(self):
+ a = [u"ᄲawef"]
+ b = self.select(a)
+ self.assertEqual(a[0], b[0])

0 comments on commit ded4014

Please sign in to comment.