Reputation: 1291
I would like to create fully dynamic where clause in Room.
Is there any way to make something like code below to work and return number of updated columns?
@Query("UPDATE table SET column = ${xyConstVal} WHERE :where")
fun updateTable(where:String):Int
Thanks.
Upvotes: 0
Views: 232
Reputation: 61
I would like to create fully dynamic where clause in Room.
Instead of using @Query annotation in dao you could try using @RawQuery which accepts SupportSQLiteQuery as value then write your query in old fashioned way
Is there any way to make something like code below to work and return number of updated columns?
A method, annotated with @Insert can return a long. This is the newly generated ID for the inserted row. A method, annotated with @Update can return an int. This is the number of updated rows.
In your case you can combine both
Upvotes: 1