Repository navigation
fix: 结果操作生成 SQL 时限定表名重复拼接 schema - #440
Merged
Merged
Conversation
查询 SQL 带模式名时,SQL 分析给出的表名是 schema.table 拼接形式, 结果操作(复制为 INSERT/UPDATE/DELETE)再拼一次 schema 会生成 schema.schema.table 重复引用导致执行报错。 format_copy_table_name 现在识别限定表名:限定名按段引用后直接使用, 裸表名才拼 schema 前缀,与保存路径 format_resolved_table_reference 的语义对齐。 Closes #400
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
查询 SQL 带模式名(如
SELECT * FROM ads.ads_tb_x)时,结果操作(复制为 INSERT / UPDATE / DELETE)生成的 SQL 出现模式名重复(ads.ads.ads_tb_x),执行报错。Closes #400根因
SQL 结果网格的表名来自查询分析(
direct_table_identity),是schema.table拼接形式。结果操作的CopySqlRequest同时携带:table=ads.ads_tb_x(已含前缀)schema=ads(连接/执行上下文的 schema)而
format_copy_table_name无脑拼接schema.table,得到ads.ads.ads_tb_x。保存路径(
format_resolved_table_reference)此前已修复过同类问题(限定名按段引用,不再拼前缀),复制路径漏掉了同样的处理。修复
format_copy_table_name识别限定表名:.)→ 按.拆开逐段引用,直接使用("ads"."ads_tb_x")与保存路径
format_resolved_table_reference语义对齐。验证
copy_sql_qualified_table_name_is_not_prefixed_twice(限定名不重复拼 schema)copy_sql_bare_table_name_keeps_schema_prefix(裸表名仍拼 schema)cargo test -p db全量 1322 测试通过cargo clippy -p db --all-targets无新增告警