-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Query parameters with tabs or newlines can't be expressed #249
Labels
bug
Something isn't working
Comments
Thanks for the report; I will have a look. |
2 tasks
@michaelsmithxyz I added similar code as used in the tests to the example // (0.3.1+) It is also possible to bind parameters with special characters.
const resultSet2 = await client.query({
query: `
SELECT
'foo_\t_bar' = {tab: String} AS has_tab,
'foo_\n_bar' = {newline: String} AS has_newline,
'foo_\r_bar' = {carriage_return: String} AS has_carriage_return,
'foo_\\'_bar' = {single_quote: String} AS has_single_quote,
'foo_\\_bar' = {backslash: String} AS has_backslash`,
format: 'JSONEachRow',
query_params: {
tab: 'foo_\t_bar',
newline: 'foo_\n_bar',
carriage_return: 'foo_\r_bar',
single_quote: "foo_'_bar",
backslash: 'foo_\\_bar',
},
})
// Should return all 1, as query params will match the strings in the SELECT.
console.info('Result (special characters):', await resultSet2.json()) which now prints:
|
@slvrtrn Thanks for knocking this out so quickly! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
It seems like it's currently not possible to use the client to construct a query with string parameters containing tabs or newlines correctly. Newlines and tabs are a special case of the value format that's used to parse query parameters (as explained on this issue in the main repo). I believe the code in the client which handles escaping backslashes and quotes also needs to escape tab and newline literals.
It doesn't seem like you can work around this by escaping the query parameter values before providing them to the client, because the client then escapes the backslashes you're using to escape tabs and/or newlines, changing the value of the parameter you've provided.
Steps to reproduce
Here's a self-contained example that reproduces the issue:
Configuration
Environment
ClickHouse server
CREATE TABLE
statements for tables involved: See aboveThe text was updated successfully, but these errors were encountered: