Skip to content

Instantly share code, notes, and snippets.

@irskep
Last active January 2, 2016 17:39
Show Gist options
  • Save irskep/8338687 to your computer and use it in GitHub Desktop.
Save irskep/8338687 to your computer and use it in GitHub Desktop.
class MyTable(...):
__tablename__ = 'my_table'
id = ...
unicode_col = Column(UnicodeText())
# (insert some rows into my_table)
assert type(session.query(MyTable).first()) == unicode # NOPE!
### workaround ###
class CoercedUTF8UnicodeText(types.TypeDecorator):
impl = UnicodeText
def process_result_value(self, value, dialect):
if isinstance(value, str):
return value.decode('UTF-8')
return value
@irskep
Copy link
Author

irskep commented Jan 9, 2014

(it's a str)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment