You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
we are working with JSON data and calling function such as jsonMergePatch(). Example:
SELECT jsonMergePatch('{"test":' || test_value || '}') FROM some_table WHERE id = ?
The query has a query parameter. The problem is that this query fails with error described as "expected string value in NamedValue for query parameter". While looking into the code we have discovered that there is some magic regular expression which tries to detect named query arguments in the file https://github.com/ClickHouse/clickhouse-go/blob/main/query_parameters.go#L30C2-L30C18.
hasQueryParamsRe = regexp.MustCompile("{.+:.+}")
We found that the regex does not hit when the query is multiline so we managed to run it successfully by putting closing bracket on the next line:
SELECT jsonMergePatch('{"test":' || test_value ||
'}') FROM some_table WHERE id = ?
We would like to ask you how we should approach? Is it a bug in the regular expression or we shall run the query somehow differently?
Note that we are not using NamedValue, the query parameter is put to the Query(query, args...) just as a common Go variable.
Thanks.
The text was updated successfully, but these errors were encountered:
Hey! Thanks for submitting this issue. I agree with your findings that this is likely a problem with the regex.
I want to understand this query better so I can reproduce the error and try to find a workaround. Can you provide an anonymized snippet of code as well as the table you're using? Is test_value a column?
Hello,
we are working with JSON data and calling function such as jsonMergePatch(). Example:
SELECT jsonMergePatch('{"test":' || test_value || '}') FROM some_table WHERE id = ?
The query has a query parameter. The problem is that this query fails with error described as "expected string value in NamedValue for query parameter". While looking into the code we have discovered that there is some magic regular expression which tries to detect named query arguments in the file https://github.com/ClickHouse/clickhouse-go/blob/main/query_parameters.go#L30C2-L30C18.
hasQueryParamsRe = regexp.MustCompile("{.+:.+}")
We found that the regex does not hit when the query is multiline so we managed to run it successfully by putting closing bracket on the next line:
We would like to ask you how we should approach? Is it a bug in the regular expression or we shall run the query somehow differently?
Note that we are not using NamedValue, the query parameter is put to the Query(query, args...) just as a common Go variable.
Thanks.
The text was updated successfully, but these errors were encountered: