objectbox-java icon indicating copy to clipboard operation
objectbox-java copied to clipboard

Queries: Support "notIn" with string arrays like "in" does

Open Joeywp opened this issue 4 years ago • 1 comments

On queries, you can use string array "overloads" for in in the following ways: QueryBuilder<T> in(Property<T> property, String[] values) QueryBuilder<T> in(Property<T> property, String[] values, StringOrder order)

The same "overloads" are not supported for notIn though, which only supports int and long arrays

image

Edit: additional suggestions via #1129:

  • Implement doesNotContain, doesNotEndWith, doesNotStartWith into Property or
  • Create QueryCondition.not() that would allow to negate any given QueryCondition

Example use case for the latter :

Character_.lastName.equal("lannister", QueryBuilder.StringOrder.CASE_INSENSITIVE)
.and(Character_.firstName.startsWith("ty", QueryBuilder.StringOrder.CASE_INSENSITIVE)) // "Tywin", "Tyrion", "Tytos"

Character_.lastName.equal("lannister", QueryBuilder.StringOrder.CASE_INSENSITIVE)
.and(Character_.firstName.startsWith("ty", QueryBuilder.StringOrder.CASE_INSENSITIVE).not()) // "Cersei", "Jaime", "Lancel"

Joeywp avatar Jan 18 '21 14:01 Joeywp

Thanks! Yes, this is currently not supported. Thumbs up the first comment to help us track interest!

greenrobot-team avatar Jan 19 '21 12:01 greenrobot-team