Hello, Help me create table with enum type column, SA do not create enum type before table :( And server_default doesn't set value that I expect, "actions import_action[] DEFAULT ARRAY['copy'] NOT NULL" it set array['copy'], not import_action['copy'] as default...
Code and exception: from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker from sqlalchemy.ext.declarative import declarative_base from sqlalchemy import Column from sqlalchemy import Integer, UnicodeText from sqlalchemy.dialects.postgresql import ARRAY, array, ENUM engine = create_engine('postgresql+psycopg2://user:password@127.0.0.1:5432/epsilon', echo=True) Base = declarative_base() DBSession = sessionmaker(bind=engine)() Base.metadata.bind = engine import_action = ENUM('copy', 'insert', 'update', name='import_action', metadata=Base.metadata) class Import(Base): __tablename__ = 'import' id = Column(Integer, primary_key=True) name = Column(UnicodeText, nullable=False) actions = Column(ARRAY(import_action), server_default=array(['copy'], type_=import_action), nullable=False) Import.__table__.create(checkfirst=True) sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) type "import_action[]" does not exist LINE 5: actions import_action[] DEFAULT ARRAY['copy'] NOT NULL, ^ [SQL: "\nCREATE TABLE import (\n\tid SERIAL NOT NULL, \n\tname TEXT NOT NULL, \n\tactions import_action[] DEFAULT ARRAY['copy'] NOT NULL, \n\tPRIMARY KEY (id)\n)\n\n"] -- 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/d/optout.