ClickHouse / ClickHouse/clickhouse-java

[jdbc-v2] JDBC Escaping

Open
#2,352 1 comment 1 reaction 0 assignees View on GitHub
area:jdbc-insert bug jdbc-v2
Dominant language
Java
Stars
1.6k
Forks
636
Avg merge
2d 23h
Merged PRs (30d)
29

Description

### Description
JDBC escaping allows to write portable (really not) SQL statements that can be run with different JDBC drivers to get same affect. For example, `{ts 2025-02-20}` should be interpreted by driver as native function like `toTimestamp()` and other drivers should do similar way.

Current JDBC implementation
- does escaping always but should be controlled by `com.clickhouse.jdbc.StatementImpl#setEscapeProcessing`
- should be true for both Statement and PreparedStatement with according tests
- lacks of documentation https://clickhouse.com/docs/integrations/language-clients/java/jdbc
- done after prepared statement is parsed but should before (to not confuse parser :-))

There is a good explanation of how JDBC escaping works https://jdbc.postgresql.org/documentation/escapes/.

Contributor guide

Open the contributing guide

Research direction

Start with com.clickhouse.jdbc.StatementImpl#setEscapeProcessing and trace how escaping is applied relative to prepared-statement parsing. Review the JDBC escaping explanation and the JDBC integration documentation, then add coverage for both Statement and PreparedStatement. Done means escaping is configurable, enabled for both statement types, and documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.