]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commit
Handle literal_column() in ExcludeConstraint differently
authorJan Katins <jasc@gmx.net>
Tue, 21 Feb 2023 21:15:03 +0000 (22:15 +0100)
committerJan Katins <jasc@gmx.net>
Fri, 3 Mar 2023 11:27:28 +0000 (12:27 +0100)
commitb31bdb78fc4705dfd057d51745ce10ed311c0aa9
treed3c01da0231cae5bc8df9aa0c452a21ed1e61ca7
parentbc4725e96bd52dee95a2b0c16876287d0a08b47d
Handle literal_column() in ExcludeConstraint differently

Before the change, a literal_column in an ExcludeConstraint ended up as a `column("...")`which in turn meant that the actual migration errored with

```
sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedColumn) column "id + 2" named in key does not exist

[SQL:
CREATE TABLE whatever2 (
        id BIGSERIAL NOT NULL,
        PRIMARY KEY (id),
        CONSTRAINT whatever_id_int8range_excl EXCLUDE USING gist (id WITH =, "id + 2" WITH =)
)
```

Note: the column name is interpreted as a quoted column named "id + 2".

After the fix, a literal_column is passed through, ending up in the correct SQL, which can be run on PG.
alembic/ddl/postgresql.py
tests/test_postgresql.py