summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects/postgresql/base.py
diff options
context:
space:
mode:
authormike bayer <mike_mp@zzzcomputing.com>2021-07-13 15:09:05 +0000
committerGerrit Code Review <gerrit@ci3.zzzcomputing.com>2021-07-13 15:09:05 +0000
commitb64ecb03a5411dd5f32e40ac564bec9a886d3672 (patch)
tree046508ac3bcdc0b6f4f48f7b23972f632a35294d /lib/sqlalchemy/dialects/postgresql/base.py
parent673ca806b323f47ef7064dd64ffc98240818b930 (diff)
parent0e46359cb00b453448e37ec16fce744f73c98581 (diff)
downloadsqlalchemy-b64ecb03a5411dd5f32e40ac564bec9a886d3672.tar.gz
Merge "Extract format_constraint truncation rules to ON CONFLICT"
Diffstat (limited to 'lib/sqlalchemy/dialects/postgresql/base.py')
-rw-r--r--lib/sqlalchemy/dialects/postgresql/base.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py
index 070490c1d..d8e4d5d20 100644
--- a/lib/sqlalchemy/dialects/postgresql/base.py
+++ b/lib/sqlalchemy/dialects/postgresql/base.py
@@ -2323,8 +2323,16 @@ class PGCompiler(compiler.SQLCompiler):
def _on_conflict_target(self, clause, **kw):
if clause.constraint_target is not None:
- target_text = "ON CONSTRAINT %s" % self.preparer.quote(
- clause.constraint_target
+ # target may be a name of an Index, UniqueConstraint or
+ # ExcludeConstraint. While there is a separate
+ # "max_identifier_length" for indexes, PostgreSQL uses the same
+ # length for all objects so we can use
+ # truncate_and_render_constraint_name
+ target_text = (
+ "ON CONSTRAINT %s"
+ % self.preparer.truncate_and_render_constraint_name(
+ clause.constraint_target
+ )
)
elif clause.inferred_target_elements is not None:
target_text = "(%s)" % ", ".join(