Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update all column values to boolean in room android?

I have database table as

@Entity
internal data class NotificationEntity(
@PrimaryKey @ColumnInfo(name = "notification_id") val notificationId: String,
val title: String,
val body: String?,
@ColumnInfo(name = "is_actionable") val isActionable: Boolean,
@ColumnInfo(name = "created_at") val createdAt: Instant,
@ColumnInfo(name = "is_read") val isRead: Boolean = false)

I want to update all the column values of isRead to true

I am using the following query but it isn't working.

@Query("UPDATE NotificationEntity SET is_read = 'true'")
suspend fun updateReadStatus()

Is it correct or not?

like image 346
WISHY Avatar asked Nov 01 '25 21:11

WISHY


1 Answers

The boolean values are mapped to the integer internally. So you should use

@Query("UPDATE NotificationEntity SET is_read = 1")
like image 134
sdex Avatar answered Nov 03 '25 11:11

sdex



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!