Hi Stephen,
That looks like a bug to me; I don't see why you shouldn't be able to
use the fluid API to build a "not" clause inside an "and" clause such as
this:
final PreparedQuery query =
sqliteDao.queryBuilder().where()
.like("col1", "%foo%")
.and().not().like("col2", "%bar%").prepare();
As you pointed out, the above syntax fails with the "already waiting for
a future clause" error. As far as I can tell this is because the Sqlite
fluid syntax is only keeping track of a single current "needs future"
clause but the "and" and the "not" clauses are both "needs future" clauses.
I did manage to build the desired query, however, by using the following
alternative, slightly clunky, syntax:
final Where where = sqliteDao.queryBuilder().where();
final Where clause1 = where.like("col1", "%foo%");
final Where clause2 = where.not().like("col2", "%bar%");
final PreparedQuery query =
where.and(clause1, clause2).prepare();
I hope this helps.
Maybe Gray can comment on whether this is a bug or a by-design
limitation of Sqlite. I guess adding support for the and-not fluid
syntax will require maintaining a stack of nested current "needs future"
clauses.
- Nathan