Skip to content

Fix escaped backslash at end of string literal preventing string closure - #41

Open
callumwalker wants to merge 1 commit into
mariadb-corporation:1.1from
callumwalker:1.1
Open

callumwalker wants to merge 1 commit into
mariadb-corporation:1.1from
callumwalker:1.1

Conversation

@callumwalker

Copy link
Copy Markdown

If a string literal ended with an escaped backslash that was being interpreted as an escaped quote preventing the string from ending. If the next string contained a ? or %s that was then treated as a parameter and a traceback was raised as the number of parameters in the statement didn't match the number supplied.

import mariadb

conn = mariadb.connect(user='root', database='db')
cursor = conn.cursor()

cursor.execute(r"INSERT INTO result VALUES (1, '\\', '?')")
Traceback (most recent call last):
  File "sql.py", line 6, in <module>
    cursor.execute(r"INSERT INTO result VALUES (1, '\\', '?')")
  File ".venv/lib64/python3.12/site-packages/mariadb/cursors.py", line 318, in execute
    self._parse_execute(statement, (data))
  File ".venv/lib64/python3.12/site-packages/mariadb/cursors.py", line 258, in _parse_execute
    self._check_execute_params()
  File ".venv/lib64/python3.12/site-packages/mariadb/cursors.py", line 195, in _check_execute_params
    raise mariadb.ProgrammingError(
mariadb.ProgrammingError: statement (1) doesn't match the number of data elements (0).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant