Add custom String type to support collation

Since sqlalchemy 0.7.9 does not support collation in init of default String type,
custom type was added.

Change-Id: I4fa841bf61d923fb80d1e52f881bcce6622923cb
Closes-Bug: #1313535
This commit is contained in:
Ekaterina Fedorova 2014-04-29 16:33:14 +04:00
parent aa6aa6f511
commit b3019ae8ee
1 changed files with 7 additions and 1 deletions

View File

@ -20,6 +20,12 @@ from sqlalchemy import types
meta = schema.MetaData()
class StringWithCollation(types.String):
def __init__(self, length, collation=None, **kwargs):
super(StringWithCollation, self).__init__(length, **kwargs)
self.collation = collation
def upgrade(migrate_engine):
meta.bind = migrate_engine
collation = 'ascii_general_ci' \
@ -34,7 +40,7 @@ def upgrade(migrate_engine):
nullable=False),
schema.Column('archive', types.LargeBinary),
schema.Column('fully_qualified_name',
types.String(512, collation=collation),
StringWithCollation(512, collation=collation),
index=True, unique=True),
schema.Column('type', types.String(20)),
schema.Column('author', types.String(80)),