@capacitor-community/sqlite 6.0.0-beta.1 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -538,9 +538,21 @@ public class Database {
538
538
  if (extractedValues == null) {
539
539
  return stmt; // Return the original statement if no placeholders are found
540
540
  }
541
+ // Regex to match the VALUES clause with varying number of placeholders
542
+ String regex = "(?i)VALUES\\s*\\((\\s*\\?\\s*(?:,\\s*\\?\\s*)*)\\)";
541
543
 
542
- // Replace placeholders in the stmt with values from sqlBuilder
543
- return stmt.replaceFirst("(?i)VALUES \\((\\?(?:,\\s*\\?\\s*)*)\\)", "VALUES " + sqlBuilder);
544
+ // Create a pattern and matcher
545
+ Pattern pattern = Pattern.compile(regex);
546
+ Matcher matcher = pattern.matcher(stmt);
547
+
548
+ // Check if the pattern matches and perform the replacement
549
+ if (matcher.find()) {
550
+ // Perform the replacement without causing an IndexOutOfBoundsException
551
+ String formattedStmt = matcher.replaceAll("VALUES " + Matcher.quoteReplacement(sqlBuilder));
552
+ return formattedStmt;
553
+ } else {
554
+ throw new IllegalArgumentException("The statement does not contain a valid VALUES clause with placeholders.");
555
+ }
544
556
  }
545
557
 
546
558
  public String extractQuestionMarkValues(String input) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor-community/sqlite",
3
- "version": "6.0.0-beta.1",
3
+ "version": "6.0.0",
4
4
  "description": "Community plugin for native & electron SQLite databases",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",