Description
Backstory:
We use N1QLExpression to implement a custom base repository.
Issue:
If a collection of keys are passed in invalid n1ql is generated.
expression.keys(Arrays.asList("hello", "world"));
would generate
USE KEYS `hello`, `world`
instead of the valid
USE KEYS ["hello", "world"]
Solution: (from our workaround)
public N1QLExpression keys(Iterable<? extends Serializable> ids) {
StringBuilder sb = new StringBuilder();
Iterator<?> it = ids.iterator();
int count = 0;
while (it.hasNext()) {
count++;
sb.append(s(it.next().toString()));
if (it.hasNext()) {
sb.append(",");
}
}
return infix("USE KEYS", toString(), count > 1 ? "[" + sb.toString() + "]" : sb.toString());
}