Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

bug: Plugin fails to parse modern SQL syntax including CTEs and ON CONFLICT clauses.

Aperta
#670 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

@xEverth ci sta già lavorando.

Dal 29/11/2025.

  • #672 di @xEverth — aperta

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
38/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
android, java, sql, sqlite

Direzione di ricerca

Inizia riproducendo il problema tramite execute o executeSet con gli esempi INSERT/UPSERT e CTE. Leggi i percorsi di parsing pertinenti in android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/Database.java e UtilsSQLStatement.java. Il lavoro è completato quando RETURNING viene rimosso senza troncare le espressioni ON CONFLICT né eliminare le definizioni CTE, mantenendo la compatibilità con i dispositivi meno recenti.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug/fix needs: triage

Plugin version:
7.0.2

Platform(s):
Android, Web

Current behavior:

  1. When an INSERT or UPSERT statement contains an ON CONFLICT clause with its own parenthesized expressions (e.g. conflict targets or column-name-lists), the plugin incorrectly splits the statement when detecting RETURNING.
    For example a valid statement like:
INSERT INTO table (col1, col2) VALUES (1,2), (3,4)
ON CONFLICT (col1) DO UPDATE SET col2 = 0
RETURNING *;

is transformed into the invalid

INSERT INTO table (col1, col2) VALUES (1,2), (3,4) 
ON CONFLICT (col1);
  1. The Common Table Expression used for "UPDATE" or "DELETE" is ignored by the getUpdDelReturnedValues and the resulting statement may be invalid.
    An update statement with a CTE like WITH new_data (col1, col2) AS ( VALUES (1,2),(3,4),(5,6) ) SELECT * FROM table WHERE col1 IN (SELECT col1 FROM new_data); would become SELECT (col1, col2) FROM table WHERE col1 IN (SELECT col1 FROM new_data); with the CTE definition missing.

Expected behavior:
Since the returning clause is always last in the grammar for the statements INSERT, UPDATE and DELETE, the parsing should just remove the associated part. I understand that the altering of the statement is performed in order to maintain retro-compatibility with older devices running older versions of SQLite, although it was not immediately clear to me while debugging the issue that this was happening behind the scenes.
Resources:

Steps to reproduce:
Run a query like the above using the plugin methods "execute" or "executeSet", observe the error in response.

Related code:
The methods responsible for this behaviour are in the Java implementation:
android\src\main\java\com\getcapacitor\community\database\sqlite\SQLite\Database.java and
android\src\main\java\com\getcapacitor\community\database\sqlite\SQLite\UtilsSQLStatement.java

Other information:
The issue has been isolated, verified and debugged in Android Studio. An attempt for a resolution will be shown in an associated draft PR.

Capacitor doctor:

   Capacitor Doctor   

Latest Dependencies:

  @capacitor/cli: 7.4.4
  @capacitor/core: 7.4.4
  @capacitor/android: 7.4.4
  @capacitor/ios: 7.4.4

Installed Dependencies:

  @capacitor/core: 7.4.3
  @capacitor/android: 7.4.3
  @capacitor/ios: 7.4.3
  @capacitor/cli: 7.4.3

[success] Android looking great! 👌
[error] Xcode is not installed
Lingua principale
Swift
Stelle
664
Fork
159
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di capacitor-community/sqlite

Tutte le issue di capacitor-community/sqlite

Issue simili

Altre issue su Swift

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.