diff --git a/collect_app/src/main/java/org/odk/collect/android/database/entities/DatabaseEntitiesRepository.kt b/collect_app/src/main/java/org/odk/collect/android/database/entities/DatabaseEntitiesRepository.kt index 87d8b39ece6..83dc28616b2 100644 --- a/collect_app/src/main/java/org/odk/collect/android/database/entities/DatabaseEntitiesRepository.kt +++ b/collect_app/src/main/java/org/odk/collect/android/database/entities/DatabaseEntitiesRepository.kt @@ -198,7 +198,7 @@ class DatabaseEntitiesRepository(context: Context, dbPath: String) : EntitiesRep databaseConnection.withConnection { getLists().forEach { writableDatabase.delete( - it, + "`$it`", "${EntitiesTable.COLUMN_ID} = ?", arrayOf(id) ) diff --git a/collect_app/src/test/java/org/odk/collect/android/entities/EntitiesRepositoryTest.kt b/collect_app/src/test/java/org/odk/collect/android/entities/EntitiesRepositoryTest.kt index 6a09b148bc9..1c63b0277d5 100644 --- a/collect_app/src/test/java/org/odk/collect/android/entities/EntitiesRepositoryTest.kt +++ b/collect_app/src/test/java/org/odk/collect/android/entities/EntitiesRepositoryTest.kt @@ -428,6 +428,27 @@ abstract class EntitiesRepositoryTest { ) } + @Test + fun `#delete supports list names with dots and dashes`() { + val repository = buildSubject() + + val leoville = Entity.New("1", "LĂ©oville Barton 2008") + + repository.save("wines.x", leoville) + repository.save("wines-x", leoville) + + repository.delete("1") + + assertThat( + repository.getEntities("wines.x").isEmpty(), + equalTo(true) + ) + assertThat( + repository.getEntities("wines-x").isEmpty(), + equalTo(true) + ) + } + @Test fun `#delete updates index values so that they are always in sequence and start at 0`() { val repository = buildSubject()