-
Notifications
You must be signed in to change notification settings - Fork 562
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
Parser cannot parse backslashed value #695
Comments
Hi @rubtsovnyu, was this working before? The SQL is invalid - perhaps you meant something like // values is a byte array
StringBuilder sql = new StringBuilder("select * from t where col in (");
for (byte b : values) {
sql.append(",?");
}
if (sql.length() > 0) {
sql.deleteCharAt(0);
} else {
throw new IllegalArgumentException("at least one input is required");
}
sql.insert(0, "select * from t where col in (").append(')');
try (PreparedStatement ps = connection.preparedStatement(sql.toString())) {
for(int i = 0; i< values.length; i++) {
ps.setInt(i + 1, values[i]);
}
ps.execute...
} |
|
Reproducing snippet: CREATE TABLE t
(
col_1 Array(Int8)
) ENGINE = Memory;
INSERT INTO t
VALUES ([1,2,3,4]); String url = "jdbc:clickhouse://127.0.0.1:8123";
ClickHouseDataSource dataSource = new ClickHouseDataSource(url);
ClickHouseConnection connection = dataSource.getConnection();
PreparedStatement prepareStatement = connection.prepareStatement("SELECT * FROM t WHERE col_1 IN (?)");
prepareStatement.setObject(1, new byte[]{1,2,3,4});
ResultSet resultSet = prepareStatement.executeQuery(); |
Thanks for the clarification. I added a unit test which can reproduce the issue even use This was introduced in commit 3be7a3c, but before I roll it back, I need some time to digest what that was for. |
I didn't change code as it will be removed in 0.4.0. The issue should not exist in the new driver(com.clickhouse.jdbc.ClickHouseDriver). |
Trying to execute query like this:
and using
preparedStatement.setObject(1, [some byte array])
.So the resulting sql looks like
and then parser is failing with an exception:
Failed to parse the given SQL. If you believe the SQL is valid, please feel free to open an issue on Github with the following SQL and exception attached.
The text was updated successfully, but these errors were encountered: