diff options
author | James Moger <james.moger@gitblit.com> | 2016-04-04 19:17:43 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2016-04-04 19:17:43 -0400 |
commit | 27979f07905dbf95b478a48babc99643d71bfdec (patch) | |
tree | 9c5cc0c9f72d30d0cf6747cc62b3452fa8020c37 /src/test | |
parent | 13b08bb1e5a955650289c1c2d548883bfeac0de9 (diff) | |
download | iciql-27979f07905dbf95b478a48babc99643d71bfdec.tar.gz iciql-27979f07905dbf95b478a48babc99643d71bfdec.zip |
Allow selecting a column from a table
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/java/com/iciql/test/ModelsTest.java | 15 | ||||
-rw-r--r-- | src/test/java/com/iciql/test/PrimitivesTest.java | 17 |
2 files changed, 32 insertions, 0 deletions
diff --git a/src/test/java/com/iciql/test/ModelsTest.java b/src/test/java/com/iciql/test/ModelsTest.java index ff27bf5..a5474df 100644 --- a/src/test/java/com/iciql/test/ModelsTest.java +++ b/src/test/java/com/iciql/test/ModelsTest.java @@ -160,4 +160,19 @@ public class ModelsTest { SupportedTypes s2 = db.from(SupportedTypes.SAMPLE).where(SupportedTypes.SAMPLE.id).is(1).selectFirst(); assertEquals(40, s2.myString.length()); } + + @Test + public void testColumnSelection() { + List<SupportedTypes> original = SupportedTypes.createList(); + db.insertAll(original); + List<String> myStrings = db.from(SupportedTypes.SAMPLE) + .select(SupportedTypes.SAMPLE.myString); + assertEquals(10, myStrings.size()); + + List<Integer> ids = db.from(SupportedTypes.SAMPLE) + .orderByDesc(SupportedTypes.SAMPLE.id) + .selectDistinct(SupportedTypes.SAMPLE.id); + assertEquals(10, ids.size()); + assertEquals("[9, 8, 7, 6, 5, 4, 3, 2, 1, 0]", ids.toString()); + } } diff --git a/src/test/java/com/iciql/test/PrimitivesTest.java b/src/test/java/com/iciql/test/PrimitivesTest.java index 0e8bf20..938fd32 100644 --- a/src/test/java/com/iciql/test/PrimitivesTest.java +++ b/src/test/java/com/iciql/test/PrimitivesTest.java @@ -99,4 +99,21 @@ public class PrimitivesTest { }
db.close();
}
+
+ @Test
+ public void testPrimitiveColumnSelection() {
+ Db db = IciqlSuite.openNewDb();
+
+ // insert random models in reverse order
+ List<PrimitivesModel> models = PrimitivesModel.getList();
+ PrimitivesModel model = models.get(0);
+ Collections.reverse(models);
+ // insert them in reverse order
+ db.insertAll(models);
+
+ PrimitivesModel p = new PrimitivesModel();
+ List<Long> list = db.from(p)/*.orderByDesc(p.myLong)*/.select(p.myLong);
+ assertEquals(models.size(), list.size());
+ assertEquals("[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]", list.toString());
+ }
}
|