Fix SQL parsing for RETURNING + Correct value handling in executeSet (Issues #670 and #671)#672
Draft
xEverth wants to merge 3 commits intocapacitor-community:masterfrom
Draft
Fix SQL parsing for RETURNING + Correct value handling in executeSet (Issues #670 and #671)#672xEverth wants to merge 3 commits intocapacitor-community:masterfrom
xEverth wants to merge 3 commits intocapacitor-community:masterfrom
Conversation
added 3 commits
November 26, 2025 00:50
account for INSERT statements w/ ON CONFLICT clauses with parentheses Previously the stmt for insert was being split at the last closing parenthesis, leaving unvalid statements in some circumstances. Unified the logic for INSERT, UPDATE and DELETE statements as per docs (the "returning-clause" has the same syntax for all of them). Removed extra if branch for retMode in prepareSQL (it was always taking a path whether retMode started with "no" or not) Added utils to parse Common Table Expressions Using the util to get statement type Using the same CTE in the getUpdDelReturnedValues if "returning" Added utils to parse Common Table Expressions Using the util to get statement type Using the same CTE in the getUpdDelReturnedValues if "returning"
replacePlaceholders is now redundant getUpdDelReturnedValues accepts the bindingValues
… database It previously got the last row id from any table of the DB, depending on which insert happened last Changes the function to retrieve inserted values
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This Draft Pull Request proposes fixes for multiple issues in the plugin’s SQL parsing and statement preparation logic in the Java/Android implementation.
The goal is to align behavior with SQLite grammar, ensure correctness when handling RETURNING clauses, and eliminate string-based parameter substitution that causes data corruption in multi-row inserts.
This PR is not ready for merging — it is intended to gather feedback and align on the expected behavior before finalizing the implementation. The code has been linted, formatted and verified (verified:android) using the npm scripts in the package.json. I would be glad to implement the same changes with a parallel PR on the repo https://github.com/jepiqueau/jeep-sqlite/tree/master which shares the same API, but I am currently unable to test these changes on iOS.
Fixes Included
BETWEEN a AND bwith b<a, resulting in an error.Rationale
SQLite’s grammar guarantees that RETURNING appears last, so parsing should only modify that clause.
Manual string substitution cannot safely reproduce SQLite’s parameter binding behavior, especially with complex string data.
Aligning the behavior across Android and Web improves consistency and reduces surprising behavior for end users.
Fixes #670 and fixes #671 on Android (API 26 and up). May also resolve #605 but can't say for sure without additional information from the submitter.