From 824bd661588d6715d56f279494f98046215b394c Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 18 Aug 2012 01:03:31 -0400 Subject: [PATCH] - aaaaand fix one more glitch I just thought of --- lib/sqlalchemy/sql/expression.py | 1 + test/sql/test_selectable.py | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py index e8905ccec5..969a6920b2 100644 --- a/lib/sqlalchemy/sql/expression.py +++ b/lib/sqlalchemy/sql/expression.py @@ -1586,6 +1586,7 @@ class ClauseElement(Visitable): c = self.__class__.__new__(self.__class__) c.__dict__ = self.__dict__.copy() c.__dict__.pop('_cloned_set', None) + c.__dict__.pop('comparator', None) # this is a marker that helps to "equate" clauses to each other # when a Select returns its list of FROM clauses. the cloning diff --git a/test/sql/test_selectable.py b/test/sql/test_selectable.py index 045f6695c3..b81bd8e6fe 100644 --- a/test/sql/test_selectable.py +++ b/test/sql/test_selectable.py @@ -1,7 +1,7 @@ """Test various algorithmic properties of selectables.""" from test.lib.testing import eq_, assert_raises, \ - assert_raises_message + assert_raises_message, is_ from sqlalchemy import * from test.lib import * from sqlalchemy.sql import util as sql_util, visitors @@ -348,6 +348,14 @@ class SelectableTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiled criterion = a.c.table1_col1 == table2.c.col2 self.assert_(criterion.compare(j.onclause)) + def test_scalar_cloned_comparator(self): + sel = select([table1.c.col1]).as_scalar() + expr = sel == table1.c.col1 + + sel2 = visitors.ReplacingCloningVisitor().traverse(sel) + + expr2 = sel2 == table1.c.col1 + is_(expr2.left, sel2) def test_column_labels(self): a = select([table1.c.col1.label('acol1'), -- 2.47.3