From 5ff473744519dfde8dc5164e928c62eda0b9da89 Mon Sep 17 00:00:00 2001 From: duanzhengqiang Date: Mon, 20 Nov 2023 13:47:18 +0800 Subject: [PATCH] Fix sharding sql rewrite error --- .../context/ShardingSQLRewriteContextDecorator.java | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rewrite/context/ShardingSQLRewriteContextDecorator.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rewrite/context/ShardingSQLRewriteContextDecorator.java index 14ecbe373768c..9872d5a4ea815 100644 --- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rewrite/context/ShardingSQLRewriteContextDecorator.java +++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rewrite/context/ShardingSQLRewriteContextDecorator.java @@ -18,7 +18,6 @@ package org.apache.shardingsphere.sharding.rewrite.context; import lombok.Setter; -import org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext; import org.apache.shardingsphere.infra.config.props.ConfigurationProperties; import org.apache.shardingsphere.infra.rewrite.context.SQLRewriteContext; import org.apache.shardingsphere.infra.rewrite.context.SQLRewriteContextDecorator; @@ -39,9 +38,6 @@ public final class ShardingSQLRewriteContextDecorator implements SQLRewriteConte @Override public void decorate(final ShardingRule shardingRule, final ConfigurationProperties props, final SQLRewriteContext sqlRewriteContext, final RouteContext routeContext) { - if (!containsShardingTable(shardingRule, sqlRewriteContext.getSqlStatementContext())) { - return; - } if (!sqlRewriteContext.getParameters().isEmpty()) { Collection parameterRewriters = new ShardingParameterRewriterBuilder(shardingRule, routeContext, sqlRewriteContext.getDatabase().getSchemas(), sqlRewriteContext.getSqlStatementContext()).getParameterRewriters(); @@ -50,15 +46,6 @@ public void decorate(final ShardingRule shardingRule, final ConfigurationPropert sqlRewriteContext.addSQLTokenGenerators(new ShardingTokenGenerateBuilder(shardingRule, routeContext, sqlRewriteContext.getSqlStatementContext()).getSQLTokenGenerators()); } - private boolean containsShardingTable(final ShardingRule shardingRule, final SQLStatementContext sqlStatementContext) { - for (String each : sqlStatementContext.getTablesContext().getTableNames()) { - if (shardingRule.findTableRule(each).isPresent()) { - return true; - } - } - return false; - } - private void rewriteParameters(final SQLRewriteContext sqlRewriteContext, final Collection parameterRewriters) { for (ParameterRewriter each : parameterRewriters) { each.rewrite(sqlRewriteContext.getParameterBuilder(), sqlRewriteContext.getSqlStatementContext(), sqlRewriteContext.getParameters());