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

[ISSUE #12625] FIX tenant_capacity query SQL dialect #12628

Closed
wants to merge 9 commits into from

Conversation

fuhouyu
Copy link
Contributor

@fuhouyu fuhouyu commented Sep 9, 2024

Please do not create a Pull Request without creating an issue first.

What is the purpose of the change

resolves #12625 #12598

FIX tenant_capacity query SQL dialect

修复租户查询的SQL方言问题,在TrustedlFunctionEnum 中添加转义的字符返回,以便sql在出现关键字时的后续处理。

Brief changelog

XX

Verifying this change

XXXX

Follow this checklist to help us incorporate your contribution quickly and easily:

  • Make sure there is a Github issue filed for the change (usually before you start working on it). Trivial changes like typos do not require a Github issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
  • Format the pull request title like [ISSUE #123] Fix UnknownException when host config not exist. Each commit in the pull request should have a meaningful subject line and body.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit-test to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add integration-test in test module.
  • Run mvn -B clean package apache-rat:check findbugs:findbugs -Dmaven.test.skip=true to make sure basic checks pass. Run mvn clean install -DskipITs to make sure unit-test pass. Run mvn clean test-compile failsafe:integration-test to make sure integration-test pass.

@codecov-commenter
Copy link

codecov-commenter commented Sep 9, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 69.70%. Comparing base (3a9003b) to head (210b79c).

Files with missing lines Patch % Lines
...source/impl/mysql/TenantCapacityMapperByMySql.java 0.00% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             develop   #12628   +/-   ##
==========================================
  Coverage      69.70%   69.70%           
- Complexity      9431     9434    +3     
==========================================
  Files           1275     1275           
  Lines          41232    41234    +2     
  Branches        4374     4374           
==========================================
+ Hits           28740    28743    +3     
- Misses         10412    10413    +1     
+ Partials        2080     2078    -2     
Files with missing lines Coverage Δ
...service/capacity/TenantCapacityPersistService.java 81.88% <100.00%> (ø)
...source/impl/mysql/TenantCapacityMapperByMySql.java 71.42% <0.00%> (-28.58%) ⬇️

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3a9003b...210b79c. Read the comment docs.

@bes2008
Copy link

bes2008 commented Sep 11, 2024

看了你新提交的代码,要考虑如下问题:

有必要使用并行stream吗?
是否只影响 select 语句,insert, update 等是否受到影响。
对于select 语句,是否影响 where 子句

@fuhouyu
Copy link
Contributor Author

fuhouyu commented Sep 11, 2024

看了你新提交的代码,要考虑如下问题:

有必要使用并行stream吗? 是否只影响 select 语句,insert, update 等是否受到影响。 对于select 语句,是否影响 where 子句

感谢老师的review,没有考虑并行流的场景在这里并不合适。

然后我看了一下SELECT的影响范围,这个方法的父类只会是使用在SELECT 查询上面。

子类只是额外处理了这个columns,并没有操作where,对于整个查询是没有影响的。

或者是将这个方法挪到子类,这样就会减少一次循环处理,不知道这样是不是更好一点。

public class TenantCapacityMapperByMySql extends AbstractMapperByMysql implements TenantCapacityMapper {
@Override
    public String select(List<String> columns, List<String> where) {
        StringBuilder sql = new StringBuilder();
        String method = "SELECT ";
        sql.append(method);
        for (int i = 0; i < columns.size(); i++) {
            sql.append("`").append(columns.get(i)).append("`");
            if (i == columns.size() - 1) {
                sql.append(" ");
            } else {
                sql.append(",");
            }
        }
        sql.append("FROM ");
        sql.append(getTableName());
        sql.append(" ");

        if (CollectionUtils.isEmpty(where)) {
            return sql.toString();
        }

        appendWhereClause(where, sql);
        return sql.toString();
    }
}

@fuhouyu
Copy link
Contributor Author

fuhouyu commented Sep 16, 2024

有其它更好的解决方案PR

@fuhouyu fuhouyu closed this Sep 16, 2024
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.4.2 创建命名空间失败/数据库语法问题
3 participants