This is an automated email from the ASF dual-hosted git repository. iamhucong pushed a commit to branch fix-encrypt-temporal-literal in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
commit fe21d84bf336cd0ab63a954cb991c22b58c978a0 Author: Cong Hu <[email protected]> AuthorDate: Mon Jun 22 21:09:14 2026 +0800 fix(encrypt): handle temporal insert values Preserve temporal literal SQL text while exposing raw literal values for encrypt INSERT VALUES rewrite. Map temporal parser values to a typed literal expression segment, keep Oracle date-time literal quote metadata, and align parser and rewrite tests. --- .../token/pojo/EncryptInsertColumnToken.java | 4 +++ .../EncryptInsertValuesTokenGeneratorTest.java | 27 ++++++++++++++++ .../visitor/statement/OracleStatementVisitor.java | 4 +-- .../statement/type/OracleDMLStatementVisitor.java | 4 +-- .../simple/TemporalLiteralExpressionSegment.java | 36 ++++++++++++++++++++++ .../sql/parser/statement/core/util/SQLUtils.java | 7 ++++- .../value/literal/impl/DateTimeLiteralValue.java | 21 ++++++++++--- .../parser/statement/core/util/SQLUtilsTest.java | 27 ++++++++++++++++ .../literal/impl/DateTimeLiteralValueTest.java} | 35 +++++++++------------ .../parser/src/main/resources/case/dml/insert.xml | 6 ++-- .../main/resources/case/dml/select-expression.xml | 2 +- .../resources/case/dml/select-special-function.xml | 2 +- .../parser/src/main/resources/case/dml/select.xml | 6 +++- .../query-with-cipher/dml/insert/insert-column.xml | 10 ++++++ 14 files changed, 155 insertions(+), 36 deletions(-) diff --git a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/pojo/EncryptInsertColumnToken.java b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/pojo/EncryptInsertColumnToken.java index 6f7d0dd0cb7..e0ada543b49 100644 --- a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/pojo/EncryptInsertColumnToken.java +++ b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/pojo/EncryptInsertColumnToken.java @@ -23,6 +23,7 @@ import org.apache.shardingsphere.sql.parser.statement.core.enums.ParameterMarker import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.expr.ExpressionSegment; import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.expr.simple.LiteralExpressionSegment; import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.expr.simple.ParameterMarkerExpressionSegment; +import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.expr.simple.TemporalLiteralExpressionSegment; /** * Insert column token for encrypt. @@ -49,6 +50,9 @@ public abstract class EncryptInsertColumnToken extends SQLToken { ParameterMarkerExpressionSegment segment = (ParameterMarkerExpressionSegment) expressionSegment; return ParameterMarkerType.QUESTION == segment.getParameterMarkerType() ? "?" : "$" + (segment.getParameterMarkerIndex() + 1); } + if (expressionSegment instanceof TemporalLiteralExpressionSegment) { + return expressionSegment.getText(); + } if (expressionSegment instanceof LiteralExpressionSegment) { Object literals = ((LiteralExpressionSegment) expressionSegment).getLiterals(); if (null == literals) { diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/insert/EncryptInsertValuesTokenGeneratorTest.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/insert/EncryptInsertValuesTokenGeneratorTest.java index 3e2332c8dc4..15b1b17bef0 100644 --- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/insert/EncryptInsertValuesTokenGeneratorTest.java +++ b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/insert/EncryptInsertValuesTokenGeneratorTest.java @@ -31,6 +31,7 @@ import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.column.Co import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.column.InsertColumnsSegment; import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.expr.ExpressionSegment; import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.expr.simple.LiteralExpressionSegment; +import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.expr.simple.TemporalLiteralExpressionSegment; import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment; import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.TableNameSegment; import org.apache.shardingsphere.sql.parser.statement.core.statement.type.dml.InsertStatement; @@ -84,6 +85,12 @@ class EncryptInsertValuesTokenGeneratorTest { assertThat(generator.generateSQLToken(createLiteralInsertStatementContext()).toString(), is("(1, 'Tom', 0, 'encryptValue', 'assistedEncryptValue', 'likeEncryptValue')")); } + @Test + void assertGenerateSQLTokenWithTemporalLiteralValue() { + generator.setPreviousSQLTokens(Collections.emptyList()); + assertThat(generator.generateSQLToken(createTemporalLiteralInsertStatementContext()).toString(), is("(1, 'Tom', 0, 'encryptValue', 'assistedEncryptValue', 'likeEncryptValue')")); + } + private InsertStatementContext createLiteralInsertStatementContext() { ShardingSphereDatabase database = EncryptGeneratorFixtureBuilder.createDatabase(); InsertColumnsSegment insertColumnsSegment = new InsertColumnsSegment(0, 0, Arrays.asList( @@ -103,4 +110,24 @@ class EncryptInsertValuesTokenGeneratorTest { new RuleMetaData(Collections.emptyList()), new ConfigurationProperties(new Properties())); return new InsertStatementContext(insertStatement, metaData, "foo_db"); } + + private InsertStatementContext createTemporalLiteralInsertStatementContext() { + ShardingSphereDatabase database = EncryptGeneratorFixtureBuilder.createDatabase(); + InsertColumnsSegment insertColumnsSegment = new InsertColumnsSegment(0, 0, Arrays.asList( + new ColumnSegment(0, 0, new IdentifierValue("id")), + new ColumnSegment(0, 0, new IdentifierValue("name")), + new ColumnSegment(0, 0, new IdentifierValue("status")), + new ColumnSegment(0, 0, new IdentifierValue("pwd")))); + List<ExpressionSegment> valueExpressions = new ArrayList<>(4); + valueExpressions.add(new LiteralExpressionSegment(0, 0, 1)); + valueExpressions.add(new LiteralExpressionSegment(0, 0, "Tom")); + valueExpressions.add(new LiteralExpressionSegment(0, 0, 0)); + valueExpressions.add(new TemporalLiteralExpressionSegment(0, 0, "2024-03-01", "DATE '2024-03-01'")); + InsertStatement insertStatement = InsertStatement.builder().databaseType(DATABASE_TYPE) + .table(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("t_user")))) + .insertColumns(insertColumnsSegment).values(Collections.singletonList(new InsertValuesSegment(0, 0, valueExpressions))).build(); + ShardingSphereMetaData metaData = new ShardingSphereMetaData(Collections.singleton(database), new ResourceMetaData(Collections.emptyMap(), Collections.emptyMap()), + new RuleMetaData(Collections.emptyList()), new ConfigurationProperties(new Properties())); + return new InsertStatementContext(insertStatement, metaData, "foo_db"); + } } diff --git a/parser/sql/engine/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/engine/oracle/visitor/statement/OracleStatementVisitor.java b/parser/sql/engine/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/engine/oracle/visitor/statement/OracleStatementVisitor.java index ef07816714b..347a89401c3 100644 --- a/parser/sql/engine/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/engine/oracle/visitor/statement/OracleStatementVisitor.java +++ b/parser/sql/engine/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/engine/oracle/visitor/statement/OracleStatementVisitor.java @@ -357,7 +357,7 @@ public abstract class OracleStatementVisitor extends OracleStatementBaseVisitor< @Override public ASTNode visitDateTimeLiterals(final DateTimeLiteralsContext ctx) { if (null != ctx.LBE_()) { - return new DateTimeLiteralValue(ctx.identifier().getText(), ((StringLiteralValue) visit(ctx.stringLiterals())).getValue(), true); + return new DateTimeLiteralValue(ctx.identifier().getText(), ctx.stringLiterals().getText(), true); } String dateTimeType; if (null != ctx.DATE()) { @@ -367,7 +367,7 @@ public abstract class OracleStatementVisitor extends OracleStatementBaseVisitor< } else { dateTimeType = ctx.TIMESTAMP().getText(); } - return new DateTimeLiteralValue(dateTimeType, ((StringLiteralValue) visit(ctx.stringLiterals())).getValue(), false); + return new DateTimeLiteralValue(dateTimeType, ctx.stringLiterals().getText(), false); } @Override diff --git a/parser/sql/engine/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/engine/oracle/visitor/statement/type/OracleDMLStatementVisitor.java b/parser/sql/engine/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/engine/oracle/visitor/statement/type/OracleDMLStatementVisitor.java index 51dedd246f3..73a2b993ffc 100644 --- a/parser/sql/engine/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/engine/oracle/visitor/statement/type/OracleDMLStatementVisitor.java +++ b/parser/sql/engine/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/engine/oracle/visitor/statement/type/OracleDMLStatementVisitor.java @@ -1008,8 +1008,8 @@ public final class OracleDMLStatementVisitor extends OracleStatementVisitor impl if (projection instanceof LiteralExpressionSegment) { LiteralExpressionSegment column = (LiteralExpressionSegment) projection; ExpressionProjectionSegment result = null == alias - ? new ExpressionProjectionSegment(column.getStartIndex(), column.getStopIndex(), String.valueOf(column.getLiterals()), column) - : new ExpressionProjectionSegment(column.getStartIndex(), ctx.alias().stop.getStopIndex(), String.valueOf(column.getLiterals()), column); + ? new ExpressionProjectionSegment(column.getStartIndex(), column.getStopIndex(), column.getText(), column) + : new ExpressionProjectionSegment(column.getStartIndex(), ctx.alias().stop.getStopIndex(), column.getText(), column); result.setAlias(alias); return result; } diff --git a/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/segment/dml/expr/simple/TemporalLiteralExpressionSegment.java b/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/segment/dml/expr/simple/TemporalLiteralExpressionSegment.java new file mode 100644 index 00000000000..8f765a9f960 --- /dev/null +++ b/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/segment/dml/expr/simple/TemporalLiteralExpressionSegment.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.shardingsphere.sql.parser.statement.core.segment.dml.expr.simple; + +/** + * Temporal literal expression segment. + */ +public final class TemporalLiteralExpressionSegment extends LiteralExpressionSegment { + + private final String text; + + public TemporalLiteralExpressionSegment(final int startIndex, final int stopIndex, final Object literals, final String text) { + super(startIndex, stopIndex, literals); + this.text = text; + } + + @Override + public String getText() { + return text; + } +} diff --git a/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/util/SQLUtils.java b/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/util/SQLUtils.java index aec0a9ba813..1c642c2a16e 100644 --- a/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/util/SQLUtils.java +++ b/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/util/SQLUtils.java @@ -26,10 +26,12 @@ import org.apache.shardingsphere.sql.parser.statement.core.enums.Paren; import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.expr.ExpressionSegment; import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.expr.complex.CommonExpressionSegment; import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.expr.simple.LiteralExpressionSegment; +import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.expr.simple.TemporalLiteralExpressionSegment; import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.JoinTableSegment; import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SubqueryTableSegment; import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.TableSegment; import org.apache.shardingsphere.sql.parser.statement.core.value.literal.impl.BooleanLiteralValue; +import org.apache.shardingsphere.sql.parser.statement.core.value.literal.impl.DateTimeLiteralValue; import org.apache.shardingsphere.sql.parser.statement.core.value.literal.impl.NullLiteralValue; import org.apache.shardingsphere.sql.parser.statement.core.value.literal.impl.NumberLiteralValue; import org.apache.shardingsphere.sql.parser.statement.core.value.literal.impl.OtherLiteralValue; @@ -279,7 +281,10 @@ public final class SQLUtils { return new LiteralExpressionSegment(startIndex, stopIndex, null); } if (astNode instanceof TemporalLiteralValue) { - return new LiteralExpressionSegment(startIndex, stopIndex, ((TemporalLiteralValue) astNode).getValue()); + return new TemporalLiteralExpressionSegment(startIndex, stopIndex, ((TemporalLiteralValue) astNode).getValue(), text); + } + if (astNode instanceof DateTimeLiteralValue) { + return new TemporalLiteralExpressionSegment(startIndex, stopIndex, ((DateTimeLiteralValue) astNode).getDateTimeValue(), text); } if (astNode instanceof OtherLiteralValue) { return new CommonExpressionSegment(startIndex, stopIndex, ((OtherLiteralValue) astNode).getValue()); diff --git a/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/value/literal/impl/DateTimeLiteralValue.java b/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/value/literal/impl/DateTimeLiteralValue.java index 0a30440f3e8..52146250dc0 100644 --- a/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/value/literal/impl/DateTimeLiteralValue.java +++ b/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/value/literal/impl/DateTimeLiteralValue.java @@ -17,6 +17,7 @@ package org.apache.shardingsphere.sql.parser.statement.core.value.literal.impl; +import org.apache.shardingsphere.database.connector.core.metadata.database.enums.QuoteCharacter; import org.apache.shardingsphere.sql.parser.statement.core.value.literal.LiteralValue; /** @@ -28,19 +29,29 @@ public final class DateTimeLiteralValue implements LiteralValue<String> { private final String dateTimeValue; + private final QuoteCharacter quoteCharacter; + private final boolean containsBrace; public DateTimeLiteralValue(final String dateTimeType, final String dateTimeValue, final boolean containsBrace) { this.dateTimeType = dateTimeType; - this.dateTimeValue = containsBrace ? dateTimeValue.substring(1, dateTimeValue.length() - 1) : dateTimeValue; + quoteCharacter = QuoteCharacter.getQuoteCharacter(dateTimeValue); + this.dateTimeValue = quoteCharacter.unwrap(dateTimeValue); this.containsBrace = containsBrace; } @Override public String getValue() { - if (containsBrace) { - return "{" + dateTimeType + " " + dateTimeValue + "}"; - } - return dateTimeType + " " + dateTimeValue; + String quotedDateTimeValue = quoteCharacter.wrap(dateTimeValue); + return containsBrace ? "{" + dateTimeType + " " + quotedDateTimeValue + "}" : dateTimeType + " " + quotedDateTimeValue; + } + + /** + * Get date time value. + * + * @return date time value + */ + public String getDateTimeValue() { + return dateTimeValue; } } diff --git a/parser/sql/statement/core/src/test/java/org/apache/shardingsphere/sql/parser/statement/core/util/SQLUtilsTest.java b/parser/sql/statement/core/src/test/java/org/apache/shardingsphere/sql/parser/statement/core/util/SQLUtilsTest.java index 13a0b07862d..c2f09069aa5 100644 --- a/parser/sql/statement/core/src/test/java/org/apache/shardingsphere/sql/parser/statement/core/util/SQLUtilsTest.java +++ b/parser/sql/statement/core/src/test/java/org/apache/shardingsphere/sql/parser/statement/core/util/SQLUtilsTest.java @@ -17,6 +17,9 @@ package org.apache.shardingsphere.sql.parser.statement.core.util; +import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.expr.simple.TemporalLiteralExpressionSegment; +import org.apache.shardingsphere.sql.parser.statement.core.value.literal.impl.DateTimeLiteralValue; +import org.apache.shardingsphere.sql.parser.statement.core.value.literal.impl.TemporalLiteralValue; import org.junit.jupiter.api.Test; import java.math.BigDecimal; @@ -95,6 +98,30 @@ class SQLUtilsTest { assertThat(SQLUtils.getExactlyExpression("((a + b*c))"), is("((a+b*c))")); } + @Test + void assertCreateLiteralExpressionForTemporalLiteral() { + TemporalLiteralExpressionSegment actual = (TemporalLiteralExpressionSegment) SQLUtils.createLiteralExpression( + new TemporalLiteralValue("DATE", "'2024-03-01'"), 0, 16, "DATE '2024-03-01'"); + assertThat(actual.getLiterals(), is("2024-03-01")); + assertThat(actual.getText(), is("DATE '2024-03-01'")); + } + + @Test + void assertCreateLiteralExpressionForDateTimeLiteral() { + TemporalLiteralExpressionSegment actual = (TemporalLiteralExpressionSegment) SQLUtils.createLiteralExpression( + new DateTimeLiteralValue("DATE", "'2024-03-01'", false), 0, 16, "DATE '2024-03-01'"); + assertThat(actual.getLiterals(), is("2024-03-01")); + assertThat(actual.getText(), is("DATE '2024-03-01'")); + } + + @Test + void assertCreateLiteralExpressionForBraceDateTimeLiteral() { + TemporalLiteralExpressionSegment actual = (TemporalLiteralExpressionSegment) SQLUtils.createLiteralExpression( + new DateTimeLiteralValue("ts", "'2024-03-01 10:00:00'", true), 0, 25, "{ts '2024-03-01 10:00:00'}"); + assertThat(actual.getLiterals(), is("2024-03-01 10:00:00")); + assertThat(actual.getText(), is("{ts '2024-03-01 10:00:00'}")); + } + @Test void assertGetExpressionWithoutOutsideParentheses() { assertThat(SQLUtils.getExpressionWithoutOutsideParentheses("((a + b*c))"), is("a + b*c")); diff --git a/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/value/literal/impl/DateTimeLiteralValue.java b/parser/sql/statement/core/src/test/java/org/apache/shardingsphere/sql/parser/statement/core/value/literal/impl/DateTimeLiteralValueTest.java similarity index 51% copy from parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/value/literal/impl/DateTimeLiteralValue.java copy to parser/sql/statement/core/src/test/java/org/apache/shardingsphere/sql/parser/statement/core/value/literal/impl/DateTimeLiteralValueTest.java index 0a30440f3e8..831db6724a9 100644 --- a/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/value/literal/impl/DateTimeLiteralValue.java +++ b/parser/sql/statement/core/src/test/java/org/apache/shardingsphere/sql/parser/statement/core/value/literal/impl/DateTimeLiteralValueTest.java @@ -17,30 +17,25 @@ package org.apache.shardingsphere.sql.parser.statement.core.value.literal.impl; -import org.apache.shardingsphere.sql.parser.statement.core.value.literal.LiteralValue; +import org.junit.jupiter.api.Test; -/** - * Date time literal value. - */ -public final class DateTimeLiteralValue implements LiteralValue<String> { - - private final String dateTimeType; - - private final String dateTimeValue; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; + +class DateTimeLiteralValueTest { - private final boolean containsBrace; + @Test + void assertGetValue() { + assertThat(new DateTimeLiteralValue("DATE", "'2024-03-01'", false).getValue(), is("DATE '2024-03-01'")); + } - public DateTimeLiteralValue(final String dateTimeType, final String dateTimeValue, final boolean containsBrace) { - this.dateTimeType = dateTimeType; - this.dateTimeValue = containsBrace ? dateTimeValue.substring(1, dateTimeValue.length() - 1) : dateTimeValue; - this.containsBrace = containsBrace; + @Test + void assertGetValueWithBrace() { + assertThat(new DateTimeLiteralValue("ts", "'2024-03-01 10:00:00'", true).getValue(), is("{ts '2024-03-01 10:00:00'}")); } - @Override - public String getValue() { - if (containsBrace) { - return "{" + dateTimeType + " " + dateTimeValue + "}"; - } - return dateTimeType + " " + dateTimeValue; + @Test + void assertGetDateTimeValue() { + assertThat(new DateTimeLiteralValue("ts", "'2024-03-01 10:00:00'", true).getDateTimeValue(), is("2024-03-01 10:00:00")); } } 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 b665c657e33..9230bef95e0 100644 --- a/test/it/parser/src/main/resources/case/dml/insert.xml +++ b/test/it/parser/src/main/resources/case/dml/insert.xml @@ -2705,13 +2705,13 @@ <values> <value> <assignment-value> - <common-expression text="TIMESTAMP'1999-12-01 10:00:00'" start-index="30" stop-index="59" /> + <literal-expression value="1999-12-01 10:00:00" start-index="30" stop-index="59" /> </assignment-value> <assignment-value> - <common-expression text="TIMESTAMP'1999-12-01 10:00:00'" start-index="62" stop-index="91" /> + <literal-expression value="1999-12-01 10:00:00" start-index="62" stop-index="91" /> </assignment-value> <assignment-value> - <common-expression text="TIMESTAMP'1999-12-01 10:00:00'" start-index="94" stop-index="123" /> + <literal-expression value="1999-12-01 10:00:00" start-index="94" stop-index="123" /> </assignment-value> </value> </values> diff --git a/test/it/parser/src/main/resources/case/dml/select-expression.xml b/test/it/parser/src/main/resources/case/dml/select-expression.xml index 0708cf66bc3..2de491a2625 100644 --- a/test/it/parser/src/main/resources/case/dml/select-expression.xml +++ b/test/it/parser/src/main/resources/case/dml/select-expression.xml @@ -3221,7 +3221,7 @@ <projections start-index="7" stop-index="32"> <expression-projection text="{ts '2020-01-01 10:00:00'}" start-index="7" stop-index="32"> <expr> - <common-expression text="{ts '2020-01-01 10:00:00'}" start-index="7" stop-index="32" /> + <literal-expression value="2020-01-01 10:00:00" start-index="7" stop-index="32" /> </expr> </expression-projection> </projections> diff --git a/test/it/parser/src/main/resources/case/dml/select-special-function.xml b/test/it/parser/src/main/resources/case/dml/select-special-function.xml index d311116da42..03276021488 100644 --- a/test/it/parser/src/main/resources/case/dml/select-special-function.xml +++ b/test/it/parser/src/main/resources/case/dml/select-special-function.xml @@ -575,7 +575,7 @@ <expr> <function function-name="EXTRACT" text="EXTRACT(YEAR FROM TIMESTAMP '2001-02-16 20:38:40')" start-index="7" stop-index="56" literal-start-index="7" literal-stop-index="56"> <parameter> - <common-expression text="TIMESTAMP '2001-02-16 20:38:40'" start-index="25" stop-index="55" literal-start-index="25" literal-stop-index="55" /> + <literal-expression value="2001-02-16 20:38:40" start-index="25" stop-index="55" literal-start-index="25" literal-stop-index="55" /> </parameter> <literalText>EXTRACT(YEAR FROM TIMESTAMP '2001-02-16 20:38:40')</literalText> </function> diff --git a/test/it/parser/src/main/resources/case/dml/select.xml b/test/it/parser/src/main/resources/case/dml/select.xml index 8b77e81d0fc..6637b0c95a6 100644 --- a/test/it/parser/src/main/resources/case/dml/select.xml +++ b/test/it/parser/src/main/resources/case/dml/select.xml @@ -14198,7 +14198,11 @@ <select sql-case-id="select_datetime_lbe_literal_oracle"> <projections start-index="7" stop-index="32"> - <expression-projection text="{ts '2020-02-02 10:00:00'}" start-index="7" stop-index="32" /> + <expression-projection text="{ts '2020-02-02 10:00:00'}" start-index="7" stop-index="32"> + <expr> + <literal-expression value="2020-02-02 10:00:00" start-index="7" stop-index="32" /> + </expr> + </expression-projection> </projections> <from> <simple-table name="dual" start-index="39" stop-index="42" /> diff --git a/test/it/rewriter/src/test/resources/scenario/encrypt/case/query-with-cipher/dml/insert/insert-column.xml b/test/it/rewriter/src/test/resources/scenario/encrypt/case/query-with-cipher/dml/insert/insert-column.xml index 7ed473edd13..889295414f0 100644 --- a/test/it/rewriter/src/test/resources/scenario/encrypt/case/query-with-cipher/dml/insert/insert-column.xml +++ b/test/it/rewriter/src/test/resources/scenario/encrypt/case/query-with-cipher/dml/insert/insert-column.xml @@ -47,6 +47,16 @@ <output sql="INSERT INTO t_account_bak(account_id, `cipher_certificate_number`, `assisted_query_certificate_number`, `like_query_certificate_number`, `cipher_password`, `assisted_query_password`, `like_query_password`, `cipher_amount`, status) VALUES (1, 'encrypt_111X', 'assisted_query_111X', 'like_query_111X', 'encrypt_aaa', 'assisted_query_aaa', 'like_query_aaa', 'encrypt_1000', 'OK'), (2, 'encrypt_222X', 'assisted_query_222X', 'like_query_222X', 'encrypt_bbb', 'assisted_query_ [...] </rewrite-assertion> + <rewrite-assertion id="insert_values_with_columns_with_plain_for_mysql_temporal_literal" db-types="MySQL"> + <input sql="INSERT INTO t_account_bak(account_id, password, amount) VALUES (1, DATE '2024-03-01', 1000)" /> + <output sql="INSERT INTO t_account_bak(account_id, `cipher_password`, `assisted_query_password`, `like_query_password`, `cipher_amount`) VALUES (1, 'encrypt_2024-03-01', 'assisted_query_2024-03-01', 'like_query_2024-03-01', 'encrypt_1000')" /> + </rewrite-assertion> + + <rewrite-assertion id="insert_values_with_columns_with_plain_for_oracle_brace_datetime_literal" db-types="Oracle"> + <input sql="INSERT INTO t_account_bak(account_id, password, amount) VALUES (1, {d '2024-03-01'}, 1000)" /> + <output sql="INSERT INTO t_account_bak(account_id, "cipher_password", "assisted_query_password", "like_query_password", "cipher_amount") VALUES (1, 'encrypt_2024-03-01', 'assisted_query_2024-03-01', 'like_query_2024-03-01', 'encrypt_1000')" /> + </rewrite-assertion> + <rewrite-assertion id="insert_values_without_columns_for_parameters" db-types="MySQL"> <input sql="INSERT INTO t_account VALUES (?, ?, ?, ?), (2, '222X', 'bbb', 2000), (?, ?, ?, ?), (4, '444X', 'ddd', 4000)" parameters="1, 111X, aaa, 1000, 3, 333X, ccc, 3000" /> <output sql="INSERT INTO t_account(`account_id`, `cipher_certificate_number`, `assisted_query_certificate_number`, `like_query_certificate_number`, `cipher_password`, `assisted_query_password`, `like_query_password`, `cipher_amount`) VALUES (?, ?, ?, ?, ?, ?, ?, ?), (2, 'encrypt_222X', 'assisted_query_222X', 'like_query_222X', 'encrypt_bbb', 'assisted_query_bbb', 'like_query_bbb', 'encrypt_2000'), (?, ?, ?, ?, ?, ?, ?, ?), (4, 'encrypt_444X', 'assisted_query_444X', 'like_query_44 [...]
