mirror of
https://github.com/bitfireAT/davx5-ose.git
synced 2025-12-23 15:07:51 -05:00
Add comments on foreign key constraint enforcement
This commit is contained in:
@@ -61,6 +61,11 @@ abstract class DatabaseMigrationTest(
|
||||
// Prepare the database with the initial version.
|
||||
val dbName = "test"
|
||||
helper.createDatabase(dbName, version = toVersion - 1).apply {
|
||||
// Foreign key constraint enforcement is disabled by default in SQLite and needs to
|
||||
// be enabled per connection. For production code room does that for us - in tests we
|
||||
// need to enable it ourselves. We could enable foreign key constraint enforcement here,
|
||||
// but it's more practical for the tests to not do so.
|
||||
// execSQL("PRAGMA foreign_keys=ON;");
|
||||
prepare(this)
|
||||
close()
|
||||
}
|
||||
|
||||
@@ -91,7 +91,9 @@ class Migration18Test : DatabaseMigrationTest(toVersion = 18) {
|
||||
arrayOf<Any?>(1, 1, "com.android.contacts", 1234)
|
||||
)
|
||||
|
||||
// Two orphan syncstats rows (collectionId not in collection)
|
||||
// Insert two orphan syncstats rows (collectionId not in collection)
|
||||
// We can insert them here because SQLite foreign key constraint enforcement is not active.
|
||||
// See `testMigration()` for details.
|
||||
db.execSQL(
|
||||
"INSERT INTO syncstats (id, collectionId, authority, lastSync) VALUES (?, ?, ?, ?)",
|
||||
arrayOf<Any?>(2, 99, "com.android.calendar", 1660521600)
|
||||
|
||||
Reference in New Issue
Block a user