Closed bhaskarvk closed 7 years ago
Looks like a problem with .bindParameters
function @ https://github.com/hannesmuehleisen/MonetDBLite/blob/9f2e060558a0bfa119087aeb476c5441f66cc248/R/dbi.R#L611
MonetDBLite:::.bindParameters("INSERT INTO foo VALUES(?,?,?)", list(1, "foo?", "bar"))
gives
[1] "INSERT INTO foo VALUES(1,'foo'bar'',?)"
good catch! Will fix by using new DBI code that should do it.
BTW just found out that in monetDB double quotes are used for parameters and single quotes for strings. It's not documented clearly anywhere but I found it mentioned in mailing list discussions.
So
dbSendUpdate(con, "INSERT INTO foo VALUES(3, \"foo?\", \"bar\")") #FAILS
# BUT
dbSendUpdate(con, "INSERT INTO foo VALUES(3, 'foo?', 'bar')") # WORKS CORRECTLY
# So I tried putting single quotes around the ?, but that fails too due to the handling of .bindParameters
dbSendUpdate(con, "INSERT INTO foo VALUES(?,'?','?')", 2, "foo?", "bar") # ERROR
you are not supposed to quote placeholders in general, but otherwise, yes. 'strings' and "identifiers" in MonetDB
Agreed! I was just experimenting.
Reproducible code
Errors on the two statements that fail
Looks like having a '?' in a string causes it to be treated as a parameter. So how do we insert data that actually has '?' in it ?