alembic rendering of types is documented at: http://alembic.readthedocs.org/en/latest/autogenerate.html#rendering-types
user-defined types need to define a __repr__() that is suitable for code generation. alchemy1 <[email protected]> wrote: > I'm trying to make a custom Enum type, but can't seem to do so. This sample > code shows what I'm trying to do: > > class Choice(sqlalchemy.types.TypeDecorator): > > impl = sqlalchemy.dialects.postgresql.ENUM > > def __init__(self): > # super(Choice, self).__init__('a', 'b', 'c', name='d') > self.impl = sqlalchemy.dialects.postgresql.ENUM('e', 'f', 'g', > name='h') > > > But this is what gets generated in alembic. Instead of using ENUM type it > uses my own Choice class, so of course it doesn't work. And it doesn't > include the 'name' parameter I passed above. > > def upgrade(): > op.add_column('table', sa.Column('column', my.custom.Choice('d', 'e', > 'f'), nullable=True)) > > What's the right way to make a custom Enum type? In my sample code I also > tried caling the super constructor for TypeDecorator as explained in > http://docs.sqlalchemy.org/en/latest/core/custom_types.html#sqlalchemy.types.TypeDecorator.__init__ > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/sqlalchemy. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
