From fe7a924f168f5738fead18a4b0dad8b0451a5973 Mon Sep 17 00:00:00 2001 From: James Moger Date: Tue, 6 Dec 2011 12:45:11 -0500 Subject: [PATCH] Fixed join into custom type of primitives --- api/v8.xml | 6098 ++++++++++++++++++++++++++ docs/05_releases.mkd | 6 +- src/com/iciql/Constants.java | 6 +- src/com/iciql/TableDefinition.java | 10 +- tests/com/iciql/test/IciqlSuite.java | 2 + tests/com/iciql/test/JoinTest.java | 23 +- 6 files changed, 6124 insertions(+), 21 deletions(-) create mode 100644 api/v8.xml diff --git a/api/v8.xml b/api/v8.xml new file mode 100644 index 0000000..d738d6a --- /dev/null +++ b/api/v8.xml @@ -0,0 +1,6098 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/05_releases.mkd b/docs/05_releases.mkd index 6d6054c..abc8791 100644 --- a/docs/05_releases.mkd +++ b/docs/05_releases.mkd @@ -6,8 +6,10 @@ **%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 +- api change release (API v8) +- Fixed JOIN ON primitives +- Fixed GROUP BY primitives +- Fixed primitive references when selecting into a custom type with primitives - Improved fluent/type-safety of joins ### Older Releases diff --git a/src/com/iciql/Constants.java b/src/com/iciql/Constants.java index 0bd7663..5c1bfc0 100644 --- a/src/com/iciql/Constants.java +++ b/src/com/iciql/Constants.java @@ -25,14 +25,14 @@ public class Constants { // The build script extracts this exact line so be careful editing it // and only use A-Z a-z 0-9 .-_ in the string. - public static final String VERSION = "0.7.3-SNAPSHOT"; + public static final String VERSION = "0.7.3"; // The build script extracts this exact line so be careful editing it // and only use A-Z a-z 0-9 .-_ in the string. - public static final String VERSION_DATE = "PENDING"; + public static final String VERSION_DATE = "2011-12-06"; // The build script extracts this exact line so be careful editing it // and only use A-Z a-z 0-9 .-_ in the string. - public static final String API_CURRENT = "7"; + public static final String API_CURRENT = "8"; } diff --git a/src/com/iciql/TableDefinition.java b/src/com/iciql/TableDefinition.java index 05d312c..97060f9 100644 --- a/src/com/iciql/TableDefinition.java +++ b/src/com/iciql/TableDefinition.java @@ -722,8 +722,14 @@ public class TableDefinition { stat.appendSQL(", "); } FieldDefinition def = fields.get(i); - Object obj = def.getValue(x); - query.appendSQL(stat, x, obj); + if (def.isPrimitive) { + Object obj = def.getValue(x); + Object alias = query.getPrimitiveAliasByValue(obj); + query.appendSQL(stat, x, alias); + } else { + Object obj = def.getValue(x); + query.appendSQL(stat, x, obj); + } } } } 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 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 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 -- 2.39.5