如何将整数文字放入房间查询中?



是否可以将整数文本放入房间查询中?以下查询会导致生成错误:

@Query("UPDATE topics SET unreadCount=0 WHERE id=:chatId")
fun resetUnreadCount(chatId: Long)

我已经尝试了几个选项(包括 RawQuery(,并得到了一个使用默认值传递 Int 参数的选项:

@Query("UPDATE chats SET unreadCount=:ZERO WHERE id=:chatId")
fun resetUnreadCount(chatId: Long, ZERO: Int = 0) // hacky way to pass int literal into the query

有没有正常的方法可以做到这一点?

第一个查询具有不同的实体类"主题">

@Query("UPDATE topics SET unreadCount=0 WHERE id=:chatId")

也应该聊天吗? 因为下面的查询正在工作。 查询中的整数很好。

@Query("UPDATE chats SET unreadCount=:ZERO WHERE id=:chatId")

请查看此文档。

https://www.sqlite.org/datatype3.html。看看第3.4节,它谈到了coumn亲和力行为

unreadCount='0'

这也应该有效

@Query("UPDATE topics SET unreadCount='0' WHERE id=:chatId")

最新更新