Our production database uses MySQL. For various reasons, the schema
often uses MySQL-specific DDL. We want that represented in our
mapper classes. We also awant to be able to exercise our SQLAlchemy
unit tests against both local MySQL databases and SQLite databases.

Using the MySQL-specific types wasn't a problem with SA 0.5.x, but
it is with 0.6. I've started working around it like this:

    class MSBigInteger(sqltypes.TypeDecorator):
        impl = sqltypes.Integer

        def load_dialect_impl(self, dialect):
            return dialect.type_descriptor(
                mysql.base.MSBigInteger if dialect.name == 'mysql'
else sqltypes.INTEGER)

This approach falls apart when the type's __init__ takes custom
parameters, such as collation or charset for the strings.

    class MSLongText(sqltypes.TypeDecorator):
        impl = sqltypes.String

        def load_dialect_impl(self, dialect):
            self.dialect = dialect
            return dialect.type_descriptor(
                mysql.base.MSLongText if dialect.name == 'mysql' else
sqltypes.TEXT)

        def __init__(self, **kwargs):
            # FIXME: figure out what the dialect is in __init__
(somehow) so can call
            # correct dialect_impl
            if 'collation' in kwargs: del kwargs['collation']
            if 'charset' in kwargs: del kwargs['charset']
            super(MSLongText, self).__init__(**kwargs)

What's a good way to fix this? I'm not wedded to the TypeDecorator
for MSBigInteger either, if there's a better approach.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to