@capacitor-community/sqlite 6.0.0-beta.1 → 6.0.0-beta.2
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.
package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/Database.java
CHANGED
|
@@ -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
|
-
//
|
|
543
|
-
|
|
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