Last active
January 2, 2016 17:39
-
-
Save irskep/8338687 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
(it's a
str)