]> source.dussan.org Git - iciql.git/commitdiff
Fixed bug in primitive group by clauses
authorJames Moger <james.moger@gmail.com>
Tue, 6 Dec 2011 12:57:51 +0000 (07:57 -0500)
committerJames Moger <james.moger@gmail.com>
Tue, 6 Dec 2011 12:57:51 +0000 (07:57 -0500)
docs/05_releases.mkd
src/com/iciql/Query.java
tests/com/iciql/test/JoinTest.java

index 17b5e048ab7e0b2c592c0aa76cee4bcd8cca8d6e..94d0e9a03cbf09b576407f5df3d7ab0ddef160ef 100644 (file)
@@ -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%)) &nbsp; *released %BUILDDATE%*\r
 \r
 - Fixed joins on primitives\r
+- Fixed group by on primitives\r
 \r
 ### Older Releases\r
 \r
index b2d397ac394428b467c027fda134ba00d99cdaa4..2f5141d329509224b35e95201b3ce20e240384c3 100644 (file)
@@ -541,31 +541,31 @@ public class Query<T> {
        }\r
 \r
        public Query<T> groupBy(boolean field) {\r
-               return orderByPrimitive(field);\r
+               return groupByPrimitive(field);\r
        }\r
 \r
        public Query<T> groupBy(byte field) {\r
-               return orderByPrimitive(field);\r
+               return groupByPrimitive(field);\r
        }\r
 \r
        public Query<T> groupBy(short field) {\r
-               return orderByPrimitive(field);\r
+               return groupByPrimitive(field);\r
        }\r
 \r
        public Query<T> groupBy(int field) {\r
-               return orderByPrimitive(field);\r
+               return groupByPrimitive(field);\r
        }\r
 \r
        public Query<T> groupBy(long field) {\r
-               return orderByPrimitive(field);\r
+               return groupByPrimitive(field);\r
        }\r
 \r
        public Query<T> groupBy(float field) {\r
-               return orderByPrimitive(field);\r
+               return groupByPrimitive(field);\r
        }\r
 \r
        public Query<T> groupBy(double field) {\r
-               return orderByPrimitive(field);\r
+               return groupByPrimitive(field);\r
        }\r
 \r
        Query<T> groupByPrimitive(Object field) {\r
index eab1376e5f147449633a5927ab05f861dafcb9d1..018d721ea6771c301324bd33d8cd3c386124f45b 100644 (file)
@@ -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<UserId> users = (List<UserId>) 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 {