Permalink
Browse files

- for strings, don't run any adapters. psycopg2's adapter seems to as…

…sume ASCII and we appear to

be getting back a complete unicode string back for JSON already.
- add a unicode round trip test.   even handles unicode hardcoded right in the SQL.
  • Loading branch information...
1 parent 943dd3f commit 4f303b475a9ab9b5ee8e9a4c138c0461217e23fc @zzzeek committed Oct 15, 2012
Showing with 15 additions and 0 deletions.
  1. +7 −0 akiban/psycopg2.py
  2. +8 −0 tests/test_psycopg2.py
View
@@ -114,6 +114,13 @@ def typecast(self, value, oid):
else:
adapter = _psycopg2_adapter_cache[oid] = None
+ # hardwire STRING types to not use adapters, since we're
+ # getting string data back already. Akiban seems to be
+ # sending fully unicode data back even without using psycopg2
+ # unicode extensions.
+ if adapter is not None and adapter == psycopg2.STRING:
+ _psycopg2_adapter_cache[oid] = adapter = None
+
if adapter:
# TODO: do we send the oid or the adapter
# as the argument here?
View
@@ -1,3 +1,4 @@
+# coding:utf-8
import unittest
from nose import SkipTest
from . import fixtures, fails
@@ -216,6 +217,13 @@ def test_typecast_boolean_outer(self):
"customer_id=5")
self.assertEquals(cursor.fetchone()[0], True)
+ def test_typecast_unicode(self):
+ cursor = self.connection.cursor()
+
+ # wow
+ cursor.execute(u"select 'drôle m’a réveillé'")
+ self.assertEquals(cursor.fetchone()[0], u'drôle m’a réveillé')
+
def test_fetchone_plain(self):
cursor = self.connection.cursor()
cursor.execute(

0 comments on commit 4f303b4

Please sign in to comment.