Update using Boolean column work only with new Update<>
Hello guys,
I've trying update a simple object using...train.update(); but I got a exception in one property that is Boolean, but I found one solution here in issues ....
new Update<>(Train.class).set( Condition.column(Train$Table.SIZE).is(train.getSize()), Condition.column(Train$Table.INSTRUCTOR).is(train.getInstructor()), Condition.column(Train$Table.LOCATION).is(train.getLocation()), Condition.column(Train$Table.DATE).is(train.getDate()), Condition.column(Train$Table.TIME).is(train.getTime()), Condition.column(Train$Table.TRAINING).is(train.getTraining()), Condition.column(Train$Table.CHECK).is(train.getCheck())) //this is the boolean column .where(Condition.column(Train$Table.ID).is(train.getId())) .query();
So, I would like tell you this thing and help someone that stuck in that.
@diogo10 I need more information. Like the stacktrace and maybe example of the model you have.
Yes @agrosner.....this is the stack....
android.database.sqlite.SQLiteException: near "check": syntax error (code 1): , while compiling: UPDATE OR ABORT Train SET training=?,id=?,time=?,instructor=?,check=?,location=?,name=?,date=?,size=? WHERE `id`=29
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:882)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:493)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
at android.database.sqlite.SQLiteDatabase.updateWithOnConflict(SQLiteDatabase.java:1563)
at com.raizlabs.android.dbflow.SQLiteCompatibilityUtils.updateWithOnConflict(SQLiteCompatibilityUtils.java:63)
at com.raizlabs.android.dbflow.sql.SqlUtils.update(SqlUtils.java:257)
at com.raizlabs.android.dbflow.structure.ModelAdapter.update(ModelAdapter.java:74)
at com.raizlabs.android.dbflow.structure.BaseModel.update(BaseModel.java:66)
This is my BaseModel.....
@Table(databaseName = Db.NAME)
public class Train extends BaseModel implements Serializable {
@Column
@PrimaryKey(autoincrement = true)
public long id;
@Column
private String name;
@Column
private String location;
@Column
private String instructor;
@Column
private String date;
@Column
private String time;
@Column
private String size;
@Column
private Boolean check;
@Column
private String training;
public Train() {
}
//gets and sets
I think that is a duplicate of https://github.com/Raizlabs/DBFlow/issues/245 because CHECK is a reserved work
@andrecrispim thanks....I builded other models with Boolean columns with different names and worked normal using model.update().....