Ignore

@Insert(onConflict = OnConflictStrategy.IGNORE)
@Update(onConflict = OnConflictStrategy.IGNORE)

What SQLite Does

This strategy maps to INSERT OR IGNORE or UPDATE OR IGNORE statements. This has two key differences to how FAIL works:

The result is that everything that can be inserted or updated is inserted or updated, with individual rows being skipped where they fail on constraint violations.

This is risky, in that you may not necessarily have a good way of knowing that some of your requested data manipulations did not take effect.

Effects in Room

Since IGNORE does not trigger an exception, Room will commit the transaction that contains your @Insert or @Update work. Hence, this “works”, insofar as Room does not reject changes that SQLite would otherwise accept because Room rolled back the transaction. You still suffer from not knowing what exactly was changed by your @Insert or @Update method, though.


Prev Table of Contents Next

This book is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license.