)
row = cursor.fetchone()
- result = isinstance(row[0], unicode)
+ unicode_for_varchar = isinstance(row[0], unicode)
+
+ cursor.execute(
+ str(
+ expression.select(
+ [expression.cast(
+ expression.literal_column("'test unicode returns'"),sqltypes.VARCHAR(60))
+ ]).compile(dialect=self)
+ )
+ )
+
+ row = cursor.fetchone()
+ unicode_for_unicode = isinstance(row[0], unicode)
cursor.close()
- return result
+
+ if unicode_for_unicode and not unicode_for_varchar:
+ return "conditional"
+ else:
+ return unicode_for_varchar
def type_descriptor(self, typeobj):
"""Provide a database-specific ``TypeEngine`` object, given
def result_processor(self, dialect, coltype):
wants_unicode = self.convert_unicode or dialect.convert_unicode
needs_convert = wants_unicode and \
- (not dialect.returns_unicode_strings or
+ (dialect.returns_unicode_strings is not True or
self.convert_unicode == 'force')
if needs_convert:
if dialect.returns_unicode_strings:
# we wouldn't be here unless convert_unicode='force'
- # was specified. since we will be getting back unicode
+ # was specified, or the driver has erratic unicode-returning
+ # habits. since we will be getting back unicode
# in most cases, we check for it (decode will fail).
def process(value):
if isinstance(value, unicode):