diff options
author | James Moger <james.moger@gmail.com> | 2011-12-06 12:45:11 -0500 |
---|---|---|
committer | James Moger <james.moger@gmail.com> | 2011-12-06 12:45:11 -0500 |
commit | fe7a924f168f5738fead18a4b0dad8b0451a5973 (patch) | |
tree | af2f0f3303b6f6f329f5cfcd357b28d590799455 /tests | |
parent | 0b94e39b872246774fe2f3a0d507f7c134a9d6b4 (diff) | |
download | iciql-fe7a924f168f5738fead18a4b0dad8b0451a5973.tar.gz iciql-fe7a924f168f5738fead18a4b0dad8b0451a5973.zip |
Fixed join into custom type of primitivesv0.7.3
Diffstat (limited to 'tests')
-rw-r--r-- | tests/com/iciql/test/IciqlSuite.java | 2 | ||||
-rw-r--r-- | tests/com/iciql/test/JoinTest.java | 23 |
2 files changed, 11 insertions, 14 deletions
diff --git a/tests/com/iciql/test/IciqlSuite.java b/tests/com/iciql/test/IciqlSuite.java index 3c98d69..000b1c8 100644 --- a/tests/com/iciql/test/IciqlSuite.java +++ b/tests/com/iciql/test/IciqlSuite.java @@ -170,6 +170,8 @@ public class IciqlSuite { db.dropTable(ProductInheritedAnnotation.class);
db.dropTable(ProductMixedAnnotation.class);
db.dropTable(SupportedTypes.class);
+ db.dropTable(JoinTest.UserId.class);
+ db.dropTable(JoinTest.UserNote.class);
return db;
}
diff --git a/tests/com/iciql/test/JoinTest.java b/tests/com/iciql/test/JoinTest.java index ceb2ad5..3d72ab8 100644 --- a/tests/com/iciql/test/JoinTest.java +++ b/tests/com/iciql/test/JoinTest.java @@ -39,6 +39,9 @@ public class JoinTest { @Before public void setup() { db = IciqlSuite.openNewDb(); + + db.insertAll(UserId.getList()); + db.insertAll(UserNote.getList()); } @After @@ -48,9 +51,6 @@ public class JoinTest { @Test public void testPrimitiveJoin() throws Exception { - db.insertAll(UserId.getList()); - db.insertAll(UserNote.getList()); - final UserId u = new UserId(); final UserNote n = new UserNote(); @@ -62,28 +62,23 @@ public class JoinTest { text = n.text; } }); - - db.dropTable(UserId.class); - db.dropTable(UserNote.class); - assertEquals(3, notes.size()); } @Test public void testJoin() throws Exception { - db.insertAll(UserId.getList()); - db.insertAll(UserNote.getList()); - final UserId u = new UserId(); final UserNote n = new UserNote(); // this query returns 1 UserId if the user has a note - List<UserId> users = db.from(u).innerJoin(n).on(u.id).is(n.userId).groupBy(u.id).where(u.id).is(2).select(); - - db.dropTable(UserId.class); - db.dropTable(UserNote.class); + // it's purpose is to confirm fluency/type-safety on a very simple + // join case where the main table is filtered/reduced by hits in a + // related table + + List<UserId> users = db.from(u).innerJoin(n).on(u.id).is(n.userId).where(u.id).is(2).selectDistinct(); assertEquals(1, users.size()); + assertEquals(2, users.get(0).id); } @IQTable |