From 1ccaac8293ee69f22dd01766a26c3ca7893c6a83 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Thu, 29 Jul 2021 10:10:28 -0400 Subject: accommodate for cloned bindparams w/ maintain_key Fixed issue where a bound parameter object that was "cloned" would cause a name conflict in the compiler, if more than one clone of this parameter were used at the same time in a single statement. This could occur in particular with things like ORM single table inheritance queries that indicated the same "discriminator" value multiple times in one query. Fixes: #6824 Change-Id: Iba7a786fc5a2341ff7d07fc666d24ed790ad4fe8 --- lib/sqlalchemy/sql/compiler.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'lib/sqlalchemy/sql') diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index 29ef8047e..a81507acb 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -2311,8 +2311,14 @@ class SQLCompiler(Compiled): existing = self.binds[name] if existing is not bindparam: if ( - existing.unique or bindparam.unique - ) and not existing.proxy_set.intersection(bindparam.proxy_set): + (existing.unique or bindparam.unique) + and not existing.proxy_set.intersection( + bindparam.proxy_set + ) + and not existing._cloned_set.intersection( + bindparam._cloned_set + ) + ): raise exc.CompileError( "Bind parameter '%s' conflicts with " "unique bind parameter of the same name" % name -- cgit v1.2.1