psycopg2da not properly casting arrays
Brian Sutherland <[email protected]>
| Newsgroups | gmane.comp.python.db.psycopg.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I've been having some problems with psycopg2da not properly casting
arrays of TEXT to python objects. Basically they are cast to lists of
strings rather than lists of unicode.
It smells like a bug because zope3's philosophy is to use unicode
internally and a plain TEXT column is indeed cast to unicode.
Based on this mail:
http://lists.initd.org/pipermail/psycopg/2006-December/005204.html
I came up with this patch, which works for me:
diff -u psycopg2-2.0.5.1/psycopg2da/adapter.py psycopg2-2.0.5.1/psycopg2da/adapter.py
--- psycopg2-2.0.5.1/psycopg2da/adapter.py
+++ psycopg2-2.0.5.1/psycopg2da/adapter.py
@@ -309,6 +309,7 @@
psycopg2.extensions.register_type(INTERVAL)
STRING = psycopg2.extensions.new_type((CHAR_OID, TEXT_OID, BPCHAR_OID, VARCHAR_OID), "ZSTRING", _get_string_conv(encoding))
psycopg2.extensions.register_type(STRING)
+ psycopg2.extensions.register_type(psycopg2._psycopg.UNICODEARRAY)
dsn2option_mapping = {'host': 'host',
--
Brian Sutherland