agrosner / DBFlow

A blazing fast, powerful, and very simple ORM android database library that writes database code for you.
MIT License
4.87k stars 598 forks source link

Unable to update multiple data when migration use UpdateTableMigration #1564

Closed qianshengta closed 3 years ago

qianshengta commented 6 years ago

DBFlow Version: 4.2.4

Bug or Feature Request: Unable to update multiple data when migration use UpdateTableMigration

Description:

@Migration(version = 2, priority = 2, database = MigrationDatabase.class)
public static class UpdateMigration2 extends UpdateTableMigration<MigrationModel> {

   /**
    * Creates an update migration.
    *
    * @param table The table to update
    */
   public UpdateMigration2(Class<MigrationModel> table) {
       super(table);
       set(MigrationModel_Table.name.eq("New Name"));
   }

}

Only one data can be updated.If more than one update, the data update is invalid.

@Database(version = 2)
public class AppDatabase {

    @Migration(version = 2, database = AppDatabase.class)
    public static class Migration2 extends BaseMigration {

        @Override
        public void migrate(DatabaseWrapper database) {
          // run some code here
          SQLite.update(Employee.class)
            .set(Employee_Table.status.eq("Invalid"),Employee_Table..job.eq("xxxxx"))
            .where(Employee_Table.job.eq("Laid Off"))
            .execute(database); // required inside a migration to pass the wrapper
        }
    }
}

The most basic application can update multiple data.

chaleao commented 6 years ago

I'm facing the same issue.

agrosner commented 3 years ago

its purpose is for only one singular update statement if you look at source.