Allow oneline comment in insert query#1693
Conversation
|
@luckyevildev thanks for the PR. I'm not sure if I understand the purpose of this change. The single line comment is already seems to be working with INSERTS. In fact all your tests (excluding the last one) already passes in the |
batch.go
Outdated
| ) | ||
|
|
||
| var normalizeInsertQueryMatch = regexp.MustCompile(`(?i)(INSERT\s+INTO\s+([^(]+)(?:\s*\([^()]*(?:\([^()]*\)[^()]*)*\))?)(?:\s*VALUES)?`) | ||
| var normalizeInsertQueryMatch = regexp.MustCompile(`(?i)(?:--[^\n]*\n\s*)*(INSERT\s+INTO\s+([^(]+)(?:\s*\([^()]*(?:\([^()]*\)[^()]*)*\))?)(?:\s*VALUES)?`) |
There was a problem hiding this comment.
ClickHouse supports also # and #! according to documentation - https://clickhouse.com/docs/sql-reference/syntax#comments
I have seen only once but have fixed in Java parser.
There was a problem hiding this comment.
Thanks, added support for #, #!
| { | ||
| name: "Insert with comment and backtick quoted names", | ||
| query: `-- Insert into special table | ||
| INSERT INTO ` + "`_test_1345# $.ДБ`.`2. Таблица №2`" + ` (col1, col2)`, |
There was a problem hiding this comment.
could you add tests for the comment in the middle and tail? see https://github.com/ClickHouse/clickhouse-rs/pull/267/files
|
@kavirajk
Without comment support, such queries were not parsed correctly. Supporting all three comment styles (--, #!, #) ensures compatibility with different SQL generators and tools. |
Summary
This PR adds support for SQL single-line comments before INSERT statements in batch operations. This enhancement improves compatibility with SQL tools and query builders that automatically add comments to generated queries.
Checklist
Delete items not relevant to your PR: