diff --git a/parser/sql/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/OracleStatementVisitor.java b/parser/sql/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/OracleStatementVisitor.java index 21715d6181eed..ca737d7d20cf2 100644 --- a/parser/sql/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/OracleStatementVisitor.java +++ b/parser/sql/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/OracleStatementVisitor.java @@ -637,7 +637,7 @@ public ASTNode visitPrivateExprOfDb(final PrivateExprOfDbContext ctx) { @Override public ASTNode visitIntervalExpression(final IntervalExpressionContext ctx) { IntervalExpressionProjection result = new IntervalExpressionProjection(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex(), (ExpressionSegment) visit(ctx.expr(0)), - (ExpressionSegment) visit(ctx.MINUS_()), (ExpressionSegment) visit(ctx.expr(1))); + (ExpressionSegment) visit(ctx.MINUS_()), (ExpressionSegment) visit(ctx.expr(1)), getOriginalText(ctx)); if (null != ctx.intervalDayToSecondExpression()) { result.setDayToSecondExpression((IntervalDayToSecondExpression) visit(ctx.intervalDayToSecondExpression())); } else { diff --git a/parser/sql/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/type/OracleDMLStatementVisitor.java b/parser/sql/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/type/OracleDMLStatementVisitor.java index 5f4f95df0beef..b6af08753fc70 100644 --- a/parser/sql/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/type/OracleDMLStatementVisitor.java +++ b/parser/sql/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/type/OracleDMLStatementVisitor.java @@ -842,7 +842,7 @@ private ASTNode createProjectionForExpressionSegment(final ASTNode projection, f if (projection instanceof IntervalExpressionProjection) { IntervalExpressionProjection intervalExpressionProjection = (IntervalExpressionProjection) projection; IntervalExpressionProjection result = new IntervalExpressionProjection(intervalExpressionProjection.getStartIndex(), intervalExpressionProjection.getStopIndex(), - intervalExpressionProjection.getLeft(), intervalExpressionProjection.getMinus(), intervalExpressionProjection.getRight()); + intervalExpressionProjection.getLeft(), intervalExpressionProjection.getMinus(), intervalExpressionProjection.getRight(), intervalExpressionProjection.getText()); if (null != intervalExpressionProjection.getDayToSecondExpression()) { result.setDayToSecondExpression(intervalExpressionProjection.getDayToSecondExpression()); } else { diff --git a/parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/segment/dml/item/IntervalExpressionProjection.java b/parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/segment/dml/item/IntervalExpressionProjection.java index 2360cb2ae8451..c1845736c4107 100644 --- a/parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/segment/dml/item/IntervalExpressionProjection.java +++ b/parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/segment/dml/item/IntervalExpressionProjection.java @@ -29,7 +29,6 @@ */ @RequiredArgsConstructor @Getter -@Setter public final class IntervalExpressionProjection implements ExpressionSegment, ProjectionSegment { private final int startIndex; @@ -42,6 +41,8 @@ public final class IntervalExpressionProjection implements ExpressionSegment, Pr private final ExpressionSegment right; + private final String expression; + @Setter private IntervalDayToSecondExpression dayToSecondExpression; @@ -50,7 +51,7 @@ public final class IntervalExpressionProjection implements ExpressionSegment, Pr @Override public String getText() { - return minus.getText(); + return expression; } @Override diff --git a/test/it/parser/src/main/resources/case/dml/insert.xml b/test/it/parser/src/main/resources/case/dml/insert.xml index 7c69aca33e2ff..224f5948cfd7b 100644 --- a/test/it/parser/src/main/resources/case/dml/insert.xml +++ b/test/it/parser/src/main/resources/case/dml/insert.xml @@ -2563,4 +2563,56 @@ + + + + + + + + + + + + + + + + + + + + + + + - + + + + + year + to + MONTH + + + + + + + + + - + + + + + DAY + TO + SECOND + + + + + + diff --git a/test/it/parser/src/main/resources/sql/supported/dml/insert.xml b/test/it/parser/src/main/resources/sql/supported/dml/insert.xml index d5ceb3b464c2e..f1eaa3eae3f89 100644 --- a/test/it/parser/src/main/resources/sql/supported/dml/insert.xml +++ b/test/it/parser/src/main/resources/sql/supported/dml/insert.xml @@ -95,4 +95,5 @@ +