kissthisrain opened a new issue, #20812:
URL: https://github.com/apache/shardingsphere/issues/20812
## Bug Report
in version 5.1.2,The SQL clause 'LIKE' is unsupported in encrypt rule,I
dont konw why
### Which version of ShardingSphere did you use?
5.1.2
### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
ShardingSphere-JDBC
### Expected behavior
support 'like'
### Actual behavior
```java
Caused by:
org.apache.shardingsphere.infra.exception.ShardingSphereException: The SQL
clause 'LIKE' is unsupported in encrypt rule.
at
org.apache.shardingsphere.encrypt.rewrite.condition.EncryptConditionEngine.createBinaryEncryptCondition(EncryptConditionEngine.java:143)
at
org.apache.shardingsphere.encrypt.rewrite.condition.EncryptConditionEngine.createEncryptCondition(EncryptConditionEngine.java:126)
at
org.apache.shardingsphere.encrypt.rewrite.condition.EncryptConditionEngine.addEncryptConditions(EncryptConditionEngine.java:119)
at
org.apache.shardingsphere.encrypt.rewrite.condition.EncryptConditionEngine.addEncryptConditions(EncryptConditionEngine.java:107)
at
org.apache.shardingsphere.encrypt.rewrite.condition.EncryptConditionEngine.createEncryptConditions(EncryptConditionEngine.java:97)
at
org.apache.shardingsphere.encrypt.rewrite.context.EncryptSQLRewriteContextDecorator.createEncryptConditions(EncryptSQLRewriteContextDecorator.java:73)
at
org.apache.shardingsphere.encrypt.rewrite.context.EncryptSQLRewriteContextDecorator.decorate(EncryptSQLRewriteContextDecorator.java:53)
at
org.apache.shardingsphere.encrypt.rewrite.context.EncryptSQLRewriteContextDecorator.decorate(EncryptSQLRewriteContextDecorator.java:44)
at
org.apache.shardingsphere.infra.rewrite.SQLRewriteEntry.decorate(SQLRewriteEntry.java:86)
at
org.apache.shardingsphere.infra.rewrite.SQLRewriteEntry.createSQLRewriteContext(SQLRewriteEntry.java:78)
at
org.apache.shardingsphere.infra.rewrite.SQLRewriteEntry.rewrite(SQLRewriteEntry.java:67)
at
org.apache.shardingsphere.infra.context.kernel.KernelProcessor.rewrite(KernelProcessor.java:59)
at
org.apache.shardingsphere.infra.context.kernel.KernelProcessor.generateExecutionContext(KernelProcessor.java:47)
at
org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.createExecutionContext(ShardingSpherePreparedStatement.java:471)
at
org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.execute(ShardingSpherePreparedStatement.java:364)
at sun.reflect.GeneratedMethodAccessor339.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at
org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:59)
at com.sun.proxy.$Proxy680.execute(Unknown Source)
at
org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:64)
at
org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:79)
at sun.reflect.GeneratedMethodAccessor347.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:63)
at com.sun.proxy.$Proxy678.query(Unknown Source)
at
com.baomidou.mybatisplus.core.executor.MybatisSimpleExecutor.doQuery(MybatisSimpleExecutor.java:69)
at
org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:325)
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156)
at
com.baomidou.mybatisplus.core.executor.MybatisCachingExecutor.query(MybatisCachingExecutor.java:165)
at
com.baomidou.mybatisplus.core.executor.MybatisCachingExecutor.query(MybatisCachingExecutor.java:92)
at sun.reflect.GeneratedMethodAccessor329.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:63)
at com.sun.proxy.$Proxy677.query(Unknown Source)
at sun.reflect.GeneratedMethodAccessor329.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:63)
at com.sun.proxy.$Proxy677.query(Unknown Source)
at
org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:147)
```
### Reason analyze (If you can)
```java
static {
LOGICAL_OPERATOR.add("AND");
LOGICAL_OPERATOR.add("&&");
LOGICAL_OPERATOR.add("OR");
LOGICAL_OPERATOR.add("||");
SUPPORTED_COMPARE_OPERATOR.add("=");
SUPPORTED_COMPARE_OPERATOR.add("<>");
SUPPORTED_COMPARE_OPERATOR.add("!=");
SUPPORTED_COMPARE_OPERATOR.add(">");
SUPPORTED_COMPARE_OPERATOR.add("<");
SUPPORTED_COMPARE_OPERATOR.add(">=");
SUPPORTED_COMPARE_OPERATOR.add("<=");
SUPPORTED_COMPARE_OPERATOR.add("IS");
}
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 ShardingSphereException("The SQL clause '%s' is
unsupported in encrypt rule.", operator);
}
return Optional.empty();
}
```
### Steps to reproduce the behavior, such as: SQL to execute, sharding rule
configuration, when exception occur etc.
### Example codes for reproduce this issue (such as a github link).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail:
[email protected]
For queries about this service, please contact Infrastructure at:
[email protected]