UTF-8 v1_json_metadata, comment, manifest

This will allow us to store unicode JSON blobs in the column on MySQL.
This commit is contained in:
Jimmy Zelinskie 2015-10-30 15:40:24 -04:00
parent c7fba332e6
commit c78c450211
3 changed files with 21 additions and 19 deletions

View file

@ -0,0 +1,16 @@
from sqlalchemy.types import TypeDecorator, Text
from sqlalchemy.dialects.mysql import TEXT as MySQLText, LONGTEXT
class UTF8LongText(TypeDecorator):
""" Platform-independent UTF-8 LONGTEXT type.
Uses MySQL's LongText with charset utf8mb4, otherwise uses TEXT, because
other engines default to UTF-8 and have longer TEXT fields.
"""
impl = Text
def load_dialect_impl(self, dialect):
if dialect.name == 'mysql':
return dialect.type_descriptor(LONGTEXT(charset='utf8mb4', collation='utf8mb4_unicode_ci'))
else:
return dialect.type_descriptor(Text())