Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sqlalchemy.exc.CompileError: Postgresql ENUM type requires a name. #3

item4 opened this issue Mar 4, 2016 · 0 comments


Copy link

item4 commented Mar 4, 2016

제 영어가 매우 불량함을 감안하여 한글과 함께 병기합니다.
(I think my poor english is not good for reader, so I write Korean together.)

Code sample

class Purpose(enum.Enum):

    normal = 'normal'
    index_only = 'index_only'
    representative_only = 'representative_only'

class Image(Base):

    # blabla

    purpose = Column(EnumType(Purpose), nullable=False)

MySQL, SQLite, PgSQL 3가지 DBMS에서 실험해본 결과 PgSQL만 EnumType에 name 인자를 필요로 합니다. (by_name 말고)
(I tested on MySQL, SQLite, PgSQL and only PgSQL must require name parameter, not by_name)

저처럼 삽뜨는 사람이 없도록 다음 중 한 가지 방법을 취하는 건 어떨까 합니다.
(I suggest get some action for people.)

1. auto-filling

if name is None:
    name = enum_class.__name__

2. write in docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

No branches or pull requests

1 participant