Reputation: 2598
@Query("UPDATE items SET saved=:saved WHERE id IN :itemsIds") // works
abstract void method1(List<Long> itemsIds, boolean saved);
@Query("UPDATE items SET saved=:saved WHERE id NOT IN :itemsIds") // ERROR!!
abstract void method2(List<Long> itemsIds, boolean saved);
@Transaction
void updatePreferredItems(@NonNull List<Long> prefItems) {
method1(prefItems, true);
method2(prefItems, false);
}
My objective is from an ids list I would like to to update the field saved of all the items to true if item id belong to ids list, false otherwise.
Why the second query is generating a compile error ?
Is this the right approach ?
Upvotes: 3
Views: 1384
Reputation: 86
What happens when you do this:
@Query("UPDATE items SET saved=:saved WHERE NOT(id IN :itemsIds)") // ERROR??
abstract void method2(List<Long> itemsIds, boolean saved);
Upvotes: 3