diff options
author | James Moger <jmoger@vas.com> | 2012-05-07 13:46:59 -0400 |
---|---|---|
committer | James Moger <jmoger@vas.com> | 2012-05-07 13:46:59 -0400 |
commit | c5ea6785a5ce16ce9c856e220ced92091b9e1ef5 (patch) | |
tree | fad25ac7049e62d25d8cee5c145389643fe7dba2 /tests | |
parent | dd8d894824afb8ba677e838dbab2781e06d643f5 (diff) | |
download | iciql-c5ea6785a5ce16ce9c856e220ced92091b9e1ef5.tar.gz iciql-c5ea6785a5ce16ce9c856e220ced92091b9e1ef5.zip |
Draft support for "where xxx in(select bbb from...)"
Diffstat (limited to 'tests')
-rw-r--r-- | tests/com/iciql/test/JoinTest.java | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/com/iciql/test/JoinTest.java b/tests/com/iciql/test/JoinTest.java index 1fea444..3e36eff 100644 --- a/tests/com/iciql/test/JoinTest.java +++ b/tests/com/iciql/test/JoinTest.java @@ -28,6 +28,7 @@ import org.junit.Test; import com.iciql.Db; import com.iciql.Iciql.IQColumn; import com.iciql.Iciql.IQTable; +import com.iciql.QueryWhere; /** * Tests of Joins. @@ -91,6 +92,17 @@ public class JoinTest { assertEquals(4, notes.get(0).id); } + @Test + public void testSubQuery() throws Exception { + final UserId u = new UserId(); + final UserNote n = new UserNote(); + + QueryWhere<UserId> q = db.from(u).where(u.id).in(db.from(n).where(n.userId).exceeds(0).subQuery(n.userId)); + assertEquals("SELECT * FROM UserId WHERE id in (SELECT userId FROM UserNote WHERE userId > 0 )", q.toSQL()); + List<UserId> notes = q.select(); + assertEquals(3, notes.size()); + } + @IQTable public static class UserId { |