From 4d6ad0e9c2f20369bf8766777f3d51f759c2df08 Mon Sep 17 00:00:00 2001 From: James Moger Date: Thu, 7 Apr 2016 14:31:16 -0400 Subject: [PATCH] Fixes #24: Add where(String) method to improve interop --- CHANGELOG.md | 4 ++++ src/main/java/com/iciql/Query.java | 10 ++++++++++ src/test/java/com/iciql/test/ModelsTest.java | 8 ++++++++ 3 files changed, 22 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ce2d54..03aaca7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +### [2.1.1] - 2016-04-07 +#### Added +- Add explicit `where(String)` method to help with non-Java language interop + ### [2.1.0] - 2016-04-06 #### Added - Add methods to select counts of a group by field (*SELECT field, COUNT(*) FROM table [WHERE conditions] GROUP BY field*) diff --git a/src/main/java/com/iciql/Query.java b/src/main/java/com/iciql/Query.java index 20d5520..d1528e8 100644 --- a/src/main/java/com/iciql/Query.java +++ b/src/main/java/com/iciql/Query.java @@ -663,6 +663,16 @@ public class Query { return new QueryWhere(this); } + /** + * Begin an string field condition clause explicitly defined for interop clarity. + * + * @param x the mapped string to query + * @return a query condition to continue building the condition + */ + public QueryCondition where(String x) { + return new QueryCondition(this, x); + } + public QueryWhere where(String fragment, List args) { return this.where(fragment, args.toArray()); } diff --git a/src/test/java/com/iciql/test/ModelsTest.java b/src/test/java/com/iciql/test/ModelsTest.java index 96a6e4a..9fef979 100644 --- a/src/test/java/com/iciql/test/ModelsTest.java +++ b/src/test/java/com/iciql/test/ModelsTest.java @@ -218,4 +218,12 @@ public class ModelsTest { assertEquals("[Condiments=5, Beverages=2, Produce=1, Meat/Poultry=1]", categories.toString()); } + @Test + public void testWhereByString() { + Product products = new Product(); + + List seafoodProducts = db.from(products).where(products.category).is("Seafood").select(); + assertEquals(1, seafoodProducts.size()); + } + } -- 2.39.5