From ad70685918aac114a4babd9a1a0e0217b6323df0 Mon Sep 17 00:00:00 2001 From: James Moger Date: Tue, 6 Dec 2011 07:57:51 -0500 Subject: [PATCH] Fixed bug in primitive group by clauses --- docs/05_releases.mkd | 1 + src/com/iciql/Query.java | 14 +++++++------- tests/com/iciql/test/JoinTest.java | 18 ++++++++++++++++++ 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/docs/05_releases.mkd b/docs/05_releases.mkd index 17b5e04..94d0e9a 100644 --- a/docs/05_releases.mkd +++ b/docs/05_releases.mkd @@ -7,6 +7,7 @@ **%VERSION%** ([zip](http://code.google.com/p/iciql/downloads/detail?name=%ZIP%)|[jar](http://code.google.com/p/iciql/downloads/detail?name=%JAR%))   *released %BUILDDATE%* - Fixed joins on primitives +- Fixed group by on primitives ### Older Releases diff --git a/src/com/iciql/Query.java b/src/com/iciql/Query.java index b2d397a..2f5141d 100644 --- a/src/com/iciql/Query.java +++ b/src/com/iciql/Query.java @@ -541,31 +541,31 @@ public class Query { } public Query groupBy(boolean field) { - return orderByPrimitive(field); + return groupByPrimitive(field); } public Query groupBy(byte field) { - return orderByPrimitive(field); + return groupByPrimitive(field); } public Query groupBy(short field) { - return orderByPrimitive(field); + return groupByPrimitive(field); } public Query groupBy(int field) { - return orderByPrimitive(field); + return groupByPrimitive(field); } public Query groupBy(long field) { - return orderByPrimitive(field); + return groupByPrimitive(field); } public Query groupBy(float field) { - return orderByPrimitive(field); + return groupByPrimitive(field); } public Query groupBy(double field) { - return orderByPrimitive(field); + return groupByPrimitive(field); } Query groupByPrimitive(Object field) { diff --git a/tests/com/iciql/test/JoinTest.java b/tests/com/iciql/test/JoinTest.java index eab1376..018d721 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.util.IciqlLogger; /** * Tests of Joins. @@ -68,6 +69,23 @@ public class JoinTest { 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 users = (List) 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); + + assertEquals(1, users.size()); + } @IQTable public static class UserId { -- 2.39.5