Browse Source

Fixes #24: Add where(String) method to improve interop

tags/release-2.1.1
James Moger 8 years ago
parent
commit
4d6ad0e9c2
3 changed files with 22 additions and 0 deletions
  1. 4
    0
      CHANGELOG.md
  2. 10
    0
      src/main/java/com/iciql/Query.java
  3. 8
    0
      src/test/java/com/iciql/test/ModelsTest.java

+ 4
- 0
CHANGELOG.md View File

@@ -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*)

+ 10
- 0
src/main/java/com/iciql/Query.java View File

@@ -663,6 +663,16 @@ public class Query<T> {
return new QueryWhere<T>(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<T, String> where(String x) {
return new QueryCondition<T, String>(this, x);
}

public QueryWhere<T> where(String fragment, List<?> args) {
return this.where(fragment, args.toArray());
}

+ 8
- 0
src/test/java/com/iciql/test/ModelsTest.java View File

@@ -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<Product> seafoodProducts = db.from(products).where(products.category).is("Seafood").select();
assertEquals(1, seafoodProducts.size());
}

}

Loading…
Cancel
Save