bug: Plugin fails to parse modern SQL syntax including CTEs and ON CONFLICT clauses.
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 38/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 領域
- database, mobile-dev
調査の方向性
まず、INSERT/UPSERT と CTE の例を使って execute または executeSet 経由で問題を再現します。android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/Database.java と UtilsSQLStatement.java の関連するパース経路を読みます。ON CONFLICT 式を切り詰めたり CTE 定義を削除したりすることなく RETURNING が除去され、かつ古いデバイスとの互換性が維持されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Plugin version:
7.0.2
Platform(s):
Android, Web
Current behavior:
- 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);
- 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 likeWITH new_data (col1, col2) AS ( VALUES (1,2),(3,4),(5,6) ) SELECT * FROM table WHERE col1 IN (SELECT col1 FROM new_data);would becomeSELECT (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:
- https://sqlite.org/syntax/insert-stmt.html
- https://sqlite.org/syntax/upsert-clause.html
- https://sqlite.org/syntax/update-stmt.html
- https://sqlite.org/lang_delete.html
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 はありません
環境構築
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
capacitor-community/sqlite のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
capacitor-community/sqlite#700 · コメント 1 件 · リアクション 1 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
capacitor-community/sqlite#693 · リアクション 7 件 ·
-
bug/fix needs: triage
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
capacitor-community/sqlite#690 ·
-
feature needs: triage
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
capacitor-community/sqlite#689 ·
-
bug/fix needs: triage
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
capacitor-community/sqlite#685 ·
capacitor-community/sqlite の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
area:dictation bug P2
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
uttrflow/uttrflow-swift#2721 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
[@capacitor/app] iOS: 'Expression implicitly coerced from String? to Any' warning in getAppLanguageオープンtriage
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
ionic-team/capacitor-plugins#2604 ·
-
auth type: bug
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100
googleapis/google-cloud-swift#1260 ·
メンテナーはふだん 1 日以内に返信
-
catalog-audit
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信