From 73f734bf80166c7dfce4892941752d7569a17524 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 6 Feb 2012 12:20:15 -0500 Subject: initial annotations approach to join conditions. all tests pass, plus additional tests in #1401 pass. would now like to reorganize RelationshipProperty more around the annotations concept. --- test/sql/test_selectable.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test/sql/test_selectable.py') diff --git a/test/sql/test_selectable.py b/test/sql/test_selectable.py index 8f599f1d6..6d85f7c4f 100644 --- a/test/sql/test_selectable.py +++ b/test/sql/test_selectable.py @@ -1023,6 +1023,25 @@ class AnnotationsTest(fixtures.TestBase): annot = obj._annotate({}) eq_(set([obj]), set([annot])) + def test_compare(self): + t = table('t', column('x'), column('y')) + x_a = t.c.x._annotate({}) + assert t.c.x.compare(x_a) + assert x_a.compare(t.c.x) + assert not x_a.compare(t.c.y) + assert not t.c.y.compare(x_a) + assert (t.c.x == 5).compare(x_a == 5) + assert not (t.c.y == 5).compare(x_a == 5) + + s = select([t]) + x_p = s.c.x + assert not x_a.compare(x_p) + assert not t.c.x.compare(x_p) + x_p_a = x_p._annotate({}) + assert x_p_a.compare(x_p) + assert x_p.compare(x_p_a) + assert not x_p_a.compare(x_a) + def test_custom_constructions(self): from sqlalchemy.schema import Column class MyColumn(Column): -- cgit v1.2.1 From bc45fa350a02da5f24d866078abed471cd98f15b Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Thu, 9 Feb 2012 21:16:53 -0500 Subject: - got m2m, local_remote_pairs, etc. working - using new traversal that returns the product of both sides of a binary, starting to work with (a+b) == (c+d) types of joins. primaryjoins on functions working - annotations working, including reversing local/remote when doing backref --- test/sql/test_selectable.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'test/sql/test_selectable.py') diff --git a/test/sql/test_selectable.py b/test/sql/test_selectable.py index 6d85f7c4f..4f1f39014 100644 --- a/test/sql/test_selectable.py +++ b/test/sql/test_selectable.py @@ -1151,5 +1151,7 @@ class AnnotationsTest(fixtures.TestBase): assert b2.left is not bin.left assert b3.left is not b2.left is not bin.left 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 + assert b4.right is bin.right + assert b2.right is not bin.right + assert b3.right is b4.right is bin.right -- cgit v1.2.1 From d934ea23e24880a5c784c9e5edf9ead5bc965a83 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 11 Feb 2012 20:33:56 -0500 Subject: - figured out again why deannotate must clone() - got everything working. just need to update error strings --- test/sql/test_selectable.py | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) (limited to 'test/sql/test_selectable.py') diff --git a/test/sql/test_selectable.py b/test/sql/test_selectable.py index 4f1f39014..c61760c5d 100644 --- a/test/sql/test_selectable.py +++ b/test/sql/test_selectable.py @@ -1151,7 +1151,37 @@ class AnnotationsTest(fixtures.TestBase): assert b2.left is not bin.left assert b3.left is not b2.left is not bin.left assert b4.left is bin.left # since column is immutable - assert b4.right is bin.right - assert b2.right is not bin.right - assert b3.right is b4.right is bin.right + # deannotate copies the element + assert bin.right is not b2.right is not b3.right is not b4.right + def test_deannotate_2(self): + table1 = table('table1', column("col1"), column("col2")) + j = table1.c.col1._annotate({"remote":True}) == \ + table1.c.col2._annotate({"local":True}) + j2 = sql_util._deep_deannotate(j) + eq_( + j.left._annotations, {"remote":True} + ) + eq_( + j2.left._annotations, {} + ) + + def test_deannotate_3(self): + table1 = table('table1', column("col1"), column("col2"), + column("col3"), column("col4")) + j = and_( + table1.c.col1._annotate({"remote":True})== + table1.c.col2._annotate({"local":True}), + table1.c.col3._annotate({"remote":True})== + table1.c.col4._annotate({"local":True}) + ) + j2 = sql_util._deep_deannotate(j) + eq_( + j.clauses[0].left._annotations, {"remote":True} + ) + eq_( + j2.clauses[0].left._annotations, {} + ) + + + -- cgit v1.2.1