diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-10-15 17:21:38 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-10-15 17:21:38 -0400 |
| commit | c307df6596dab489109cd216665cf30006b70d13 (patch) | |
| tree | 4ce669b36759f8289d959c0e7e92b776b77d1865 /test/orm/test_query.py | |
| parent | 3510e38a772a2e48a8bb4b0a4efc6479034f649e (diff) | |
| download | sqlalchemy-c307df6596dab489109cd216665cf30006b70d13.tar.gz | |
- [feature] "scalar" selects now have a WHERE method
to help with generative building. Also slight adjustment
regarding how SS "correlates" columns; the new methodology
no longer applies meaning to the underlying
Table column being selected. This improves
some fairly esoteric situations, and the logic
that was there didn't seem to have any purpose.
- [feature] Some support for auto-rendering of a
relationship join condition based on the mapped
attribute, with usage of core SQL constructs.
E.g. select([SomeClass]).where(SomeClass.somerelationship)
would render SELECT from "someclass" and use the
primaryjoin of "somerelationship" as the WHERE
clause. This changes the previous meaning
of "SomeClass.somerelationship" when used in a
core SQL context; previously, it would "resolve"
to the parent selectable, which wasn't generally
useful. Related to [ticket:2245].
Diffstat (limited to 'test/orm/test_query.py')
| -rw-r--r-- | test/orm/test_query.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/orm/test_query.py b/test/orm/test_query.py index 56275a735..52f83ba32 100644 --- a/test/orm/test_query.py +++ b/test/orm/test_query.py @@ -129,6 +129,26 @@ class RawSelectTest(QueryTest, AssertsCompiledSQL): "SELECT * FROM users" ) + def test_where_relationship(self): + User = self.classes.User + + self.assert_compile( + select([User]).where(User.addresses), + "SELECT users.id, users.name FROM users, addresses " + "WHERE users.id = addresses.user_id" + ) + + def test_where_m2m_relationship(self): + Item = self.classes.Item + + self.assert_compile( + select([Item]).where(Item.keywords), + "SELECT items.id, items.description FROM items, " + "item_keywords AS item_keywords_1, keywords " + "WHERE items.id = item_keywords_1.item_id " + "AND keywords.id = item_keywords_1.keyword_id" + ) + def test_inline_select_from_entity(self): User = self.classes.User |
