I am thinking about the request to easily create where clauses that look like
where X or Y or Z or ...
I made a small addition to the Where
class, a static factory method with this signature:
public static Where or(List<Where> subWheres)
This allows users to write code like this:
@Test
public void testStaticOrConstruction() {
helper.useConnection(connection -> {
Dao<Columns> dao = daoBuilder().buildDao(connection);
for(long idx=1; idx<=10; idx++){
Columns columns = new Columns();
columns.setIntegerThing(idx);
dao.insert(columns);
}
});
helper.useConnection(connection -> {
Dao<Columns> dao = daoBuilder().buildDao(connection);
List<Where> wheres = new ArrayList<>();
for(long idx=2; idx<=10; idx+=2){
wheres.add(new Where("integer_column", EQUALS, idx));
}
List<Columns> columns = dao.select(Where.or(wheres));
AssertHelp.containsAllItems(new Long[]{ 2L, 4L, 6L, 8L, 10L }, columns, c -> c.getIntegerThing());
});
}
It’s a pretty small addition, and adding a similar and
method is easy enough.
Not sure if this scratches a big enough itch, but there’s little downside. Still thinking about it, to see if a better idea appears.