Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン
#670 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
38/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
android, java, sql, sqlite

調査の方向性

まず、INSERT/UPSERT と CTE の例を使って execute または executeSet 経由で問題を再現します。android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/Database.java と UtilsSQLStatement.java の関連するパース経路を読みます。ON CONFLICT 式を切り詰めたり CTE 定義を削除したりすることなく RETURNING が除去され、かつ古いデバイスとの互換性が維持されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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
主要言語
Swift
スター
661
フォーク
158
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

capacitor-community/sqlite のほかの issue

capacitor-community/sqlite の issue をすべて見る

似ている issue

Swift の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。