我在我的 Android 项目中使用 DBFlow,我想知道是否有办法更新整个对象,而不是指定每一列,如下所示
// Native SQL wrapper
SQLite.update(Ant.class)
.set(Ant_Table.type.eq("other"))
.where(Ant_Table.type.is("worker"))
.and(Ant_Table.isMale.is(true))
.async()
.execute(); // non-UI blocking
从指南 https://agrosner.gitbooks.io/dbflow/content/SQLiteWrapperLanguage.html
更新的“设置”部分支持不同类型的值:
- ContentValues -> 转换为 key/value 作为 is()/eq() 的 SQLOperator
- SQLOperator,它们作为 SET 语句的一部分组合在一起。
基于此,我尝试将 ContentValues 传入 set 方法
// Native SQL wrapper
SQLite.update(Ant.class)
.set(contentValues)
.where(Ant_Table.type.is("worker"))
.and(Ant_Table.isMale.is(true))
.async()
.execute(); // non-UI blocking
我得到一个编译错误
set (com.raizlabs....SQLOperator...) in Update cannot be applied
to (android.content.ContentValues)