Executing the following test code:

import sqlalchemy as sa
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.dialects import postgresql


Base = declarative_base()

class MyEnum(sa.types.TypeDecorator):
    impl = postgresql.ENUM

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:5432/sqlalchemy_test')
Base.metadata.create_all(engine)

Results in the exception (traceback omitted):

sqlalchemy.exc.ProgrammingError: (ProgrammingError) type "my_enum_type" 
does not exist
LINE 4:  enum_column my_enum_type,
                     ^
 '\nCREATE TABLE test (\n\tid SERIAL NOT NULL, \n\tenum_column 
my_enum_type, \n\tPRIMARY KEY (id)\n)\n\n' {}

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.

--Pedro.

-- 
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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to