summaryrefslogtreecommitdiff
path: root/test/sql/test_selectable.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2013-06-26 13:24:07 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2013-06-26 13:24:07 -0400
commitf76e65727d667a0c40f132698c2c11063d7271bd (patch)
tree29652c5f8421e432bab07829f00801b2db627181 /test/sql/test_selectable.py
parentef6245a3caa10b0d1e1a08e49a91e186a9d9efc6 (diff)
parentf76cae4bc92da640c155337da5d089075ebae0d8 (diff)
downloadsqlalchemy-f76e65727d667a0c40f132698c2c11063d7271bd.tar.gz
Merge branch 'ticket_2746'
Conflicts: doc/build/changelog/changelog_08.rst doc/build/changelog/changelog_09.rst
Diffstat (limited to 'test/sql/test_selectable.py')
-rw-r--r--test/sql/test_selectable.py44
1 files changed, 43 insertions, 1 deletions
diff --git a/test/sql/test_selectable.py b/test/sql/test_selectable.py
index 6a0511faa..335083ce1 100644
--- a/test/sql/test_selectable.py
+++ b/test/sql/test_selectable.py
@@ -6,7 +6,7 @@ from sqlalchemy import *
from sqlalchemy.testing import fixtures, AssertsCompiledSQL, \
AssertsExecutionResults
from sqlalchemy import testing
-from sqlalchemy.sql import util as sql_util, visitors
+from sqlalchemy.sql import util as sql_util, visitors, expression
from sqlalchemy import exc
from sqlalchemy.sql import table, column, null
from sqlalchemy import util
@@ -148,6 +148,48 @@ class SelectableTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiled
s = select([t])._clone()
assert c in s.c.bar.proxy_set
+ def test_cloned_intersection(self):
+ t1 = table('t1', column('x'))
+ t2 = table('t2', column('x'))
+
+ s1 = t1.select()
+ s2 = t2.select()
+ s3 = t1.select()
+
+ s1c1 = s1._clone()
+ s1c2 = s1._clone()
+ s2c1 = s2._clone()
+ s3c1 = s3._clone()
+
+ eq_(
+ expression._cloned_intersection(
+ [s1c1, s3c1], [s2c1, s1c2]
+ ),
+ set([s1c1])
+ )
+
+ def test_cloned_difference(self):
+ t1 = table('t1', column('x'))
+ t2 = table('t2', column('x'))
+
+ s1 = t1.select()
+ s2 = t2.select()
+ s3 = t1.select()
+
+ s1c1 = s1._clone()
+ s1c2 = s1._clone()
+ s2c1 = s2._clone()
+ s2c2 = s2._clone()
+ s3c1 = s3._clone()
+
+ eq_(
+ expression._cloned_difference(
+ [s1c1, s2c1, s3c1], [s2c1, s1c2]
+ ),
+ set([s3c1])
+ )
+
+
def test_distance_on_aliases(self):
a1 = table1.alias('a1')
for s in (select([a1, table1], use_labels=True),