You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by su...@apache.org on 2024/08/26 10:36:23 UTC
(shardingsphere) branch master updated: Fix sonar issue on MySQLStatementVisitor (#32682)
This is an automated email from the ASF dual-hosted git repository.
sunnianjun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new ed874ac0b42 Fix sonar issue on MySQLStatementVisitor (#32682)
ed874ac0b42 is described below
commit ed874ac0b42b6510d66b69a2cfbd9e4a6dfb139a
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Mon Aug 26 18:36:17 2024 +0800
Fix sonar issue on MySQLStatementVisitor (#32682)
---
.../sql/parser/mysql/visitor/statement/MySQLStatementVisitor.java | 6 +++---
.../sql/parser/statement/core/segment/dml/expr/FunctionSegment.java | 4 ++--
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/parser/sql/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/MySQLStatementVisitor.java b/parser/sql/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/MySQLStatementVisitor.java
index 5a230c4d746..5bc545ea464 100644
--- a/parser/sql/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/MySQLStatementVisitor.java
+++ b/parser/sql/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/MySQLStatementVisitor.java
@@ -1098,9 +1098,9 @@ public abstract class MySQLStatementVisitor extends MySQLStatementBaseVisitor<AS
@Override
public final ASTNode visitSubstringFunction(final SubstringFunctionContext ctx) {
- FunctionSegment result = new FunctionSegment(
- ctx.getStart().getStartIndex(),
- ctx.getStop().getStopIndex(), null == ctx.SUBSTR() ? null == ctx.SUBSTRING() ? ctx.MID().getText() : ctx.SUBSTRING().getText() : ctx.SUBSTR().getText(), getOriginalText(ctx));
+ String substringFunctionName = null == ctx.SUBSTRING() ? ctx.MID().getText() : ctx.SUBSTRING().getText();
+ String functionName = null == ctx.SUBSTR() ? substringFunctionName : ctx.SUBSTR().getText();
+ FunctionSegment result = new FunctionSegment(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex(), functionName, getOriginalText(ctx));
result.getParameters().add((ExpressionSegment) visit(ctx.expr()));
for (TerminalNode each : ctx.NUMBER_()) {
result.getParameters().add(new LiteralExpressionSegment(each.getSymbol().getStartIndex(), each.getSymbol().getStopIndex(), new NumberLiteralValue(each.getText()).getValue()));
diff --git a/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/segment/dml/expr/FunctionSegment.java b/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/segment/dml/expr/FunctionSegment.java
index d455c2b8b72..8cdec556146 100644
--- a/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/segment/dml/expr/FunctionSegment.java
+++ b/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/segment/dml/expr/FunctionSegment.java
@@ -40,10 +40,10 @@ public final class FunctionSegment implements ComplexExpressionSegment {
private final String functionName;
- private final Collection<ExpressionSegment> parameters = new LinkedList<>();
-
private final String text;
+ private final Collection<ExpressionSegment> parameters = new LinkedList<>();
+
@Setter
private OwnerSegment owner;