Open brendonboshell opened 6 years ago
I'm not aware if this problem was solved in most recent versions but I'm facing this same issue when inserting escaped content (example: System File Paths).
Issue 1: Driver preserves js escaping when inserting content Expected behaviour: Don't preserve escaping.
Issue 2: Since drive preserves escaping. Each initial value is loaded from database as \\.
For example:
con.query('INSERT INTO T VALUES(?)', ['C:\\Program Files'].....
Using a DBMS to check the value, will reveal that value was not unespaced before being inserted. I would expect to see 'C:\Program Files' in my db field. Not 'C:\Program Files'
Then, If i pull that record from db. con.query('SELECT F FROM T',.....) // F will have the value of C:\\Program files
.... so on.
The only workaround I could found, for now, was to insert my text field as binary: Example:
let sql = `INSERT INTO T VALUES (X'${Buffer.from(data.ftpFolder).toString('hex')}'`
It seems that using the
Firebird.escape
function replaces each backslash (\
) with two backslash (\\
) characters, for example:However, this results in duplicate backslashes when inserted into the database. I am not too familiar with Firebird, but I understand we need to escape
'
as''
, but no escaping of backslashes is necessary.Relevant line in
escape
I am inclined to remove the escaping of
\
and send a PR, but please let me know if there is some reason for this.