aboutsummaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/com/iciql/test/ModelsTest.java15
-rw-r--r--src/test/java/com/iciql/test/PrimitivesTest.java17
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());
+ }
}