[Sqlalchemy-tickets] Issue #4323: Reflection does not work on Postgres Enums that start with capita
Brought to you by:
zzzeek
From: Steven H. <iss...@bi...> - 2018-08-21 23:12:45
|
New issue 4323: Reflection does not work on Postgres Enums that start with capital letters https://bitbucket.org/zzzeek/sqlalchemy/issues/4323/reflection-does-not-work-on-postgres-enums Steven Heidel: With the following Postgres schema: ``` #!sql CREATE TYPE "Status" AS ENUM ('ok', 'err'); CREATE TABLE statuses (status "Status"); ``` Run the following code: ``` #!python from sqlalchemy import create_engine, MetaData engine = create_engine('postgres://...') metadata = MetaData() metadata.reflect(engine) ``` This gives the error: ``` sqlalchemy/lib/python3.6/site-packages/sqlalchemy/dialects/postgresql/base.py:2679: SAWarning: Did not recognize type '"Status"' of column 'status' (attype, name)) ``` The problem is that in postgresql/base.py the list of enums is created with the lowercase-d version of the enums, meaning it won't be able to find the column type when it looks it up in the dictionary. This means that reflection does not work properly, and for instance when using Alembic it won't be able to autogenerate these migrations. Postgres Version: 10.4 SQLAlchemy Version: 1.2.11 psycopg2 Version: 2.7.5 |