Skip to content
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

fix: method of optimizer #1964

Closed
wants to merge 2 commits into from
Closed

fix: method of optimizer #1964

wants to merge 2 commits into from

Conversation

winfredLIN
Copy link
Collaborator

#1955

功能描述

这个方法的功能是解析Select语句中的表,然后放到Optimizer的tables中去
有两种情况:

  1. 当Select语句中的表是单表,即非JOIN多表的情形,将对应Select语句放到tables中,如果表有别名,则要将别名也存一份,共两份
  2. 当Select语句中的表是JOIN的多表,将表参与连接的列存储到tables中,但不存储Select语句

解决三个问题:

  1. 对Using的支持不好,没判断空指针,导致panic
  2. 获取ON两边的列不达预期,当存在多个表JOIN,并且ON的相同表有两个以上时,只保存最后一个,例如:JOIN .. ON t1.id = t2.id JOIN .. ON t2.name = t3.name 这时候t2保存的列是name 没有id
  3. 不支持多JOIN嵌套

IndexedColumns: []string{o.tables[tbl].joinOnColumn},
Reason: fmt.Sprintf("字段 %s 为被驱动表 %s 上的关联字段", o.tables[tbl].joinOnColumn, tbl),
IndexedColumns: indexColumns,
Reason: fmt.Sprintf("字段 %s 为被驱动表 %s 上的关联字段", indexColumns, tbl),
Copy link
Member

Choose a reason for hiding this comment

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

使用%s format []string 最终打印的格式是什么样的

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

对于字符串切片indexColumns:=[]string{column_1,column_2,column_3}
使用%s format []string 最终打印的格式是:[column_1 column_2 column_3]

Copy link
Member

Choose a reason for hiding this comment

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

建议使用string 的 join 手工格式一下

@winfredLIN winfredLIN closed this Nov 8, 2023
@winfredLIN winfredLIN deleted the issue1955 branch November 29, 2023 07:11
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.

2 participants