capacitor-community / sqlite

Community plugin for native & electron SQLite databases
MIT License
426 stars 104 forks source link

Multi Value Statement error with spaces inbetween ? #550

Closed lasher23 closed 2 weeks ago

lasher23 commented 2 weeks ago

Describe the bug In the extractQuestionMarkValues the values is detected with a regex that allows spaces in between the question marks. image And if Values are found you replace all the whitespaces in between comma. image This does not work with the replace logic which on the other replaces the the values template (?, ?, ?) with the actual values. image

Example:

  1. Statement: insert into table values (?, ?)
  2. Then the regex matches and extractedSubstring result is the following: ?, ?
  3. Then the result is prefixed with brackets () and replace all the spaces resulting in (?,?)
  4. Then the statement.replace does not replace anything because the (?,?) is not found in insert into table values (?, ?)

Solution:

  1. The String from the Regex matching group should not be manipulated at all
  2. The matching group should include the opening and closing bracket ( ) the following regex would do the trick (?i)VALUES\s*(\(\s*\?(?:,\s*\?\s*)*\)) I will create a PR with this.

Smartphone (please complete the following information):

lasher23 commented 2 weeks ago

Sorry i saw it is fixed in Version 5.7.3-3