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 2023/08/10 03:14:58 UTC
[shardingsphere] branch master updated: Revise code style for EncryptConditionEngine (#28003)
This is an automated email from the ASF dual-hosted git repository.
zhaojinchao 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 9ada0c1f676 Revise code style for EncryptConditionEngine (#28003)
9ada0c1f676 is described below
commit 9ada0c1f67605c59b96f3f2cffb35d4faaa54cc4
Author: Zhengqiang Duan <du...@apache.org>
AuthorDate: Thu Aug 10 11:14:51 2023 +0800
Revise code style for EncryptConditionEngine (#28003)
---
.../encrypt/rewrite/condition/EncryptConditionEngine.java | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/condition/EncryptConditionEngine.java b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/condition/EncryptConditionEngine.java
index 664d36dd162..91c5210550a 100644
--- a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/condition/EncryptConditionEngine.java
+++ b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/condition/EncryptConditionEngine.java
@@ -25,6 +25,7 @@ import org.apache.shardingsphere.encrypt.rule.EncryptRule;
import org.apache.shardingsphere.encrypt.rule.EncryptTable;
import org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
import org.apache.shardingsphere.infra.database.core.type.DatabaseTypeRegistry;
+import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.column.ColumnSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.BetweenExpression;
@@ -158,13 +159,11 @@ public final class EncryptConditionEngine {
private Optional<EncryptCondition> createBinaryEncryptCondition(final BinaryOperationExpression expression, final String tableName) {
String operator = expression.getOperator();
- if (!LOGICAL_OPERATOR.contains(operator)) {
- if (SUPPORTED_COMPARE_OPERATOR.contains(operator)) {
- return createCompareEncryptCondition(tableName, expression, expression.getRight());
- }
- throw new UnsupportedEncryptSQLException(operator);
+ if (LOGICAL_OPERATOR.contains(operator)) {
+ return Optional.empty();
}
- return Optional.empty();
+ ShardingSpherePreconditions.checkState(SUPPORTED_COMPARE_OPERATOR.contains(operator), () -> new UnsupportedEncryptSQLException(operator));
+ return createCompareEncryptCondition(tableName, expression, expression.getRight());
}
private Optional<EncryptCondition> createCompareEncryptCondition(final String tableName, final BinaryOperationExpression expression, final ExpressionSegment compareRightValue) {