Duplicate Column check in AlterTableMigration doesn't always work.
- Lingua principale
- Kotlin
- Stelle
- 4.8k
- Fork
- 593
- Merge medio
- 1m
- PR unite (30g)
- 1
Descrizione
DBFlow Version: 4.2.4
Bug or Feature Request: Bug
Description:
I am getting reports of one of my migrations failing for a very small amount of users with an `SQLiteException` with the message `duplicate column name`. I know this is caused by a previous migration that was done wrong by me, so this in itself isn't the problem.
However, as far as I know the `AlterTableMigration` is meant to only add new columns if they don't exist yet, but apparently that isn't the case, since this exception is raised. So my assumption here is that the check for existing columns doesn't quite work. This is quite a problem for me because I wanted to eliminate these crashes by detecting the column existing before the migration is run using the same logic as the one in `AlterTableMigration` and resetting the app in that case. But since the check not working is the cause of this exception I can't work around it by using the check.
2/3 of the devices impacted by this issue are Android 4, but I also get reports from Android 5-9, so it isn't an exclusive 4 issue.
Stacktrace from one report:
```
Caused by android.database.sqlite.SQLiteException: duplicate column name: [column_name] (code 1): , while compiling: ALTER TABLE `[table_name]` ADD COLUMN `[column_name]` INTEGER
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(SQLiteConnection.java)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement + 1113(SQLiteConnection.java:1113)
at android.database.sqlite.SQLiteConnection.prepare + 686(SQLiteConnection.java:686)
at android.database.sqlite.SQLiteSession.prepare + 588(SQLiteSession.java:588)
at android.database.sqlite.SQLiteProgram. + 58(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteStatement. + 31(SQLiteStatement.java:31)
at android.database.sqlite.SQLiteDatabase.executeSql + 1769(SQLiteDatabase.java:1769)
at android.database.sqlite.SQLiteDatabase.execSQL + 1700(SQLiteDatabase.java:1700)
at com.raizlabs.android.dbflow.structure.database.AndroidDatabase.execSQL + 26(AndroidDatabase.java:26)
at com.raizlabs.android.dbflow.sql.migration.AlterTableMigration.migrate + 80(AlterTableMigration.java:80)
at com.raizlabs.android.dbflow.structure.database.BaseDatabaseHelper.executeMigrations + 171(BaseDatabaseHelper.java:171)
at com.raizlabs.android.dbflow.structure.database.BaseDatabaseHelper.onUpgrade + 56(BaseDatabaseHelper.java:56)
at com.raizlabs.android.dbflow.structure.database.DatabaseHelperDelegate.onUpgrade + 79(DatabaseHelperDelegate.java:79)
at com.raizlabs.android.dbflow.structure.database.FlowSQLiteOpenHelper.onUpgrade + 84(FlowSQLiteOpenHelper.java:84)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked + 257(SQLiteOpenHelper.java:257)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase + 164(SQLiteOpenHelper.java:164)
at com.raizlabs.android.dbflow.structure.database.FlowSQLiteOpenHelper.getDatabase + 62(FlowSQLiteOpenHelper.java:62)
at com.raizlabs.android.dbflow.config.DatabaseDefinition.getWritableDatabase + 257(DatabaseDefinition.java:257)
at com.raizlabs.android.dbflow.config.DatabaseDefinition.executeTransaction + 280(DatabaseDefinition.java:280)
at com.raizlabs.android.dbflow.structure.database.transaction.Transaction.executeSync + 121(Transaction.java:121)
at com.raizlabs.android.dbflow.structure.database.transaction.DefaultTransactionQueue.run + 54(DefaultTransactionQueue.java:54)
```
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Valutazione
Questa issue non è ancora stata valutata.