Skip to content

Enhance SQL parsing for UNIQUE constraints and add split_sql_statements - #258

Merged
bakwc merged 5 commits into
bakwc:masterfrom
liuhuo23:master
Jun 24, 2026
Merged

Enhance SQL parsing for UNIQUE constraints and add split_sql_statements#258
bakwc merged 5 commits into
bakwc:masterfrom
liuhuo23:master

Conversation

@liuhuo23

Copy link
Copy Markdown
Contributor

Fix: bug
eg: ALTER TABLE backflow_sample_set ADD COLUMN file_path VARCHAR(255) COMMENT '文件路径; 上传文件的存储路径. 上传完毕才会有值'

Copilot AI review requested due to automatic review settings April 15, 2026 09:11
@liuhuo23

Copy link
Copy Markdown
Contributor Author

您好, 还请您花费一点时间审核一下我刚才提的这个pr, 核心是修复这种情况
ALTER TABLE backflow_sample_set ADD COLUMN file_path VARCHAR(255) COMMENT '文件路径; 上传文件的存储路径. 上传完毕才会有值' 这种情况。

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves MySQL DDL query validation by correctly handling semicolons that appear inside quoted strings (e.g., within COMMENT '...'), preventing false “multi-query” rejections.

Changes:

  • Added split_sql_statements(sql) to split semicolon-separated SQL while ignoring semicolons inside ', ", and ` quotes.
  • Updated MysqlToClickhouseConverter.__basic_validate_query() to use split_sql_statements() instead of a naive find(';') check.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +713 to +716
# Use split_sql_statements to correctly ignore semicolons inside quoted strings
# (e.g. semicolons inside COMMENT '...' clauses are not statement separators)
if len(split_sql_statements(mysql_query)) > 1:
print(f'warning: multi-query statement detected, query: {mysql_query}')

Copilot AI Apr 15, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add/adjust tests to cover the new multi-statement detection behavior: an ALTER TABLE with a COMMENT string containing a semicolon (e.g. the example in the PR description) should be accepted, while true multi-statement input like "ALTER ...; DROP ..." should still raise. This change is safety-critical because __basic_validate_query now relies on split_sql_statements for correctness.

Copilot uses AI. Check for mistakes.
…identifying non-optimizable table engines and updating database selection logic
@bakwc
bakwc merged commit a841a57 into bakwc:master Jun 24, 2026
1 check passed
@bakwc

bakwc commented Jun 24, 2026

Copy link
Copy Markdown
Owner

Sorry for long review. Thanks a lot for contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants