]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- [bug] Fixed bug whereby a primaryjoin
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 12 Mar 2012 20:35:27 +0000 (13:35 -0700)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 12 Mar 2012 20:35:27 +0000 (13:35 -0700)
condition with a "literal" in it would
raise an error on compile with certain
kinds of deeply nested expressions
which also needed to render the same
bound parameter name more than once.
[ticket:2425]

CHANGES
lib/sqlalchemy/sql/compiler.py
test/sql/test_selectable.py

diff --git a/CHANGES b/CHANGES
index 3936964c4c9ac17c5eeb6b2f9ee23140ebb2fdfd..6c94f3161c15efc840710a1342bc3d3fd708f5d2 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -13,6 +13,14 @@ CHANGES
     after the event was associated
     with the Session class.  [ticket:2424]
 
+  - [bug] Fixed bug whereby a primaryjoin
+    condition with a "literal" in it would
+    raise an error on compile with certain
+    kinds of deeply nested expressions
+    which also needed to render the same
+    bound parameter name more than once.
+    [ticket:2425]
+
   - [feature] Added "no_autoflush" context
     manager to Session, used with with:
     will temporarily disable autoflush.
index e8f86634d2d3a52096bb99f6cf9d6e394b641850..6f010ed54c7b53ec2cd1744fc722547e983c9e7d 100644 (file)
@@ -655,7 +655,8 @@ class SQLCompiler(engine.Compiled):
         if name in self.binds:
             existing = self.binds[name]
             if existing is not bindparam:
-                if existing.unique or bindparam.unique:
+                if (existing.unique or bindparam.unique) and \
+                    not existing.proxy_set.intersection(bindparam.proxy_set):
                     raise exc.CompileError(
                             "Bind parameter '%s' conflicts with "
                             "unique bind parameter of the same name" %
index 8f599f1d6dd675a4d3e99f74d1dc5a31d6410b77..9048192152e26157cbddaa7da8c8e4fe955f6db1 100644 (file)
@@ -1134,3 +1134,13 @@ class AnnotationsTest(fixtures.TestBase):
         assert b4.left is bin.left  # since column is immutable
         assert b4.right is not bin.right is not b2.right is not b3.right
 
+    def test_bind_unique_test(self):
+        t1 = table('t', column('a'), column('b'))
+
+        b = bindparam("bind", value="x", unique=True)
+
+        # the annotation of "b" should render the
+        # same.  The "unique" test in compiler should
+        # also pass, [ticket:2425]
+        eq_(str(or_(b, b._annotate({"foo":"bar"}))),
+            ":bind_1 OR :bind_1")