Skip to content

No need to escape double quotes when wrapped in single quotes #40

Closed

Description

@kadishmal
var sql = 'INSERT INTO tbl (str) VALUES (?)';

conn.execute(sql, ['logLevel:"ERROR"'], cb);

In the above case when the query parameter value includes double quotes, node-cubrid escapes them, so the final value that gets inserted is logLevel:""ERROR"" where each double quote is escaped with another double quote. On read the value of str column will be logLevel:""ERROR"" which is not what the user expects.

When placing parameters into the placeholders we should check if the delimiter is the same as the quote. The default delimiter is a single quote which means that when a string is wrapped in single quotes, no need to escape the double quotes in the string.

The opposite is true, too, i.e. when a string that includes a single quote but wrapped in double quote, single quotes should not be escaped.

Activity

  1. self-assigned this
    on Mar 17, 2015
  2. added this to the 2.2.3 milestone on Mar 17, 2015
  3. added a commit that references this issue on Mar 17, 2015
  4. added a commit that references this issue on Mar 17, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions