On Jan 24, 2014, at 5:24 AM, Pedro Romano <[email protected]> wrote:
>
> Which means the PostgreSQL enumerate type isn't being created as it would
> have been if the postgresql.ENUM had been used directly in the column
> definition instead of the decorated MyEnum.
>
> Is this behaviour by design or should the decorated column type be expected
> to also create the corresponding PostgreSQL enumerate type?
>
> Thanks in advance for any feedback regarding this.
please use this approach in the case of a type like ENUM which requires special
schema-level steps:
class MyEnum(sa.types.TypeDecorator, sa.types.SchemaType):
impl = postgresql.ENUM
def _set_parent(self, column):
self.impl._set_parent(column)
class Test(Base):
__tablename__ = 'test'
id = sa.Column(sa.Integer, primary_key=True)
enum_column = sa.Column(MyEnum('1', '2', '3', name='my_enum_type'))
engine = sa.create_engine('postgresql://scott:tiger@localhost/test', echo=True)
Base.metadata.create_all(engine)
signature.asc
Description: Message signed with OpenPGP using GPGMail
