From dee57477882f8876fd97071a790fe3d3ee2164c5 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 30 Jun 2021 09:22:00 -0400 Subject: apply quoting to "ON CONSTRAINT" symbol Fixed issue in :meth:`_postgresql.Insert.on_conflict_do_nothing` and :meth:`_postgresql.Insert.on_conflict_do_update` where the name of a unique constraint passed as the ``constraint`` parameter would not be properly quoted if it contained characters which required quoting. Fixes: #6696 Change-Id: I4ffca9b8c72cef4ed39e2de96831ccc11a620422 --- lib/sqlalchemy/dialects/postgresql/base.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/sqlalchemy/dialects/postgresql/base.py') diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py index 4c7898132..4c654a643 100644 --- a/lib/sqlalchemy/dialects/postgresql/base.py +++ b/lib/sqlalchemy/dialects/postgresql/base.py @@ -2322,7 +2322,9 @@ class PGCompiler(compiler.SQLCompiler): def _on_conflict_target(self, clause, **kw): if clause.constraint_target is not None: - target_text = "ON CONSTRAINT %s" % clause.constraint_target + target_text = "ON CONSTRAINT %s" % self.preparer.quote( + clause.constraint_target + ) elif clause.inferred_target_elements is not None: target_text = "(%s)" % ", ".join( ( -- cgit v1.2.1