MonetDBSolutions / MonetDBe-Python

Embedded MonetDB with a Python frontend and fast Numpy/Pandas support
Mozilla Public License 2.0
61 stars 7 forks source link

MonetDBe stumble over ':' in the query string #127

Open ghost opened 3 years ago

ghost commented 3 years ago

Parsing error in handling a correct query

To Reproduce

import monetdbe

conn=  monetdbe.connect(':memory:')
cur = conn.cursor()
res= cur.execute("create table tmp(i integer, s string)")
res= cur.execute("insert into tmp values(123, 'hello''world'':\n ERROR');");
rows = res.fetchall()
print(rows)

raise ProgrammingError(f"unexpected symbol '{symbol}' in operation") monetdbe.exceptions.ProgrammingError: unexpected symbol ':' in operation

Expected behavior This is a normal query string that works on MonetDB

gijzelaerr commented 3 years ago

This is solved in the current master by switching to monetdbe engine style query preparation logic, but the python logic still has an issue with this. So I'm leaving this open so I can solve it on the python side for the next release.

gijzelaerr commented 3 years ago

comment from Sjoerd:

Officially, the only special character inside a single quote delimited string in SQL is a single quote, and you double it to get one single quote in your string. Similarly for double quote (for quoting identifiers). We currently also recognize \ in single-quoted strings, but shoudln't. You should use an E (e) prefix (like Python raw strings) to get backslash escapes. We also recognize the R (r) prefix which is similar to Python's, except a string can end with one backslash. And single quote is still special.