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

[BUG] SQLUtils.refactor表名改写错误 #6119

Open
Jin-2019 opened this issue Aug 26, 2024 · 1 comment
Open

[BUG] SQLUtils.refactor表名改写错误 #6119

Jin-2019 opened this issue Aug 26, 2024 · 1 comment

Comments

@Jin-2019
Copy link

Jin-2019 commented Aug 26, 2024

Database Type

MySQL

Database Version

MySQL

Druid Version

1.2.23

JDK Version

JDK 8

Error SQL

select db_a.tbl_b.col_c from db_a.tbl_b

Testcase Code

public void testRenameTable() {
    Map<String, String> tableMapping = Collections.singletonMap("tbl_b", "xxx");
    String sql = "select db_a.tbl_b.col_c from db_a.tbl_b";
    String out =  SQLUtils.refactor(sql, DbType.mysql,tableMapping);
    System.out.println("input: "+ sql);
    System.out.println("out: "+ out);
}

Stacktrace Info

No response

Error Info

改写表名tbl_b为xxx,在select item中的表名未被正确改写。

input: select db_a.tbl_b.col_c from db_a.tbl_b
out: SELECT db_a.tbl_b.col_c FROM db_a.xxx

补充

另一个case,当select的查询列中使用 'user_extra.col+1 '表名无法被正确替换

select user_extra.col+1 from user_extra 
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

No branches or pull requests

2 participants
@Jin-2019 and others