Skip to content

Entering an apostrophe leads to a SQL Execution error on SQL Server. #929

Closed
@chstorb

Description

@chstorb

QueryBuilder replaces an apostrophe in a string with a backslash(es) followed by an apostrophe.

This leads to a SQL execution error in a SQL Server query.

Instead, SQL Server requires a double apostrophe.

Steps to Reproduce:

  1. Open the demo page https://querybuilder.js.org/demo.html and go to the last section "Import/Export".
  2. Add a "contains" rule for a field "name" and enter the value "D'Artagnan".
  3. Click the button "SQL".
  4. Copy the resulting SQL condition name LIKE ('% D \\' Artagnan% ') and use the condition in a sql statement like this:

SELECT * FROM [Musketeers] WHERE [name] LIKE ('% D \\' Artagnan% ')

  1. Running this query on SQL Server results in the following error:

Execution failed due to an unexpected error:
SQL Execution error: A fatal error occurred.
Incorrect syntax was encountered while [Statement] LIKE ('% D \' Artagnan% ') was being parsed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions