Using @Upsert annotation of room2/room3 and SQLCipherDriver leads to UNIQUE constraint failed exception
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 32/100
- Tipo de issue
- Bug
- Clareza
- Razoavelmente clara
- Status de atividade
- Ativa
- Domínio
- databases, mobile, mobile-dev
Direção de pesquisa
Start from how SQLCipherDriver surfaces constraint failures versus SupportOpenHelperFactory/SupportSQLiteDriver. Room @Upsert expects androidx.sqlite.SQLiteException (and a uniqueness message) so it can fall back from INSERT to UPDATE; SQLCipher currently throws net.zetetic.database.sqlcipher.SQLiteConstraintException. Align exception type/message with Room’s catch (same class of issue as sqlcipher-android#23 and #84). Done when @Upsert succeeds with SQLCipherDriver on Room 2.x and 3 without UNIQUE constraint failed.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Library version used: 4.19.1
Room version used: 2.8.5 & 3.0.3
I'm currently upgrading to room3 and during the Prepare and modernize in Room 2.x part of the Android documentation I'm running into an runtime error.
At the stage Set the SQLite driver I'm doing it like your documentation says and pass a SQLCipherDriver to the databaseBuilder.
Using the @Upsert annotation (both in room2 and room3) now leads to an UNIQUE constraint failed exception at runtime. This also happens after a complete upgrade to room3.
This does not happen when using the room2 way with SupportOpenHelperFactory.
This is what Claude analyzed:
Room implements @Upsert as:
- try a plain INSERT (conflict strategy ABORT),
- catch the constraint exception, check it's a uniqueness violation,
- fall back to UPDATE.
Step 2 is the fragile part: it is a catch on a specific exception type plus a string match on the message. Room's driver-based adapter catches androidx.sqlite.SQLiteException.
SupportOpenHelperFactory went through Room's SupportSQLiteDriver wrapper, where the error surfaced in a form Room's fallback recognised, so step 3 ran and you never saw the error. SQLCipherDriver hands Room SQLCipher's own
net.zetetic.database.sqlcipher.SQLiteConstraintException instead (the (code 1555); query: … message format is zetetic's native formatter). That type is not androidx.sqlite.SQLiteException, so the catch never fires, the UPDATE
fallback is skipped, and the raw insert failure propagates to you.This is the same class of bug as sqlcipher-android#23 (https://github.com/sqlcipher/sqlcipher-android/issues/23) (@Upsert + SQLCipher) and robolectric#8469 (https://github.com/robolectric/robolectric/issues/8469) — any driver
that wraps SQLite errors in its own exception hierarchy breaks Room's upsert fallback. sqlcipher-android#84 (https://github.com/sqlcipher/sqlcipher-android/issues/84) tracks the broader Room 3 / SQLiteDriver migration gap.
- Linguagem predominante
- Java
- Estrelas
- 277
- Forks
- 39
- Merge médio
- 1d 11h
- PRs com merge (30d)
- 1
Preparar o ambiente
Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de sqlcipher/sqlcipher-android
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
sqlcipher/sqlcipher-android#97 · 1 comentário ·
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 32/100
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 45/100
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 30/100
sqlcipher/sqlcipher-android#23 · 2 comentários ·
Todas as issues de sqlcipher/sqlcipher-android
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 64/100
utopia-rise/godot-jvm#1004 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
resilience4j/resilience4j#2547 ·
Mantenedores costumam responder em até 9 dias
-
Clock.MakeDate continues execution and returns a rolled-over instant after dispatching error on invalid dateTalvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Aberta
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 82/100
mit-cml/appinventor-sources#4155 ·
Mantenedores costumam responder em até 1 dia
-
[Doc] - Creation du READMEAberta
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 62/100
Hira-shi/PW1-DAI-Carrel-Egal-Eyer#28 ·
Mantenedores costumam responder em até 1 dia
-
`GET /v1/event/token/{uuid}` can report a BOM upload as done before policy evaluation and metrics have finishedTalvez já em andamento @Zargath assumiu hoje. Abertadefect in triage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
DependencyTrack/dependency-track#7646 ·
Mantenedores costumam responder em até 1 dia