From 5cc18bb80077e98418b4a8066c0bc628209f3ada Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Thu, 22 Dec 2022 18:14:31 -0500 Subject: expand out Index if passed to "constraint" Fixed bug where the PostgreSQL :paramref:`_postgresql.OnConflictClause.constraint` parameter would accept an :class:`.Index` object, however would not expand this index out into its individual index expressions, instead rendering its name in an ON CONFLICT ON CONSTRAINT clause, which is not accepted by PostgreSQL; the "constraint name" form only accepts unique or exclude constraint names. The parameter continues to accept the index but now expands it out into its component expressions for the render. Fixes: #9023 Change-Id: I6baf243e26bfe578bf3f193c162dd7a623b6ede9 --- lib/sqlalchemy/dialects/postgresql/dml.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/sqlalchemy/dialects/postgresql/dml.py') diff --git a/lib/sqlalchemy/dialects/postgresql/dml.py b/lib/sqlalchemy/dialects/postgresql/dml.py index 645bedf17..27075191d 100644 --- a/lib/sqlalchemy/dialects/postgresql/dml.py +++ b/lib/sqlalchemy/dialects/postgresql/dml.py @@ -213,7 +213,7 @@ class OnConflictClause(ClauseElement): if constraint is not None: if not isinstance(constraint, str) and isinstance( constraint, - (schema.Index, schema.Constraint, ext.ExcludeConstraint), + (schema.Constraint, ext.ExcludeConstraint), ): constraint = getattr(constraint, "name") or constraint -- cgit v1.2.1