You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2022/05/15 15:51:32 UTC
[shardingsphere] branch master updated: Revise pr 17500 (#17677)
This is an automated email from the ASF dual-hosted git repository.
zhangliang 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 e499ceb9009 Revise pr 17500 (#17677)
e499ceb9009 is described below
commit e499ceb9009f9ec8cc20cda819acda0aa8528d82
Author: Zhengqiang Duan <du...@apache.org>
AuthorDate: Sun May 15 23:51:27 2022 +0800
Revise pr 17500 (#17677)
---
.../rewrite/condition/EncryptConditionEngine.java | 2 +-
.../sql/common/util/ExpressionExtractUtil.java | 14 ++++++-------
.../case/query-with-cipher/dml/update/update.xml | 24 +++++++++++-----------
3 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/condition/EncryptConditionEngine.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/condition/EncryptConditionEngine.java
index 04b8e06469e..e7221f7bb0d 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/condition/EncryptConditionEngine.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/condition/EncryptConditionEngine.java
@@ -109,7 +109,7 @@ public final class EncryptConditionEngine {
}
private void addEncryptConditions(final Collection<EncryptCondition> encryptConditions, final ExpressionSegment expression, final Map<String, String> expressionTableNames) {
- if (!ExpressionExtractUtil.checkAndGetExpressionSegment(expression).isPresent()) {
+ if (!ExpressionExtractUtil.findNotContainsNullLiteralsExpression(expression).isPresent()) {
return;
}
for (ColumnSegment each : ColumnExtractor.extract(expression)) {
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/util/ExpressionExtractUtil.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/util/ExpressionExtractUtil.java
index d48a830596b..fb48d46e18a 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/util/ExpressionExtractUtil.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/util/ExpressionExtractUtil.java
@@ -83,27 +83,27 @@ public final class ExpressionExtractUtil {
private static AndPredicate createAndPredicate(final ExpressionSegment expression) {
AndPredicate result = new AndPredicate();
- checkAndGetExpressionSegment(expression).ifPresent(each -> result.getPredicates().add(each));
+ findNotContainsNullLiteralsExpression(expression).ifPresent(optional -> result.getPredicates().add(optional));
return result;
}
/**
- * Check and get the expressionSegment.
+ * Find not contains null literals expression.
*
* @param expression ExpressionSegment
- * @return expression while it is not and it's right side not LiteralExpressionSegment
+ * @return expression which not contains null literals
*/
- public static Optional<ExpressionSegment> checkAndGetExpressionSegment(final ExpressionSegment expression) {
- if (isNullLiterals(expression)) {
+ public static Optional<ExpressionSegment> findNotContainsNullLiteralsExpression(final ExpressionSegment expression) {
+ if (isContainsNullLiterals(expression)) {
return Optional.empty();
}
- if (expression instanceof BinaryOperationExpression && isNullLiterals(((BinaryOperationExpression) expression).getRight())) {
+ if (expression instanceof BinaryOperationExpression && isContainsNullLiterals(((BinaryOperationExpression) expression).getRight())) {
return Optional.empty();
}
return Optional.ofNullable(expression);
}
- private static boolean isNullLiterals(final ExpressionSegment expression) {
+ private static boolean isContainsNullLiterals(final ExpressionSegment expression) {
if (!(expression instanceof LiteralExpressionSegment)) {
return false;
}
diff --git a/shardingsphere-test/shardingsphere-rewrite-test/src/test/resources/scenario/encrypt/case/query-with-cipher/dml/update/update.xml b/shardingsphere-test/shardingsphere-rewrite-test/src/test/resources/scenario/encrypt/case/query-with-cipher/dml/update/update.xml
index 3ea89d1912f..45a69c9926c 100644
--- a/shardingsphere-test/shardingsphere-rewrite-test/src/test/resources/scenario/encrypt/case/query-with-cipher/dml/update/update.xml
+++ b/shardingsphere-test/shardingsphere-rewrite-test/src/test/resources/scenario/encrypt/case/query-with-cipher/dml/update/update.xml
@@ -65,32 +65,32 @@
</rewrite-assertion>
<rewrite-assertion id="update_null_to_clear_plain" db-types="MySQL">
- <input sql="UPDATE t_account_bak SET certificate_number = null" />
- <output sql="UPDATE t_account_bak SET certificate_number = null" />
+ <input sql="UPDATE t_account_bak SET certificate_number = NULL" />
+ <output sql="UPDATE t_account_bak SET certificate_number = NULL" />
</rewrite-assertion>
<rewrite-assertion id="update_null_to_clear_plain_with_multi" db-types="MySQL">
- <input sql="UPDATE t_account_bak SET certificate_number = null, certificate_number = ''" />
- <output sql="UPDATE t_account_bak SET certificate_number = null, cipher_certificate_number = 'encrypt_', assisted_query_certificate_number = 'assisted_query_', plain_certificate_number = ''" />
+ <input sql="UPDATE t_account_bak SET certificate_number = NULL, certificate_number = ''" />
+ <output sql="UPDATE t_account_bak SET certificate_number = NULL, cipher_certificate_number = 'encrypt_', assisted_query_certificate_number = 'assisted_query_', plain_certificate_number = ''" />
</rewrite-assertion>
<rewrite-assertion id="update_null_to_clear_plain_where_is_null" db-types="MySQL">
- <input sql="UPDATE t_account_bak SET certificate_number = null where certificate_number is null" />
- <output sql="UPDATE t_account_bak SET certificate_number = null where certificate_number is null" />
+ <input sql="UPDATE t_account_bak SET certificate_number = NULL WHERE certificate_number IS NULL" />
+ <output sql="UPDATE t_account_bak SET certificate_number = NULL WHERE certificate_number IS NULL" />
</rewrite-assertion>
<rewrite-assertion id="update_null_to_clear_plain_where_is_null_with_multi" db-types="MySQL">
- <input sql="UPDATE t_account_bak SET certificate_number = null where certificate_number is null AND status = 'OK' AND certificate_number = '111X'" />
- <output sql="UPDATE t_account_bak SET certificate_number = null where certificate_number is null AND status = 'OK' AND assisted_query_certificate_number = 'assisted_query_111X'" />
+ <input sql="UPDATE t_account_bak SET certificate_number = NULL WHERE certificate_number IS NULL AND status = 'OK' AND certificate_number = '111X'" />
+ <output sql="UPDATE t_account_bak SET certificate_number = NULL WHERE certificate_number IS NULL AND status = 'OK' AND assisted_query_certificate_number = 'assisted_query_111X'" />
</rewrite-assertion>
<rewrite-assertion id="update_null_to_clear_plain_where_is_not_null" db-types="MySQL">
- <input sql="UPDATE t_account_bak SET certificate_number = null where certificate_number is not null" />
- <output sql="UPDATE t_account_bak SET certificate_number = null where certificate_number is not null" />
+ <input sql="UPDATE t_account_bak SET certificate_number = NULL WHERE certificate_number IS NOT NULL" />
+ <output sql="UPDATE t_account_bak SET certificate_number = NULL WHERE certificate_number IS NOT NULL" />
</rewrite-assertion>
<rewrite-assertion id="update_null_to_clear_plain_where_is_not_null_with_multi" db-types="MySQL">
- <input sql="UPDATE t_account_bak SET certificate_number = null where certificate_number is not null AND status = 'OK' AND certificate_number = '111X'" />
- <output sql="UPDATE t_account_bak SET certificate_number = null where certificate_number is not null AND status = 'OK' AND assisted_query_certificate_number = 'assisted_query_111X'" />
+ <input sql="UPDATE t_account_bak SET certificate_number = NULL WHERE certificate_number IS NOT NULL AND status = 'OK' AND certificate_number = '111X'" />
+ <output sql="UPDATE t_account_bak SET certificate_number = NULL WHERE certificate_number IS NOT NULL AND status = 'OK' AND assisted_query_certificate_number = 'assisted_query_111X'" />
</rewrite-assertion>
</rewrite-assertions>