exportToJson fails when CREATE TABLE statement contains nested parentheses
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 68/100
Hướng nghiên cứu
Bắt đầu trong ExportToJson.java, ở quanh helper modEmbeddedParentheses() được exportToJson('full') sử dụng, và tái hiện lỗi bằng câu lệnh CREATE TABLE budgets được cung cấp, có chứa các dấu ngoặc lồng nhau và cùng cấp. Theo dõi các vị trí của dấu ngoặc mở và đóng đã thu thập; được xem là hoàn tất khi quá trình export Android hoàn thành thành công cho các schema này mà không có StringIndexOutOfBoundsException đã được báo cáo.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Plugin version:
capacitor-community/[email protected]
Platform(s):
Android
Current behavior:
exportToJson('full', false); fails when CREATE TABLE statement contains nested parentheses
e.g if this statements are used, export fails
CHECK (isDisabled IN (0, 1))
CHECK (endDate IS NULL OR date(endDate) >= date(startDate))
CHECK ( (isRecurring = 1 AND recurrenceIntervalType IS NOT NULL AND recurrenceIntervalValue IS NOT NULL) OR
(isRecurring = 0 AND recurrenceIntervalType IS NULL AND recurrenceIntervalValue IS NULL) ),
Changing those to those below works as workaround, export finishes:
CHECK (isDisabled = 0 OR isDisabled = 1)
CHECK (endDate IS NULL OR endDate >= startDate)
CHECK (isRecurring = 1 AND recurrenceIntervalType IS NOT NULL AND recurrenceIntervalValue IS NOT NULL
OR isRecurring = 0 AND recurrenceIntervalType IS NULL AND recurrenceIntervalValue IS NULL),
Exact error messages from android:
Error: exportToJson CreateExportObject: GetTablesFull: begin 919, end 831, length 1121
2026-04-28 23:41:51.380 8687-8752 com.getcap...RetHandler com.myapp.app V *** ERROR ExportToJson: ExportToJson CreateExportObject: GetTablesFull: begin 919, end 831, length 1121
2026-04-28 23:41:51.380 8687-8752 Capacitor com.myapp.app D Sending plugin error: {"save":false,"callbackId":"14032160","pluginId":"CapacitorSQLite","methodName":"exportToJson","success":false,"error":{"message":"ExportToJson: ExportToJson CreateExportObject: GetTablesFull: begin 919, end 831, length 1121"}}
2026-04-28 23:41:51.380 8687-8687 Capacitor/Console com.myapp.app E File: - Line 330 - Msg: [object Object]
2026-04-28 23:41:51.382 8687-8687 Capacitor/Console com.myapp.app E File: https://localhost/settings - Line 961 - Msg: Uncaught (in promise) Error: ExportToJson: ExportToJson CreateExportObject: GetTablesFull: begin 919, end 831, length 1121
Expected behavior:
Export completed without problems.
Steps to reproduce:
Run statement containing nested parentheses and run exportToJson('full')
`CREATE TABLE budgets
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
amount REAL NOT NULL,
startDate TEXT NOT NULL,
endDate TEXT NULL,
isRecurring BOOLEAN NOT NULL DEFAULT 0,
recurrenceIntervalType TEXT NULL,
recurrenceIntervalValue INTEGER NULL,
warnNotifThresholdPercent INTEGER NOT NULL DEFAULT 80,
CHECK (isRecurring IN (0, 1)),
CHECK ( (isRecurring = 1 AND recurrenceIntervalType IS NOT NULL AND recurrenceIntervalValue IS NOT NULL) OR
(isRecurring = 0 AND recurrenceIntervalType IS NULL AND recurrenceIntervalValue IS NULL) ),
CHECK (recurrenceIntervalType IN ('days', 'weeks', 'months', 'years') OR recurrenceIntervalType IS NULL),
CHECK (endDate IS NULL OR date(endDate) >= date(startDate))
);`
Other information:
Claude sonnet analysis of the problem:
The Android plugin's modEmbeddedParentheses() helper in ExportToJson.java iterates through the ( and ) positions it collected from the CREATE TABLE body. When it detects a nested pair (oPars[i+1] < cPars[i]), it advances i inside the loop and the loop advances it again, putting it out of sync. It then tries to fill the "gap" between the two inner groups with substring(cPars[i], oPars[i+1]-1).
For CHECK ( (expr_A) OR (expr_B) ) the inner i points to the close of expr_B (later in string) while i+1 points to the open of expr_B (earlier in string) → begin > end → StringIndexOutOfBoundsException: begin 919, end 831, length 1121.
Or from other prompt
The crash comes from ExportToJson.java (line ~290) inside the modEmbeddedParentheses() helper, which is called for every CREATE TABLE schema during exportToJson('full').
The helper collects all ( positions into oPars and all ) positions into cPars and then tries to pair them up in a single loop. The pairing logic has a flaw: when a table has sibling nested parentheses — i.e., two (or more) inner groups at the same depth — it advances i inside the loop body and outside it, so the "gap between groups" substring is computed as substring(cPars[i], oPars[i+1] - 1) where cPars[i] ends up greater than oPars[i+1] - 1. That triggers Java's StringIndexOutOfBoundsException: begin N, end M, length L.
Capacitor doctor:
💊 Capacitor Doctor 💊
Latest Dependencies:
@capacitor/cli: 8.3.1
@capacitor/core: 8.3.1
@capacitor/android: 8.3.1
@capacitor/ios: 8.3.1
Installed Dependencies:
@capacitor/ios: not installed
@capacitor/cli: 8.3.1
@capacitor/core: 8.3.1
@capacitor/android: 8.3.1
[success] Android looking great! 👌
- Ngôn ngữ chính
- Swift
- Star
- 661
- Fork
- 158
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của capacitor-community/sqlite
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
capacitor-community/sqlite#700 · 1 bình luận · 1 reaction ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
capacitor-community/sqlite#693 · 7 reaction ·
-
feature needs: triage
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
capacitor-community/sqlite#689 ·
-
bug/fix needs: triage
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
capacitor-community/sqlite#685 ·
-
bug/fix needs: triage
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 48/100
capacitor-community/sqlite#671 ·
Tất cả issue của capacitor-community/sqlite
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
EtanHey/brainlayer#984 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
hoiekim/turnip-ios#197 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
clawsweeper:needs-maintainer-review clawsweeper:needs-product-decision clawsweeper:no-new-fix-pr clawsweeper:source-repro impact:other issue-rating: 🦞 diamond lobster P2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
steipete/CodexBar#4071 · 1 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
gingerbeardman/Katana#15 ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
Maintainer thường phản hồi trong vòng 1 ngày