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 2025/07/13 10:22:27 UTC
(shardingsphere) branch master updated: Remove SQLStatementContext.getDatabaseType() (#35973)
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 8f5139de907 Remove SQLStatementContext.getDatabaseType() (#35973)
8f5139de907 is described below
commit 8f5139de9070d6d6e0acc929a54b5ba78a8bbf1b
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Sun Jul 13 18:22:20 2025 +0800
Remove SQLStatementContext.getDatabaseType() (#35973)
* Remove SQLStatementContext.getDatabaseType()
* Remove SQLStatementContext.getDatabaseType()
* Remove SQLStatementContext.getDatabaseType()
* Remove SQLStatementContext.getDatabaseType()
---
.../core/advice/SQLRouteCountAdviceTest.java | 8 +--
.../unicast/BroadcastUnicastRouteEngineTest.java | 2 +-
.../EncryptShowCreateTableMergedResultTest.java | 2 +-
.../ddl/EncryptAlterTableTokenGeneratorTest.java | 6 +--
.../ddl/EncryptCreateTableTokenGeneratorTest.java | 2 +-
.../fixture/EncryptGeneratorFixtureBuilder.java | 6 +--
.../ShardingAlterIndexSupportedCheckerTest.java | 6 +--
.../ShardingAlterTableSupportedCheckerTest.java | 2 +-
.../ddl/ShardingAlterViewSupportedCheckerTest.java | 6 +--
...ShardingCreateFunctionSupportedCheckerTest.java | 8 +--
.../ShardingCreateIndexSupportedCheckerTest.java | 12 ++---
...hardingCreateProcedureSupportedCheckerTest.java | 8 +--
.../ShardingCreateTableSupportedCheckerTest.java | 4 +-
.../ddl/ShardingDropIndexSupportedCheckerTest.java | 4 +-
.../ddl/ShardingDropTableSupportedCheckerTest.java | 2 +-
.../ddl/ShardingInsertSupportedCheckerTest.java | 3 +-
.../ShardingRenameTableSupportedCheckerTest.java | 2 +-
...ShardingMultipleTablesSupportedCheckerTest.java | 4 +-
.../sql/dml/ShardingTableSupportedCheckerTest.java | 4 +-
.../merge/ShardingResultMergerEngineTest.java | 8 +--
.../common/IteratorStreamMergedResultTest.java | 2 +-
.../merge/ddl/ShardingDDLResultMergerTest.java | 5 +-
.../ddl/fetch/FetchStreamMergedResultTest.java | 5 +-
.../merge/dql/ShardingDQLResultMergerTest.java | 52 +++++++++----------
.../dql/groupby/GroupByMemoryMergedResultTest.java | 8 +--
.../dql/groupby/GroupByRowComparatorTest.java | 12 ++---
.../dql/groupby/GroupByStreamMergedResultTest.java | 2 +-
.../dql/orderby/OrderByStreamMergedResultTest.java | 2 +-
.../merge/dql/orderby/OrderByValueTest.java | 9 ++--
.../pagination/LimitDecoratorMergedResultTest.java | 6 +--
.../RowNumberDecoratorMergedResultTest.java | 11 ++--
.../TopAndRowNumberDecoratorMergedResultTest.java | 10 ++--
.../impl/ShardingIndexTokenGeneratorTest.java | 8 +--
.../impl/ShardingRemoveTokenGeneratorTest.java | 3 +-
.../rewrite/token/pojo/IndexTokenTest.java | 2 +-
.../ShardingAlterTableRouteContextCheckerTest.java | 4 +-
...ShardingCreateTableRouteContextCheckerTest.java | 6 +--
.../ShardingDropIndexRouteContextCheckerTest.java | 4 +-
.../ShardingDropTableRouteContextCheckerTest.java | 8 +--
...ShardingRenameTableRouteContextCheckerTest.java | 2 +-
.../dml/ShardingInsertRouteContextCheckerTest.java | 3 +-
.../dml/ShardingUpdateRouteContextCheckerTest.java | 6 +--
.../type/ShardingRouteEngineFactoryTest.java | 2 +-
.../binder/context/SQLStatementContextFactory.java | 58 ++++++++++------------
.../context/statement/SQLStatementContext.java | 8 ---
.../statement/type/CommonSQLStatementContext.java | 6 +--
.../type/dal/ExplainStatementContext.java | 11 ++--
.../type/ddl/AlterViewStatementContext.java | 12 ++---
.../type/ddl/CreateProcedureStatementContext.java | 6 +--
.../type/ddl/CreateViewStatementContext.java | 9 +---
.../type/ddl/CursorHeldSQLStatementContext.java | 6 +--
.../statement/type/ddl/CursorStatementContext.java | 9 +---
.../statement/type/dml/DeleteStatementContext.java | 8 +--
.../statement/type/dml/InsertStatementContext.java | 14 ++----
.../statement/type/dml/SelectStatementContext.java | 20 +++-----
.../statement/type/dml/UpdateStatementContext.java | 8 +--
.../infra/binder/engine/SQLBindEngine.java | 2 +-
.../select/pagination/PaginationContextTest.java | 4 +-
.../type/dal/ExplainStatementContextTest.java | 4 +-
.../type/ddl/AlterViewStatementContextTest.java | 6 +--
.../ddl/CreateProcedureStatementContextTest.java | 2 +-
.../type/ddl/CreateViewStatementContextTest.java | 4 +-
.../type/dml/DeleteStatementContextTest.java | 2 +-
.../type/dml/InsertStatementContextTest.java | 9 +++-
.../type/dml/SelectStatementContextTest.java | 39 +++++++--------
.../type/dml/UpdateStatementContextTest.java | 3 +-
.../connection/kernel/KernelProcessorTest.java | 2 +-
.../executor/sql/process/ProcessEngineTest.java | 2 +-
.../infra/rewrite/sql/impl/AbstractSQLBuilder.java | 3 +-
.../infra/rewrite/sql/impl/RouteSQLBuilder.java | 5 +-
.../sql/SingleDropSchemaSupportedCheckerTest.java | 2 +-
.../sql/SingleDropTableSupportedCheckerTest.java | 2 +-
.../single/route/SingleSQLRouterTest.java | 2 +-
.../connector/StandardDatabaseConnector.java | 3 +-
.../backend/distsql/DistSQLStatementContext.java | 6 ---
.../backend/connector/ProxySQLExecutorTest.java | 6 +--
.../data/DatabaseBackendHandlerFactoryTest.java | 2 +-
.../handler/tcl/TCLBackendHandlerFactoryTest.java | 4 +-
.../admin/MySQLAdminExecutorCreatorTest.java | 18 +++----
.../admin/OpenGaussAdminExecutorFactoryTest.java | 2 +-
...enGaussSystemCatalogAdminQueryExecutorTest.java | 8 +--
.../admin/PostgreSQLAdminExecutorCreatorTest.java | 10 ++--
.../command/MySQLCommandPacketFactoryTest.java | 3 +-
.../execute/MySQLComStmtExecuteExecutorTest.java | 2 +-
.../command/query/extended/PortalTest.java | 8 +--
.../bind/PostgreSQLComBindExecutorTest.java | 4 +-
86 files changed, 273 insertions(+), 342 deletions(-)
diff --git a/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/SQLRouteCountAdviceTest.java b/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/SQLRouteCountAdviceTest.java
index 77c1f784e56..4b71d394d28 100644
--- a/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/SQLRouteCountAdviceTest.java
+++ b/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/SQLRouteCountAdviceTest.java
@@ -61,7 +61,7 @@ class SQLRouteCountAdviceTest {
@Test
void assertInsertRoute() {
QueryContext queryContext = new QueryContext(new CommonSQLStatementContext(
- databaseType, new InsertStatement(databaseType)), "", Collections.emptyList(), new HintValueContext(), mockConnectionContext(), mock(ShardingSphereMetaData.class));
+ new InsertStatement(databaseType)), "", Collections.emptyList(), new HintValueContext(), mockConnectionContext(), mock(ShardingSphereMetaData.class));
assertRoute(queryContext, "INSERT=1");
}
@@ -74,21 +74,21 @@ class SQLRouteCountAdviceTest {
@Test
void assertUpdateRoute() {
QueryContext queryContext = new QueryContext(new CommonSQLStatementContext(
- databaseType, new UpdateStatement(databaseType)), "", Collections.emptyList(), new HintValueContext(), mockConnectionContext(), mock(ShardingSphereMetaData.class));
+ new UpdateStatement(databaseType)), "", Collections.emptyList(), new HintValueContext(), mockConnectionContext(), mock(ShardingSphereMetaData.class));
assertRoute(queryContext, "UPDATE=1");
}
@Test
void assertDeleteRoute() {
QueryContext queryContext = new QueryContext(new CommonSQLStatementContext(
- databaseType, new DeleteStatement(databaseType)), "", Collections.emptyList(), new HintValueContext(), mockConnectionContext(), mock(ShardingSphereMetaData.class));
+ new DeleteStatement(databaseType)), "", Collections.emptyList(), new HintValueContext(), mockConnectionContext(), mock(ShardingSphereMetaData.class));
assertRoute(queryContext, "DELETE=1");
}
@Test
void assertSelectRoute() {
QueryContext queryContext = new QueryContext(new CommonSQLStatementContext(
- databaseType, new SelectStatement(databaseType)), "", Collections.emptyList(), new HintValueContext(), mockConnectionContext(), mock(ShardingSphereMetaData.class));
+ new SelectStatement(databaseType)), "", Collections.emptyList(), new HintValueContext(), mockConnectionContext(), mock(ShardingSphereMetaData.class));
assertRoute(queryContext, "SELECT=1");
}
diff --git a/features/broadcast/core/src/test/java/org/apache/shardingsphere/broadcast/route/engine/type/unicast/BroadcastUnicastRouteEngineTest.java b/features/broadcast/core/src/test/java/org/apache/shardingsphere/broadcast/route/engine/type/unicast/BroadcastUnicastRouteEngineTest.java
index 1039d617931..c997cd3895e 100644
--- a/features/broadcast/core/src/test/java/org/apache/shardingsphere/broadcast/route/engine/type/unicast/BroadcastUnicastRouteEngineTest.java
+++ b/features/broadcast/core/src/test/java/org/apache/shardingsphere/broadcast/route/engine/type/unicast/BroadcastUnicastRouteEngineTest.java
@@ -87,7 +87,7 @@ class BroadcastUnicastRouteEngineTest {
@Test
void assertRouteToFirstDataSourceWithDropViewStatementContext() {
- SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(mock(), new DropViewStatement(databaseType));
+ SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(new DropViewStatement(databaseType));
assertRoute(sqlStatementContext, is("ds_0"));
}
diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/show/EncryptShowCreateTableMergedResultTest.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/show/EncryptShowCreateTableMergedResultTest.java
index fe1f5aad4c8..69ea37be69d 100644
--- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/show/EncryptShowCreateTableMergedResultTest.java
+++ b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/show/EncryptShowCreateTableMergedResultTest.java
@@ -184,7 +184,7 @@ class EncryptShowCreateTableMergedResultTest {
private EncryptShowCreateTableMergedResult createMergedResult(final MergedResult mergedResult, final String tableName, final EncryptRule rule) {
SQLStatement sqlStatement = new MySQLShowCreateTableStatement(databaseType, new SimpleTableSegment(new TableNameSegment(1, 4, new IdentifierValue(tableName))));
- CommonSQLStatementContext sqlStatementContext = new CommonSQLStatementContext(databaseType, sqlStatement);
+ CommonSQLStatementContext sqlStatementContext = new CommonSQLStatementContext(sqlStatement);
RuleMetaData globalRuleMetaData = mock(RuleMetaData.class);
when(globalRuleMetaData.getSingleRule(SQLParserRule.class)).thenReturn(new SQLParserRule(new SQLParserRuleConfiguration(new CacheOption(128, 1024L), new CacheOption(2000, 65535L))));
return new EncryptShowCreateTableMergedResult(globalRuleMetaData, mergedResult, sqlStatementContext, rule);
diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/ddl/EncryptAlterTableTokenGeneratorTest.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/ddl/EncryptAlterTableTokenGeneratorTest.java
index 547ae37296b..f16adc59639 100644
--- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/ddl/EncryptAlterTableTokenGeneratorTest.java
+++ b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/ddl/EncryptAlterTableTokenGeneratorTest.java
@@ -100,7 +100,7 @@ class EncryptAlterTableTokenGeneratorTest {
@Test
void assertAddColumnGenerateSQLTokens() {
- Collection<SQLToken> actual = generator.generateSQLTokens(new CommonSQLStatementContext(databaseType, createAddColumnStatement()));
+ Collection<SQLToken> actual = generator.generateSQLTokens(new CommonSQLStatementContext(createAddColumnStatement()));
assertThat(actual.size(), is(4));
Iterator<SQLToken> actualIterator = actual.iterator();
assertThat(actualIterator.next(), instanceOf(RemoveToken.class));
@@ -129,7 +129,7 @@ class EncryptAlterTableTokenGeneratorTest {
@Test
void assertModifyEncryptColumnGenerateSQLTokens() {
- assertThrows(UnsupportedOperationException.class, () -> generator.generateSQLTokens(new CommonSQLStatementContext(databaseType, createModifyColumnStatement())));
+ assertThrows(UnsupportedOperationException.class, () -> generator.generateSQLTokens(new CommonSQLStatementContext(createModifyColumnStatement())));
}
private SQLStatement createModifyColumnStatement() {
@@ -143,7 +143,7 @@ class EncryptAlterTableTokenGeneratorTest {
@Test
void assertChangeEncryptColumnGenerateSQLTokens() {
- assertThrows(UnsupportedOperationException.class, () -> generator.generateSQLTokens(new CommonSQLStatementContext(databaseType, createChangeColumnStatement())));
+ assertThrows(UnsupportedOperationException.class, () -> generator.generateSQLTokens(new CommonSQLStatementContext(createChangeColumnStatement())));
}
private SQLStatement createChangeColumnStatement() {
diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/ddl/EncryptCreateTableTokenGeneratorTest.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/ddl/EncryptCreateTableTokenGeneratorTest.java
index e83e3cb8f2c..79a6a3c1875 100644
--- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/ddl/EncryptCreateTableTokenGeneratorTest.java
+++ b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/ddl/EncryptCreateTableTokenGeneratorTest.java
@@ -86,7 +86,7 @@ class EncryptCreateTableTokenGeneratorTest {
@Test
void assertGenerateSQLTokens() {
- Collection<SQLToken> actual = generator.generateSQLTokens(new CommonSQLStatementContext(mock(), createCreateTableStatement()));
+ Collection<SQLToken> actual = generator.generateSQLTokens(new CommonSQLStatementContext(createCreateTableStatement()));
assertThat(actual.size(), is(1));
SQLToken token = actual.iterator().next();
assertThat(token, instanceOf(SubstituteColumnDefinitionToken.class));
diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/fixture/EncryptGeneratorFixtureBuilder.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/fixture/EncryptGeneratorFixtureBuilder.java
index c586b63cdc3..d9890d4716e 100644
--- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/fixture/EncryptGeneratorFixtureBuilder.java
+++ b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/fixture/EncryptGeneratorFixtureBuilder.java
@@ -114,7 +114,7 @@ public final class EncryptGeneratorFixtureBuilder {
ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
when(database.getSchema("foo_db")).thenReturn(schema);
ShardingSphereMetaData metaData = new ShardingSphereMetaData(Collections.singleton(database), mock(ResourceMetaData.class), mock(RuleMetaData.class), mock(ConfigurationProperties.class));
- return new InsertStatementContext(DATABASE_TYPE, createInsertStatement(), params, metaData, "foo_db");
+ return new InsertStatementContext(createInsertStatement(), params, metaData, "foo_db");
}
private static InsertStatement createInsertStatement() {
@@ -167,7 +167,7 @@ public final class EncryptGeneratorFixtureBuilder {
updateStatement.setTable(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("t_user"))));
updateStatement.setWhere(createWhereSegment());
updateStatement.setSetAssignment(createSetAssignmentSegment());
- return new UpdateStatementContext(DATABASE_TYPE, updateStatement);
+ return new UpdateStatementContext(updateStatement);
}
private static WhereSegment createWhereSegment() {
@@ -219,6 +219,6 @@ public final class EncryptGeneratorFixtureBuilder {
ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
when(database.getSchema("foo_db")).thenReturn(schema);
ShardingSphereMetaData metaData = new ShardingSphereMetaData(Collections.singleton(database), mock(ResourceMetaData.class), mock(RuleMetaData.class), mock(ConfigurationProperties.class));
- return new InsertStatementContext(DATABASE_TYPE, createInsertSelectStatement(containsInsertColumns), params, metaData, "foo_db");
+ return new InsertStatementContext(createInsertSelectStatement(containsInsertColumns), params, metaData, "foo_db");
}
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingAlterIndexSupportedCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingAlterIndexSupportedCheckerTest.java
index e5c68e94367..85d28071b6a 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingAlterIndexSupportedCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingAlterIndexSupportedCheckerTest.java
@@ -64,7 +64,7 @@ class ShardingAlterIndexSupportedCheckerTest {
when(schema.getAllTables()).thenReturn(Collections.singleton(table));
when(table.containsIndex("t_order_index")).thenReturn(true);
when(table.containsIndex("t_order_index_new")).thenReturn(false);
- assertDoesNotThrow(() -> new ShardingAlterIndexSupportedChecker().check(rule, database, schema, new CommonSQLStatementContext(mock(), sqlStatement)));
+ assertDoesNotThrow(() -> new ShardingAlterIndexSupportedChecker().check(rule, database, schema, new CommonSQLStatementContext(sqlStatement)));
}
@Test
@@ -74,7 +74,7 @@ class ShardingAlterIndexSupportedCheckerTest {
sqlStatement.setRenameIndex(new IndexSegment(0, 0, new IndexNameSegment(0, 0, new IdentifierValue("t_order_index_new"))));
ShardingSphereTable table = mock(ShardingSphereTable.class);
when(database.getSchema("public").getTable("t_order")).thenReturn(table);
- assertThrows(IndexNotFoundException.class, () -> new ShardingAlterIndexSupportedChecker().check(rule, database, mock(), new CommonSQLStatementContext(mock(), sqlStatement)));
+ assertThrows(IndexNotFoundException.class, () -> new ShardingAlterIndexSupportedChecker().check(rule, database, mock(), new CommonSQLStatementContext(sqlStatement)));
}
@Test
@@ -88,6 +88,6 @@ class ShardingAlterIndexSupportedCheckerTest {
when(table.containsIndex("t_order_index")).thenReturn(true);
when(table.containsIndex("t_order_index_new")).thenReturn(true);
assertThrows(DuplicateIndexException.class,
- () -> new ShardingAlterIndexSupportedChecker().check(rule, database, schema, new CommonSQLStatementContext(mock(), sqlStatement)));
+ () -> new ShardingAlterIndexSupportedChecker().check(rule, database, schema, new CommonSQLStatementContext(sqlStatement)));
}
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingAlterTableSupportedCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingAlterTableSupportedCheckerTest.java
index 74b5d27b3e6..f4fa40aa1cd 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingAlterTableSupportedCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingAlterTableSupportedCheckerTest.java
@@ -58,7 +58,7 @@ class ShardingAlterTableSupportedCheckerTest {
AlterTableStatement sqlStatement = new AlterTableStatement(databaseType);
sqlStatement.setTable(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("t_order"))));
sqlStatement.setRenameTable(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("t_order_new"))));
- CommonSQLStatementContext sqlStatementContext = new CommonSQLStatementContext(mock(), sqlStatement);
+ CommonSQLStatementContext sqlStatementContext = new CommonSQLStatementContext(sqlStatement);
when(rule.containsShardingTable(Arrays.asList("t_order", "t_order_new"))).thenReturn(true);
assertThrows(UnsupportedShardingOperationException.class, () -> new ShardingAlterTableSupportedChecker().check(rule, database, mock(), sqlStatementContext));
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingAlterViewSupportedCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingAlterViewSupportedCheckerTest.java
index 3ec6390fe57..db62918fa5b 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingAlterViewSupportedCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingAlterViewSupportedCheckerTest.java
@@ -65,7 +65,7 @@ class ShardingAlterViewSupportedCheckerTest {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
when(database.getRuleMetaData().getAttributes(TableMapperRuleAttribute.class)).thenReturn(Collections.emptyList());
when(metaData.getDatabase("foo_db")).thenReturn(database);
- AlterViewStatementContext sqlStatementContext = new AlterViewStatementContext(metaData, databaseType, Collections.emptyList(), sqlStatement, "foo_db");
+ AlterViewStatementContext sqlStatementContext = new AlterViewStatementContext(metaData, Collections.emptyList(), sqlStatement, "foo_db");
when(rule.isShardingTable("t_order")).thenReturn(false);
assertDoesNotThrow(() -> new ShardingAlterViewSupportedChecker().check(rule, mock(), mock(), sqlStatementContext));
}
@@ -82,7 +82,7 @@ class ShardingAlterViewSupportedCheckerTest {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
when(database.getRuleMetaData().getAttributes(TableMapperRuleAttribute.class)).thenReturn(Collections.emptyList());
when(metaData.getDatabase("foo_db")).thenReturn(database);
- AlterViewStatementContext sqlStatementContext = new AlterViewStatementContext(metaData, databaseType, Collections.emptyList(), sqlStatement, "foo_db");
+ AlterViewStatementContext sqlStatementContext = new AlterViewStatementContext(metaData, Collections.emptyList(), sqlStatement, "foo_db");
when(rule.isShardingTable("t_order")).thenReturn(true);
assertThrows(EngagedViewException.class, () -> new ShardingAlterViewSupportedChecker().check(rule, mock(), mock(), sqlStatementContext));
}
@@ -92,7 +92,7 @@ class ShardingAlterViewSupportedCheckerTest {
AlterViewStatement sqlStatement = mock(AlterViewStatement.class);
when(sqlStatement.getView()).thenReturn(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("t_order_view"))));
when(sqlStatement.getRenameView()).thenReturn(Optional.of(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("t_order_new")))));
- AlterViewStatementContext sqlStatementContext = new AlterViewStatementContext(mock(ShardingSphereMetaData.class), databaseType, Collections.emptyList(), sqlStatement, "foo_db");
+ AlterViewStatementContext sqlStatementContext = new AlterViewStatementContext(mock(ShardingSphereMetaData.class), Collections.emptyList(), sqlStatement, "foo_db");
assertDoesNotThrow(() -> new ShardingAlterViewSupportedChecker().check(rule, mock(), mock(), sqlStatementContext));
}
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateFunctionSupportedCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateFunctionSupportedCheckerTest.java
index 5a54ddfbd6b..c98c4af8d09 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateFunctionSupportedCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateFunctionSupportedCheckerTest.java
@@ -75,7 +75,7 @@ class ShardingCreateFunctionSupportedCheckerTest {
CreateFunctionStatement sqlStatement = mock(CreateFunctionStatement.class);
when(sqlStatement.getRoutineBody()).thenReturn(Optional.of(routineBody));
when(sqlStatement.getAttributes()).thenReturn(new SQLStatementAttributes(new TableSQLStatementAttribute(fromTable)));
- SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(mock(), sqlStatement);
+ SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(sqlStatement);
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class);
ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
when(schema.containsTable("bar_tbl")).thenReturn(true);
@@ -94,7 +94,7 @@ class ShardingCreateFunctionSupportedCheckerTest {
CreateFunctionStatement sqlStatement = mock(CreateFunctionStatement.class);
when(sqlStatement.getRoutineBody()).thenReturn(Optional.of(routineBody));
when(sqlStatement.getAttributes()).thenReturn(new SQLStatementAttributes(new TableSQLStatementAttribute(fromTable)));
- SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(mock(), sqlStatement);
+ SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(sqlStatement);
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
when(rule.isShardingTable("foo_tbl")).thenReturn(true);
assertThrows(UnsupportedShardingOperationException.class, () -> new ShardingCreateFunctionSupportedChecker().check(rule, database, mock(), sqlStatementContext));
@@ -112,7 +112,7 @@ class ShardingCreateFunctionSupportedCheckerTest {
CreateFunctionStatement sqlStatement = mock(CreateFunctionStatement.class);
when(sqlStatement.getRoutineBody()).thenReturn(Optional.of(routineBody));
when(sqlStatement.getAttributes()).thenReturn(new SQLStatementAttributes(new TableSQLStatementAttribute(fromTable)));
- SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(mock(), sqlStatement);
+ SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(sqlStatement);
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
assertThrows(NoSuchTableException.class, () -> new ShardingCreateFunctionSupportedChecker().check(rule, database, mock(), sqlStatementContext));
}
@@ -129,7 +129,7 @@ class ShardingCreateFunctionSupportedCheckerTest {
CreateFunctionStatement sqlStatement = mock(CreateFunctionStatement.class);
when(sqlStatement.getRoutineBody()).thenReturn(Optional.of(routineBody));
when(sqlStatement.getAttributes()).thenReturn(new SQLStatementAttributes(new TableSQLStatementAttribute(table)));
- SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(mock(), sqlStatement);
+ SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(sqlStatement);
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
when(schema.containsTable("foo_tbl")).thenReturn(true);
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateIndexSupportedCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateIndexSupportedCheckerTest.java
index c857dec997d..e0c59fb3cba 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateIndexSupportedCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateIndexSupportedCheckerTest.java
@@ -61,7 +61,7 @@ class ShardingCreateIndexSupportedCheckerTest {
sqlStatement.setIndex(new IndexSegment(0, 0, new IndexNameSegment(0, 0, new IdentifierValue("t_order_index"))));
ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
when(schema.containsTable("t_order")).thenReturn(true);
- assertDoesNotThrow(() -> new ShardingCreateIndexSupportedChecker().check(rule, database, schema, new CommonSQLStatementContext(mock(), sqlStatement)));
+ assertDoesNotThrow(() -> new ShardingCreateIndexSupportedChecker().check(rule, database, schema, new CommonSQLStatementContext(sqlStatement)));
}
@Test
@@ -71,7 +71,7 @@ class ShardingCreateIndexSupportedCheckerTest {
sqlStatement.setIndex(new IndexSegment(0, 0, new IndexNameSegment(0, 0, new IdentifierValue("t_order_index"))));
ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
when(schema.containsTable("t_order")).thenReturn(false);
- assertThrows(NoSuchTableException.class, () -> new ShardingCreateIndexSupportedChecker().check(rule, database, schema, new CommonSQLStatementContext(mock(), sqlStatement)));
+ assertThrows(NoSuchTableException.class, () -> new ShardingCreateIndexSupportedChecker().check(rule, database, schema, new CommonSQLStatementContext(sqlStatement)));
}
@Test
@@ -82,7 +82,7 @@ class ShardingCreateIndexSupportedCheckerTest {
ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
when(schema.containsTable("t_order")).thenReturn(true);
when(schema.containsIndex("t_order", "t_order_index")).thenReturn(true);
- assertThrows(DuplicateIndexException.class, () -> new ShardingCreateIndexSupportedChecker().check(rule, database, schema, new CommonSQLStatementContext(mock(), sqlStatement)));
+ assertThrows(DuplicateIndexException.class, () -> new ShardingCreateIndexSupportedChecker().check(rule, database, schema, new CommonSQLStatementContext(sqlStatement)));
}
@Test
@@ -93,7 +93,7 @@ class ShardingCreateIndexSupportedCheckerTest {
sqlStatement.setAnonymousIndexStartIndex(10);
ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
when(schema.containsTable("t_order")).thenReturn(true);
- assertDoesNotThrow(() -> new ShardingCreateIndexSupportedChecker().check(rule, database, schema, new CommonSQLStatementContext(mock(), sqlStatement)));
+ assertDoesNotThrow(() -> new ShardingCreateIndexSupportedChecker().check(rule, database, schema, new CommonSQLStatementContext(sqlStatement)));
}
@Test
@@ -104,7 +104,7 @@ class ShardingCreateIndexSupportedCheckerTest {
sqlStatement.setAnonymousIndexStartIndex(10);
ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
when(schema.containsTable("t_order")).thenReturn(false);
- assertThrows(NoSuchTableException.class, () -> new ShardingCreateIndexSupportedChecker().check(rule, database, schema, new CommonSQLStatementContext(mock(), sqlStatement)));
+ assertThrows(NoSuchTableException.class, () -> new ShardingCreateIndexSupportedChecker().check(rule, database, schema, new CommonSQLStatementContext(sqlStatement)));
}
@Test
@@ -116,6 +116,6 @@ class ShardingCreateIndexSupportedCheckerTest {
ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
when(schema.containsTable("t_order")).thenReturn(true);
when(schema.containsIndex("t_order", "content_idx")).thenReturn(true);
- assertThrows(DuplicateIndexException.class, () -> new ShardingCreateIndexSupportedChecker().check(rule, database, schema, new CommonSQLStatementContext(mock(), sqlStatement)));
+ assertThrows(DuplicateIndexException.class, () -> new ShardingCreateIndexSupportedChecker().check(rule, database, schema, new CommonSQLStatementContext(sqlStatement)));
}
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateProcedureSupportedCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateProcedureSupportedCheckerTest.java
index 134ff93761b..c9863f92114 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateProcedureSupportedCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateProcedureSupportedCheckerTest.java
@@ -74,7 +74,7 @@ class ShardingCreateProcedureSupportedCheckerTest {
ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
when(schema.containsTable("bar_tbl")).thenReturn(true);
when(rule.isShardingTable("bar_tbl")).thenReturn(false);
- CreateProcedureStatementContext sqlStatementContext = new CreateProcedureStatementContext(mock(), sqlStatement);
+ CreateProcedureStatementContext sqlStatementContext = new CreateProcedureStatementContext(sqlStatement);
assertDoesNotThrow(() -> new ShardingCreateProcedureSupportedChecker().check(rule, database, schema, sqlStatementContext));
}
@@ -88,7 +88,7 @@ class ShardingCreateProcedureSupportedCheckerTest {
routineBody.getValidStatements().add(validStatementSegment);
CreateProcedureStatement sqlStatement = new CreateProcedureStatement(databaseType);
sqlStatement.setRoutineBody(routineBody);
- CreateProcedureStatementContext sqlStatementContext = new CreateProcedureStatementContext(mock(), sqlStatement);
+ CreateProcedureStatementContext sqlStatementContext = new CreateProcedureStatementContext(sqlStatement);
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
when(rule.isShardingTable("foo_tbl")).thenReturn(true);
assertThrows(UnsupportedShardingOperationException.class, () -> new ShardingCreateProcedureSupportedChecker().check(rule, database, mock(), sqlStatementContext));
@@ -104,7 +104,7 @@ class ShardingCreateProcedureSupportedCheckerTest {
routineBody.getValidStatements().add(validStatementSegment);
CreateProcedureStatement sqlStatement = mock(CreateProcedureStatement.class);
when(sqlStatement.getRoutineBody()).thenReturn(Optional.of(routineBody));
- CreateProcedureStatementContext sqlStatementContext = new CreateProcedureStatementContext(mock(), sqlStatement);
+ CreateProcedureStatementContext sqlStatementContext = new CreateProcedureStatementContext(sqlStatement);
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
assertThrows(NoSuchTableException.class, () -> new ShardingCreateProcedureSupportedChecker().check(rule, database, mock(), sqlStatementContext));
}
@@ -119,7 +119,7 @@ class ShardingCreateProcedureSupportedCheckerTest {
routineBody.getValidStatements().add(validStatementSegment);
CreateProcedureStatement sqlStatement = mock(CreateProcedureStatement.class);
when(sqlStatement.getRoutineBody()).thenReturn(Optional.of(routineBody));
- CreateProcedureStatementContext sqlStatementContext = new CreateProcedureStatementContext(mock(), sqlStatement);
+ CreateProcedureStatementContext sqlStatementContext = new CreateProcedureStatementContext(sqlStatement);
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
when(schema.containsTable("foo_tbl")).thenReturn(true);
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateTableSupportedCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateTableSupportedCheckerTest.java
index 50cd38bdb1e..16bad0a50cf 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateTableSupportedCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateTableSupportedCheckerTest.java
@@ -54,7 +54,7 @@ class ShardingCreateTableSupportedCheckerTest {
}
private void assertCheck(final CreateTableStatement sqlStatement) {
- CommonSQLStatementContext sqlStatementContext = new CommonSQLStatementContext(mock(), sqlStatement);
+ CommonSQLStatementContext sqlStatementContext = new CommonSQLStatementContext(sqlStatement);
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
when(schema.containsTable("foo_tbl")).thenReturn(true);
@@ -70,7 +70,7 @@ class ShardingCreateTableSupportedCheckerTest {
}
private void assertCheckIfNotExists(final CreateTableStatement sqlStatement) {
- CommonSQLStatementContext sqlStatementContext = new CommonSQLStatementContext(mock(), sqlStatement);
+ CommonSQLStatementContext sqlStatementContext = new CommonSQLStatementContext(sqlStatement);
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
new ShardingCreateTableSupportedChecker().check(rule, database, mock(), sqlStatementContext);
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingDropIndexSupportedCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingDropIndexSupportedCheckerTest.java
index 19aae540af2..84f4e368535 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingDropIndexSupportedCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingDropIndexSupportedCheckerTest.java
@@ -63,7 +63,7 @@ class ShardingDropIndexSupportedCheckerTest {
when(schema.getAllTables()).thenReturn(Collections.singleton(table));
when(table.containsIndex("t_order_index")).thenReturn(true);
when(table.containsIndex("t_order_index_new")).thenReturn(true);
- assertDoesNotThrow(() -> new ShardingDropIndexSupportedChecker().check(rule, database, schema, new CommonSQLStatementContext(mock(), sqlStatement)));
+ assertDoesNotThrow(() -> new ShardingDropIndexSupportedChecker().check(rule, database, schema, new CommonSQLStatementContext(sqlStatement)));
}
@Test
@@ -74,6 +74,6 @@ class ShardingDropIndexSupportedCheckerTest {
ShardingSphereTable table = mock(ShardingSphereTable.class);
when(database.getSchema("public").getAllTables()).thenReturn(Collections.singleton(table));
when(database.getSchema("public").getTable("t_order")).thenReturn(table);
- assertThrows(IndexNotFoundException.class, () -> new ShardingDropIndexSupportedChecker().check(rule, database, mock(), new CommonSQLStatementContext(mock(), sqlStatement)));
+ assertThrows(IndexNotFoundException.class, () -> new ShardingDropIndexSupportedChecker().check(rule, database, mock(), new CommonSQLStatementContext(sqlStatement)));
}
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingDropTableSupportedCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingDropTableSupportedCheckerTest.java
index ca336156bcd..6ebe199a256 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingDropTableSupportedCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingDropTableSupportedCheckerTest.java
@@ -70,7 +70,7 @@ class ShardingDropTableSupportedCheckerTest {
DropTableStatement sqlStatement = new DropTableStatement(databaseType);
SimpleTableSegment table = new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("t_order_item")));
sqlStatement.getTables().add(table);
- SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(mock(), sqlStatement);
+ SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(sqlStatement);
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
when(schema.containsTable("t_order_item")).thenReturn(true);
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingInsertSupportedCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingInsertSupportedCheckerTest.java
index b06c5dcf9d5..5b07da140a0 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingInsertSupportedCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingInsertSupportedCheckerTest.java
@@ -81,7 +81,7 @@ class ShardingInsertSupportedCheckerTest {
private InsertStatementContext createInsertStatementContext(final List<Object> params, final InsertStatement insertStatement) {
when(database.getName()).thenReturn("foo_db");
ShardingSphereMetaData metaData = new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), mock());
- return new InsertStatementContext(databaseType, insertStatement, params, metaData, "foo_db");
+ return new InsertStatementContext(insertStatement, params, metaData, "foo_db");
}
@Test
@@ -125,6 +125,7 @@ class ShardingInsertSupportedCheckerTest {
private InsertStatement createInsertStatement() {
InsertStatement result = mock(InsertStatement.class);
+ when(result.getDatabaseType()).thenReturn(databaseType);
when(result.getTable()).thenReturn(Optional.of(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("user")))));
ColumnSegment columnSegment = new ColumnSegment(0, 0, new IdentifierValue("id"));
List<ColumnSegment> columnSegments = Collections.singletonList(columnSegment);
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingRenameTableSupportedCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingRenameTableSupportedCheckerTest.java
index ac668401ca8..7a940bc5cab 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingRenameTableSupportedCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingRenameTableSupportedCheckerTest.java
@@ -70,6 +70,6 @@ class ShardingRenameTableSupportedCheckerTest {
renameTableDefinitionSegment.setRenameTable(renameTable);
when(sqlStatement.getRenameTables()).thenReturn(Collections.singleton(renameTableDefinitionSegment));
when(sqlStatement.getAttributes()).thenReturn(new SQLStatementAttributes(new TableSQLStatementAttribute(Arrays.asList(table, renameTable))));
- return new CommonSQLStatementContext(mock(), sqlStatement);
+ return new CommonSQLStatementContext(sqlStatement);
}
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingMultipleTablesSupportedCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingMultipleTablesSupportedCheckerTest.java
index 01aedb64b71..f2e21197311 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingMultipleTablesSupportedCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingMultipleTablesSupportedCheckerTest.java
@@ -58,7 +58,7 @@ class ShardingMultipleTablesSupportedCheckerTest {
void assertCheckWhenUpdateSingleTable() {
UpdateStatement updateStatement = createUpdateStatement();
updateStatement.setTable(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("user"))));
- UpdateStatementContext sqlStatementContext = new UpdateStatementContext(mock(), updateStatement);
+ UpdateStatementContext sqlStatementContext = new UpdateStatementContext(updateStatement);
Collection<String> tableNames = sqlStatementContext.getTablesContext().getTableNames();
when(rule.isAllShardingTables(tableNames)).thenReturn(true);
when(rule.containsShardingTable(tableNames)).thenReturn(true);
@@ -72,7 +72,7 @@ class ShardingMultipleTablesSupportedCheckerTest {
joinTableSegment.setLeft(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("user"))));
joinTableSegment.setRight(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("order"))));
updateStatement.setTable(joinTableSegment);
- UpdateStatementContext sqlStatementContext = new UpdateStatementContext(mock(), updateStatement);
+ UpdateStatementContext sqlStatementContext = new UpdateStatementContext(updateStatement);
Collection<String> tableNames = sqlStatementContext.getTablesContext().getTableNames();
when(rule.containsShardingTable(tableNames)).thenReturn(true);
assertThrows(DMLWithMultipleShardingTablesException.class, () -> new ShardingMultipleTablesSupportedChecker().check(rule, mock(), mock(), sqlStatementContext));
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingTableSupportedCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingTableSupportedCheckerTest.java
index c2e74056172..10d2ba3db11 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingTableSupportedCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingTableSupportedCheckerTest.java
@@ -53,12 +53,12 @@ class ShardingTableSupportedCheckerTest {
@Test
void assertCheckWithoutShardingTable() {
- assertDoesNotThrow(() -> new ShardingTableSupportedChecker().check(rule, mock(), mock(), new CommonSQLStatementContext(mock(), sqlStatement)));
+ assertDoesNotThrow(() -> new ShardingTableSupportedChecker().check(rule, mock(), mock(), new CommonSQLStatementContext(sqlStatement)));
}
@Test
void assertCheckWithShardingTable() {
when(rule.isShardingTable("foo_tbl")).thenReturn(true);
- assertThrows(UnsupportedShardingOperationException.class, () -> new ShardingTableSupportedChecker().check(rule, mock(), mock(), new CommonSQLStatementContext(mock(), sqlStatement)));
+ assertThrows(UnsupportedShardingOperationException.class, () -> new ShardingTableSupportedChecker().check(rule, mock(), mock(), new CommonSQLStatementContext(sqlStatement)));
}
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/ShardingResultMergerEngineTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/ShardingResultMergerEngineTest.java
index f027c0ab97c..37e09ca39b0 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/ShardingResultMergerEngineTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/ShardingResultMergerEngineTest.java
@@ -64,7 +64,7 @@ class ShardingResultMergerEngineTest {
when(database.getName()).thenReturn("foo_db");
selectStatement.setProjections(new ProjectionsSegment(0, 0));
SelectStatementContext sqlStatementContext = new SelectStatementContext(
- databaseType, selectStatement, Collections.emptyList(), new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), mock()), "foo_db", Collections.emptyList());
+ selectStatement, Collections.emptyList(), new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), mock()), "foo_db", Collections.emptyList());
assertThat(new ShardingResultMergerEngine().newInstance("foo_db", databaseType, null, new ConfigurationProperties(new Properties()), sqlStatementContext),
instanceOf(ShardingDQLResultMerger.class));
}
@@ -74,7 +74,7 @@ class ShardingResultMergerEngineTest {
ConfigurationProperties props = new ConfigurationProperties(new Properties());
SQLStatement sqlStatement = mock(ShowStatement.class);
when(sqlStatement.getAttributes()).thenReturn(new SQLStatementAttributes());
- SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(databaseType, sqlStatement);
+ SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(sqlStatement);
assertThat(new ShardingResultMergerEngine().newInstance("foo_db", databaseType, null, props, sqlStatementContext), instanceOf(ShardingDALResultMerger.class));
}
@@ -92,13 +92,13 @@ class ShardingResultMergerEngineTest {
private InsertStatementContext createInsertStatementContext(final InsertStatement insertStatement) {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
when(database.getName()).thenReturn("foo_db");
- return new InsertStatementContext(databaseType, insertStatement, Collections.emptyList(), new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), mock()), "foo_db");
+ return new InsertStatementContext(insertStatement, Collections.emptyList(), new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), mock()), "foo_db");
}
@Test
void assertNewInstanceWithDDLStatement() {
ConfigurationProperties props = new ConfigurationProperties(new Properties());
- SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(databaseType, new FetchStatement(databaseType, null, null));
+ SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(new FetchStatement(databaseType, null, null));
assertThat(new ShardingResultMergerEngine().newInstance("foo_db", databaseType, null, props, sqlStatementContext), instanceOf(ShardingDDLResultMerger.class));
}
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/common/IteratorStreamMergedResultTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/common/IteratorStreamMergedResultTest.java
index 84c9464dd87..75949ee963b 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/common/IteratorStreamMergedResultTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/common/IteratorStreamMergedResultTest.java
@@ -61,7 +61,7 @@ class IteratorStreamMergedResultTest {
void setUp() {
SelectStatement selectStatement = new SelectStatement(databaseType);
selectStatement.setProjections(new ProjectionsSegment(0, 0));
- selectStatementContext = new SelectStatementContext(databaseType, selectStatement, Collections.emptyList(), createShardingSphereMetaData(), "foo_db", Collections.emptyList());
+ selectStatementContext = new SelectStatementContext(selectStatement, Collections.emptyList(), createShardingSphereMetaData(), "foo_db", Collections.emptyList());
}
private ShardingSphereMetaData createShardingSphereMetaData() {
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/ddl/ShardingDDLResultMergerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/ddl/ShardingDDLResultMergerTest.java
index 41bd56463da..093119e21bc 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/ddl/ShardingDDLResultMergerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/ddl/ShardingDDLResultMergerTest.java
@@ -79,7 +79,7 @@ class ShardingDDLResultMergerTest {
}
private CursorHeldSQLStatementContext createCursorHeldSQLStatementContext(final ShardingSphereDatabase database) {
- CursorHeldSQLStatementContext result = new CursorHeldSQLStatementContext(databaseType, new FetchStatement(databaseType, new CursorNameSegment(0, 0, new IdentifierValue("foo_cursor")), null));
+ CursorHeldSQLStatementContext result = new CursorHeldSQLStatementContext(new FetchStatement(databaseType, new CursorNameSegment(0, 0, new IdentifierValue("foo_cursor")), null));
result.setCursorStatementContext(createCursorStatementContext(database));
return result;
}
@@ -89,7 +89,7 @@ class ShardingDDLResultMergerTest {
SelectStatement selectStatement = createSelectStatement();
selectStatement.setProjections(new ProjectionsSegment(0, 0));
SelectStatementContext selectStatementContext = new SelectStatementContext(
- databaseType, selectStatement, Collections.emptyList(), new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), mock()), "foo_db", Collections.emptyList());
+ selectStatement, Collections.emptyList(), new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), mock()), "foo_db", Collections.emptyList());
when(result.getSelectStatementContext()).thenReturn(selectStatementContext);
when(result.getSqlStatement().getSelect()).thenReturn(selectStatement);
return result;
@@ -97,6 +97,7 @@ class ShardingDDLResultMergerTest {
private SelectStatement createSelectStatement() {
SelectStatement result = mock(SelectStatement.class, RETURNS_DEEP_STUBS);
+ when(result.getDatabaseType()).thenReturn(databaseType);
when(result.getFrom()).thenReturn(Optional.of(new SimpleTableSegment(new TableNameSegment(10, 13, new IdentifierValue("tbl")))));
when(result.getProjections()).thenReturn(new ProjectionsSegment(0, 0));
return result;
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/ddl/fetch/FetchStreamMergedResultTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/ddl/fetch/FetchStreamMergedResultTest.java
index b2e4e8ed9ee..d8432b7c60c 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/ddl/fetch/FetchStreamMergedResultTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/ddl/fetch/FetchStreamMergedResultTest.java
@@ -91,7 +91,7 @@ class FetchStreamMergedResultTest {
}
private static CursorHeldSQLStatementContext createCursorHeldSQLStatementContext(final boolean containsAllDirectionType) {
- CursorHeldSQLStatementContext result = new CursorHeldSQLStatementContext(DATABASE_TYPE, createFetchStatement(containsAllDirectionType));
+ CursorHeldSQLStatementContext result = new CursorHeldSQLStatementContext(createFetchStatement(containsAllDirectionType));
result.setCursorStatementContext(mockCursorStatementContext());
return result;
}
@@ -105,11 +105,12 @@ class FetchStreamMergedResultTest {
CursorStatement cursorStatement = new CursorStatement(DATABASE_TYPE, null, selectStatement);
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
when(database.getName()).thenReturn("foo_db");
- return new CursorStatementContext(new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), mock()), DATABASE_TYPE, Collections.emptyList(), cursorStatement, "foo_db");
+ return new CursorStatementContext(new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), mock()), Collections.emptyList(), cursorStatement, "foo_db");
}
private static SelectStatement mockSelectStatement() {
SelectStatement result = mock(SelectStatement.class);
+ when(result.getDatabaseType()).thenReturn(DATABASE_TYPE);
when(result.getProjections()).thenReturn(new ProjectionsSegment(0, 0));
when(result.getFrom()).thenReturn(Optional.of(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("foo_tbl")))));
return result;
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/ShardingDQLResultMergerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/ShardingDQLResultMergerTest.java
index c041dd7eae2..d1a87888470 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/ShardingDQLResultMergerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/ShardingDQLResultMergerTest.java
@@ -86,7 +86,7 @@ class ShardingDQLResultMergerTest {
SelectStatement selectStatement = buildSelectStatement(new SelectStatement(mysqlDatabaseType));
selectStatement.setProjections(new ProjectionsSegment(0, 0));
SelectStatementContext selectStatementContext = new SelectStatementContext(
- mysqlDatabaseType, selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
+ selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
assertThat(resultMerger.merge(createQueryResults(), selectStatementContext, createDatabase(), mock(ConnectionContext.class)), instanceOf(IteratorStreamMergedResult.class));
}
@@ -98,7 +98,7 @@ class ShardingDQLResultMergerTest {
selectStatement.setProjections(new ProjectionsSegment(0, 0));
selectStatement.setLimit(new LimitSegment(0, 0, new NumberLiteralLimitValueSegment(0, 0, 1L), null));
SelectStatementContext selectStatementContext = new SelectStatementContext(
- mysqlDatabaseType, selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
+ selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
assertThat(resultMerger.merge(Collections.singletonList(createQueryResult()), selectStatementContext, createDatabase(), mock(ConnectionContext.class)),
instanceOf(IteratorStreamMergedResult.class));
}
@@ -111,7 +111,7 @@ class ShardingDQLResultMergerTest {
selectStatement.setProjections(new ProjectionsSegment(0, 0));
selectStatement.setLimit(new LimitSegment(0, 0, new NumberLiteralLimitValueSegment(0, 0, 1L), null));
SelectStatementContext selectStatementContext = new SelectStatementContext(
- mysqlDatabaseType, selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
+ selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
MergedResult actual = resultMerger.merge(createQueryResults(), selectStatementContext, createDatabase(), mock(ConnectionContext.class));
assertThat(actual, instanceOf(LimitDecoratorMergedResult.class));
assertThat(((LimitDecoratorMergedResult) actual).getMergedResult(), instanceOf(IteratorStreamMergedResult.class));
@@ -133,14 +133,14 @@ class ShardingDQLResultMergerTest {
SubqueryTableSegment subqueryTableSegment = mock(SubqueryTableSegment.class);
SubquerySegment subquerySegment = mock(SubquerySegment.class);
SelectStatement subSelectStatement = mock(SelectStatement.class);
+ when(subSelectStatement.getDatabaseType()).thenReturn(oracleDatabaseType);
ProjectionsSegment subProjectionsSegment = mock(ProjectionsSegment.class);
when(subSelectStatement.getProjections()).thenReturn(subProjectionsSegment);
when(subquerySegment.getSelect()).thenReturn(subSelectStatement);
when(subqueryTableSegment.getSubquery()).thenReturn(subquerySegment);
selectStatement.setFrom(subqueryTableSegment);
selectStatement.setWhere(whereSegment);
- SelectStatementContext selectStatementContext = new SelectStatementContext(
- oracleDatabaseType, selectStatement, null, createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
+ SelectStatementContext selectStatementContext = new SelectStatementContext(selectStatement, null, createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
MergedResult actual = resultMerger.merge(createQueryResults(), selectStatementContext, createDatabase(), mock(ConnectionContext.class));
assertThat(actual, instanceOf(IteratorStreamMergedResult.class));
}
@@ -153,7 +153,7 @@ class ShardingDQLResultMergerTest {
selectStatement.setProjections(new ProjectionsSegment(0, 0));
selectStatement.setLimit(new LimitSegment(0, 0, new NumberLiteralLimitValueSegment(0, 0, 1L), null));
SelectStatementContext selectStatementContext = new SelectStatementContext(
- sqlserverDatabaseType, selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
+ selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
MergedResult actual = resultMerger.merge(createQueryResults(), selectStatementContext, createSQLServerDatabase(), mock(ConnectionContext.class));
assertThat(actual, instanceOf(TopAndRowNumberDecoratorMergedResult.class));
assertThat(((TopAndRowNumberDecoratorMergedResult) actual).getMergedResult(), instanceOf(IteratorStreamMergedResult.class));
@@ -167,7 +167,7 @@ class ShardingDQLResultMergerTest {
selectStatement.setOrderBy(new OrderBySegment(0, 0, Collections.singletonList(new IndexOrderByItemSegment(0, 0, 1, OrderDirection.DESC, NullsOrderType.FIRST))));
selectStatement.setProjections(new ProjectionsSegment(0, 0));
SelectStatementContext selectStatementContext = new SelectStatementContext(
- mysqlDatabaseType, selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
+ selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
assertThat(resultMerger.merge(createQueryResults(), selectStatementContext, createDatabase(), mock(ConnectionContext.class)), instanceOf(OrderByStreamMergedResult.class));
}
@@ -180,7 +180,7 @@ class ShardingDQLResultMergerTest {
selectStatement.setProjections(new ProjectionsSegment(0, 0));
selectStatement.setLimit(new LimitSegment(0, 0, new NumberLiteralLimitValueSegment(0, 0, 1L), null));
SelectStatementContext selectStatementContext = new SelectStatementContext(
- mysqlDatabaseType, selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
+ selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
MergedResult actual = resultMerger.merge(createQueryResults(), selectStatementContext, createDatabase(), mock(ConnectionContext.class));
assertThat(actual, instanceOf(LimitDecoratorMergedResult.class));
assertThat(((LimitDecoratorMergedResult) actual).getMergedResult(), instanceOf(OrderByStreamMergedResult.class));
@@ -200,6 +200,7 @@ class ShardingDQLResultMergerTest {
SubqueryTableSegment subqueryTableSegment = mock(SubqueryTableSegment.class);
SubquerySegment subquerySegment = mock(SubquerySegment.class);
SelectStatement subSelectStatement = mock(SelectStatement.class);
+ when(subSelectStatement.getDatabaseType()).thenReturn(oracleDatabaseType);
ProjectionsSegment subProjectionsSegment = mock(ProjectionsSegment.class);
when(subSelectStatement.getProjections()).thenReturn(subProjectionsSegment);
when(subquerySegment.getSelect()).thenReturn(subSelectStatement);
@@ -209,8 +210,7 @@ class ShardingDQLResultMergerTest {
selectStatement.setProjections(new ProjectionsSegment(0, 0));
selectStatement.setFrom(subqueryTableSegment);
selectStatement.setWhere(whereSegment);
- SelectStatementContext selectStatementContext = new SelectStatementContext(oracleDatabaseType,
- selectStatement, null, createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
+ SelectStatementContext selectStatementContext = new SelectStatementContext(selectStatement, null, createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
MergedResult actual = resultMerger.merge(createQueryResults(), selectStatementContext, createDatabase(), mock(ConnectionContext.class));
assertThat(actual, instanceOf(OrderByStreamMergedResult.class));
}
@@ -224,7 +224,7 @@ class ShardingDQLResultMergerTest {
selectStatement.setProjections(new ProjectionsSegment(0, 0));
selectStatement.setLimit(new LimitSegment(0, 0, new NumberLiteralRowNumberValueSegment(0, 0, 1L, true), null));
SelectStatementContext selectStatementContext = new SelectStatementContext(
- sqlserverDatabaseType, selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
+ selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
MergedResult actual = resultMerger.merge(createQueryResults(), selectStatementContext, createSQLServerDatabase(), mock(ConnectionContext.class));
assertThat(actual, instanceOf(TopAndRowNumberDecoratorMergedResult.class));
assertThat(((TopAndRowNumberDecoratorMergedResult) actual).getMergedResult(), instanceOf(OrderByStreamMergedResult.class));
@@ -239,7 +239,7 @@ class ShardingDQLResultMergerTest {
selectStatement.setOrderBy(new OrderBySegment(0, 0, Collections.singletonList(new IndexOrderByItemSegment(0, 0, 1, OrderDirection.DESC, NullsOrderType.FIRST))));
selectStatement.setProjections(new ProjectionsSegment(0, 0));
SelectStatementContext selectStatementContext = new SelectStatementContext(
- mysqlDatabaseType, selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
+ selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
assertThat(resultMerger.merge(createQueryResults(), selectStatementContext, createDatabase(), mock(ConnectionContext.class)), instanceOf(GroupByStreamMergedResult.class));
}
@@ -252,7 +252,7 @@ class ShardingDQLResultMergerTest {
selectStatement.setOrderBy(new OrderBySegment(0, 0, Collections.singletonList(new IndexOrderByItemSegment(0, 0, 1, OrderDirection.DESC, NullsOrderType.FIRST))));
selectStatement.setProjections(new ProjectionsSegment(0, 0));
selectStatement.setLimit(new LimitSegment(0, 0, new NumberLiteralLimitValueSegment(0, 0, 1L), null));
- SelectStatementContext selectStatementContext = new SelectStatementContext(mysqlDatabaseType,
+ SelectStatementContext selectStatementContext = new SelectStatementContext(
selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
MergedResult actual = resultMerger.merge(createQueryResults(), selectStatementContext, createDatabase(), mock(ConnectionContext.class));
assertThat(actual, instanceOf(LimitDecoratorMergedResult.class));
@@ -273,6 +273,7 @@ class ShardingDQLResultMergerTest {
SubqueryTableSegment subqueryTableSegment = mock(SubqueryTableSegment.class);
SubquerySegment subquerySegment = mock(SubquerySegment.class);
SelectStatement subSelectStatement = mock(SelectStatement.class);
+ when(subSelectStatement.getDatabaseType()).thenReturn(oracleDatabaseType);
ProjectionsSegment subProjectionsSegment = mock(ProjectionsSegment.class);
when(subSelectStatement.getProjections()).thenReturn(subProjectionsSegment);
when(subquerySegment.getSelect()).thenReturn(subSelectStatement);
@@ -283,8 +284,7 @@ class ShardingDQLResultMergerTest {
selectStatement.setProjections(new ProjectionsSegment(0, 0));
selectStatement.setFrom(subqueryTableSegment);
selectStatement.setWhere(whereSegment);
- SelectStatementContext selectStatementContext = new SelectStatementContext(
- oracleDatabaseType, selectStatement, null, createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
+ SelectStatementContext selectStatementContext = new SelectStatementContext(selectStatement, null, createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
MergedResult actual = resultMerger.merge(createQueryResults(), selectStatementContext, createDatabase(), mock(ConnectionContext.class));
assertThat(actual, instanceOf(GroupByStreamMergedResult.class));
}
@@ -299,7 +299,7 @@ class ShardingDQLResultMergerTest {
selectStatement.setProjections(new ProjectionsSegment(0, 0));
selectStatement.setLimit(new LimitSegment(0, 0, new NumberLiteralRowNumberValueSegment(0, 0, 1L, true), null));
SelectStatementContext selectStatementContext = new SelectStatementContext(
- sqlserverDatabaseType, selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
+ selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
MergedResult actual = resultMerger.merge(createQueryResults(), selectStatementContext, createSQLServerDatabase(), mock(ConnectionContext.class));
assertThat(actual, instanceOf(TopAndRowNumberDecoratorMergedResult.class));
assertThat(((TopAndRowNumberDecoratorMergedResult) actual).getMergedResult(), instanceOf(GroupByStreamMergedResult.class));
@@ -313,7 +313,7 @@ class ShardingDQLResultMergerTest {
selectStatement.setGroupBy(new GroupBySegment(0, 0, Collections.singletonList(new IndexOrderByItemSegment(0, 0, 1, OrderDirection.DESC, NullsOrderType.FIRST))));
selectStatement.setProjections(new ProjectionsSegment(0, 0));
SelectStatementContext selectStatementContext = new SelectStatementContext(
- mysqlDatabaseType, selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
+ selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
assertThat(resultMerger.merge(createQueryResults(), selectStatementContext, createDatabase(), mock(ConnectionContext.class)), instanceOf(GroupByStreamMergedResult.class));
}
@@ -326,7 +326,7 @@ class ShardingDQLResultMergerTest {
selectStatement.setProjections(new ProjectionsSegment(0, 0));
selectStatement.setLimit(new LimitSegment(0, 0, new NumberLiteralLimitValueSegment(0, 0, 1L), null));
SelectStatementContext selectStatementContext = new SelectStatementContext(
- mysqlDatabaseType, selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
+ selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
MergedResult actual = resultMerger.merge(createQueryResults(), selectStatementContext, createDatabase(), mock(ConnectionContext.class));
assertThat(actual, instanceOf(LimitDecoratorMergedResult.class));
assertThat(((LimitDecoratorMergedResult) actual).getMergedResult(), instanceOf(GroupByStreamMergedResult.class));
@@ -346,6 +346,7 @@ class ShardingDQLResultMergerTest {
SubqueryTableSegment subqueryTableSegment = mock(SubqueryTableSegment.class);
SubquerySegment subquerySegment = mock(SubquerySegment.class);
SelectStatement subSelectStatement = mock(SelectStatement.class);
+ when(subSelectStatement.getDatabaseType()).thenReturn(oracleDatabaseType);
ProjectionsSegment subProjectionsSegment = mock(ProjectionsSegment.class);
when(subSelectStatement.getProjections()).thenReturn(subProjectionsSegment);
when(subquerySegment.getSelect()).thenReturn(subSelectStatement);
@@ -356,8 +357,7 @@ class ShardingDQLResultMergerTest {
selectStatement.setProjections(new ProjectionsSegment(0, 0));
selectStatement.setFrom(subqueryTableSegment);
selectStatement.setWhere(whereSegment);
- SelectStatementContext selectStatementContext = new SelectStatementContext(
- oracleDatabaseType, selectStatement, null, createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
+ SelectStatementContext selectStatementContext = new SelectStatementContext(selectStatement, null, createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
MergedResult actual = resultMerger.merge(createQueryResults(), selectStatementContext, createDatabase(), mock(ConnectionContext.class));
assertThat(actual, instanceOf(GroupByStreamMergedResult.class));
}
@@ -373,7 +373,7 @@ class ShardingDQLResultMergerTest {
selectStatement.setOrderBy(new OrderBySegment(0, 0, Collections.singletonList(new IndexOrderByItemSegment(0, 0, 1, OrderDirection.ASC, NullsOrderType.FIRST))));
selectStatement.setLimit(new LimitSegment(0, 0, new NumberLiteralRowNumberValueSegment(0, 0, 1L, true), null));
SelectStatementContext selectStatementContext = new SelectStatementContext(
- sqlserverDatabaseType, selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
+ selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
MergedResult actual = resultMerger.merge(createQueryResults(), selectStatementContext, createSQLServerDatabase(), mock(ConnectionContext.class));
assertThat(actual, instanceOf(TopAndRowNumberDecoratorMergedResult.class));
assertThat(((TopAndRowNumberDecoratorMergedResult) actual).getMergedResult(), instanceOf(GroupByMemoryMergedResult.class));
@@ -388,7 +388,7 @@ class ShardingDQLResultMergerTest {
projectionsSegment.getProjections().add(new AggregationProjectionSegment(0, 0, AggregationType.COUNT, "COUNT(*)"));
selectStatement.setProjections(projectionsSegment);
SelectStatementContext selectStatementContext = new SelectStatementContext(
- mysqlDatabaseType, selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
+ selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
assertThat(resultMerger.merge(createQueryResults(), selectStatementContext, createDatabase(), mock(ConnectionContext.class)), instanceOf(GroupByMemoryMergedResult.class));
}
@@ -400,7 +400,7 @@ class ShardingDQLResultMergerTest {
selectStatement.setProjections(projectionsSegment);
selectStatement.setLimit(new LimitSegment(0, 0, new NumberLiteralLimitValueSegment(0, 0, 1L), null));
SelectStatementContext selectStatementContext = new SelectStatementContext(
- mysqlDatabaseType, selectStatement, Collections.emptyList(), createShardingSphereMetaData(mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS)), "foo_db", Collections.emptyList());
+ selectStatement, Collections.emptyList(), createShardingSphereMetaData(mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS)), "foo_db", Collections.emptyList());
ShardingDQLResultMerger resultMerger = new ShardingDQLResultMerger(mysqlDatabaseType);
MergedResult actual = resultMerger.merge(createQueryResults(), selectStatementContext, createDatabase(), mock(ConnectionContext.class));
assertThat(actual, instanceOf(LimitDecoratorMergedResult.class));
@@ -420,6 +420,7 @@ class ShardingDQLResultMergerTest {
SubqueryTableSegment subqueryTableSegment = mock(SubqueryTableSegment.class);
SubquerySegment subquerySegment = mock(SubquerySegment.class);
SelectStatement subSelectStatement = mock(SelectStatement.class);
+ when(subSelectStatement.getDatabaseType()).thenReturn(oracleDatabaseType);
ProjectionsSegment subProjectionsSegment = mock(ProjectionsSegment.class);
when(subSelectStatement.getProjections()).thenReturn(subProjectionsSegment);
when(subquerySegment.getSelect()).thenReturn(subSelectStatement);
@@ -430,8 +431,7 @@ class ShardingDQLResultMergerTest {
selectStatement.setProjections(projectionsSegment);
selectStatement.setFrom(subqueryTableSegment);
selectStatement.setWhere(whereSegment);
- SelectStatementContext selectStatementContext = new SelectStatementContext(
- oracleDatabaseType, selectStatement, null, createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
+ SelectStatementContext selectStatementContext = new SelectStatementContext(selectStatement, null, createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
MergedResult actual = resultMerger.merge(createQueryResults(), selectStatementContext, createDatabase(), mock(ConnectionContext.class));
assertThat(actual, instanceOf(GroupByMemoryMergedResult.class));
}
@@ -444,7 +444,7 @@ class ShardingDQLResultMergerTest {
projectionsSegment.getProjections().add(new AggregationProjectionSegment(0, 0, AggregationType.COUNT, "COUNT(*)"));
selectStatement.setProjections(projectionsSegment);
selectStatement.setLimit(new LimitSegment(0, 0, new NumberLiteralRowNumberValueSegment(0, 0, 1L, true), null));
- SelectStatementContext selectStatementContext = new SelectStatementContext(sqlserverDatabaseType,
+ SelectStatementContext selectStatementContext = new SelectStatementContext(
selectStatement, Collections.emptyList(), createShardingSphereMetaData(mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS)), "foo_db", Collections.emptyList());
MergedResult actual = resultMerger.merge(createQueryResults(), selectStatementContext, createSQLServerDatabase(), mock(ConnectionContext.class));
assertThat(actual, instanceOf(TopAndRowNumberDecoratorMergedResult.class));
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/groupby/GroupByMemoryMergedResultTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/groupby/GroupByMemoryMergedResultTest.java
index 4aa8fa94db8..bd64277779d 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/groupby/GroupByMemoryMergedResultTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/groupby/GroupByMemoryMergedResultTest.java
@@ -126,7 +126,7 @@ class GroupByMemoryMergedResultTest {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
when(database.getName()).thenReturn("foo_db");
return new SelectStatementContext(
- databaseType, selectStatement, Collections.emptyList(), new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), mock()), "foo_db", Collections.emptyList());
+ selectStatement, Collections.emptyList(), new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), mock()), "foo_db", Collections.emptyList());
}
private SelectStatementContext createSelectStatementContext(final ShardingSphereDatabase database) {
@@ -139,7 +139,7 @@ class GroupByMemoryMergedResultTest {
selectStatement.setFrom(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("t_order"))));
selectStatement.setProjections(projectionsSegment);
return new SelectStatementContext(
- databaseType, selectStatement, Collections.emptyList(), new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), mock()), "foo_db", Collections.emptyList());
+ selectStatement, Collections.emptyList(), new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), mock()), "foo_db", Collections.emptyList());
}
@Test
@@ -247,7 +247,7 @@ class GroupByMemoryMergedResultTest {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
when(database.getName()).thenReturn("foo_db");
return new SelectStatementContext(
- databaseType, selectStatement, Collections.emptyList(), new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), mock()), "foo_db", Collections.emptyList());
+ selectStatement, Collections.emptyList(), new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), mock()), "foo_db", Collections.emptyList());
}
private SelectStatementContext createSelectStatementContextForCountGroupByDifferentOrderBy() {
@@ -260,6 +260,6 @@ class GroupByMemoryMergedResultTest {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
when(database.getName()).thenReturn("foo_db");
return new SelectStatementContext(
- databaseType, selectStatement, Collections.emptyList(), new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), mock()), "foo_db", Collections.emptyList());
+ selectStatement, Collections.emptyList(), new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), mock()), "foo_db", Collections.emptyList());
}
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/groupby/GroupByRowComparatorTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/groupby/GroupByRowComparatorTest.java
index 55c30c366ae..a36710550ee 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/groupby/GroupByRowComparatorTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/groupby/GroupByRowComparatorTest.java
@@ -66,7 +66,7 @@ class GroupByRowComparatorTest {
new IndexOrderByItemSegment(0, 0, 2, OrderDirection.ASC, NullsOrderType.FIRST))));
selectStatement.setProjections(new ProjectionsSegment(0, 0));
SelectStatementContext selectStatementContext = new SelectStatementContext(
- databaseType, selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
+ selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
GroupByRowComparator groupByRowComparator = new GroupByRowComparator(selectStatementContext, caseSensitives);
MemoryQueryResultRow o1 = new MemoryQueryResultRow(mockQueryResult("1", "2"));
MemoryQueryResultRow o2 = new MemoryQueryResultRow(mockQueryResult("3", "4"));
@@ -86,7 +86,7 @@ class GroupByRowComparatorTest {
new IndexOrderByItemSegment(0, 0, 2, OrderDirection.DESC, NullsOrderType.FIRST))));
selectStatement.setProjections(new ProjectionsSegment(0, 0));
SelectStatementContext selectStatementContext = new SelectStatementContext(
- databaseType, selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
+ selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
GroupByRowComparator groupByRowComparator = new GroupByRowComparator(selectStatementContext, caseSensitives);
MemoryQueryResultRow o1 = new MemoryQueryResultRow(mockQueryResult("1", "2"));
MemoryQueryResultRow o2 = new MemoryQueryResultRow(mockQueryResult("3", "4"));
@@ -106,7 +106,7 @@ class GroupByRowComparatorTest {
new IndexOrderByItemSegment(0, 0, 2, OrderDirection.DESC, NullsOrderType.FIRST))));
selectStatement.setProjections(new ProjectionsSegment(0, 0));
SelectStatementContext selectStatementContext = new SelectStatementContext(
- databaseType, selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
+ selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
GroupByRowComparator groupByRowComparator = new GroupByRowComparator(selectStatementContext, caseSensitives);
MemoryQueryResultRow o1 = new MemoryQueryResultRow(mockQueryResult("1", "2"));
MemoryQueryResultRow o2 = new MemoryQueryResultRow(mockQueryResult("1", "2"));
@@ -123,7 +123,7 @@ class GroupByRowComparatorTest {
new IndexOrderByItemSegment(0, 0, 2, OrderDirection.ASC, NullsOrderType.FIRST))));
selectStatement.setOrderBy(new OrderBySegment(0, 0, Collections.emptyList()));
selectStatement.setProjections(new ProjectionsSegment(0, 0));
- SelectStatementContext selectStatementContext = new SelectStatementContext(databaseType,
+ SelectStatementContext selectStatementContext = new SelectStatementContext(
selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
GroupByRowComparator groupByRowComparator = new GroupByRowComparator(selectStatementContext, caseSensitives);
MemoryQueryResultRow o1 = new MemoryQueryResultRow(mockQueryResult("1", "2"));
@@ -142,7 +142,7 @@ class GroupByRowComparatorTest {
selectStatement.setOrderBy(new OrderBySegment(0, 0, Collections.emptyList()));
selectStatement.setProjections(new ProjectionsSegment(0, 0));
SelectStatementContext selectStatementContext = new SelectStatementContext(
- databaseType, selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
+ selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
GroupByRowComparator groupByRowComparator = new GroupByRowComparator(selectStatementContext, caseSensitives);
MemoryQueryResultRow o1 = new MemoryQueryResultRow(mockQueryResult("1", "2"));
MemoryQueryResultRow o2 = new MemoryQueryResultRow(mockQueryResult("3", "4"));
@@ -164,7 +164,7 @@ class GroupByRowComparatorTest {
selectStatement.setOrderBy(new OrderBySegment(0, 0, Collections.emptyList()));
selectStatement.setProjections(new ProjectionsSegment(0, 0));
SelectStatementContext selectStatementContext = new SelectStatementContext(
- databaseType, selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
+ selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
GroupByRowComparator groupByRowComparator = new GroupByRowComparator(selectStatementContext, caseSensitives);
MemoryQueryResultRow o1 = new MemoryQueryResultRow(mockQueryResult("1", "2"));
MemoryQueryResultRow o2 = new MemoryQueryResultRow(mockQueryResult("1", "2"));
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/groupby/GroupByStreamMergedResultTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/groupby/GroupByStreamMergedResultTest.java
index 46fb2f2ccd3..6d838e21c1e 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/groupby/GroupByStreamMergedResultTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/groupby/GroupByStreamMergedResultTest.java
@@ -176,7 +176,7 @@ class GroupByStreamMergedResultTest {
selectStatement.setGroupBy(new GroupBySegment(0, 0, Collections.singletonList(new IndexOrderByItemSegment(0, 0, 3, OrderDirection.ASC, NullsOrderType.FIRST))));
selectStatement.setOrderBy(new OrderBySegment(0, 0, Collections.singletonList(new IndexOrderByItemSegment(0, 0, 3, OrderDirection.ASC, NullsOrderType.FIRST))));
return new SelectStatementContext(
- databaseType, selectStatement, Collections.emptyList(), new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), mock()), "foo_db", Collections.emptyList());
+ selectStatement, Collections.emptyList(), new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), mock()), "foo_db", Collections.emptyList());
}
private ShardingSphereDatabase createDatabase() {
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/orderby/OrderByStreamMergedResultTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/orderby/OrderByStreamMergedResultTest.java
index 337939210e2..aa4a7b224f6 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/orderby/OrderByStreamMergedResultTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/orderby/OrderByStreamMergedResultTest.java
@@ -75,7 +75,7 @@ class OrderByStreamMergedResultTest {
new IndexOrderByItemSegment(0, 0, 1, OrderDirection.ASC, NullsOrderType.FIRST),
new IndexOrderByItemSegment(0, 0, 2, OrderDirection.ASC, NullsOrderType.FIRST))));
selectStatement.setProjections(new ProjectionsSegment(0, 0));
- selectStatementContext = new SelectStatementContext(databaseType, selectStatement, Collections.emptyList(), createShardingSphereMetaData(), "foo_db", Collections.emptyList());
+ selectStatementContext = new SelectStatementContext(selectStatement, Collections.emptyList(), createShardingSphereMetaData(), "foo_db", Collections.emptyList());
}
private ShardingSphereMetaData createShardingSphereMetaData() {
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/orderby/OrderByValueTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/orderby/OrderByValueTest.java
index 15911366632..629d5da7a64 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/orderby/OrderByValueTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/orderby/OrderByValueTest.java
@@ -65,8 +65,7 @@ class OrderByValueTest {
ProjectionsSegment projectionsSegment = new ProjectionsSegment(0, 0);
selectStatement.setProjections(projectionsSegment);
selectStatement.setOrderBy(createOrderBySegment());
- SelectStatementContext selectStatementContext = new SelectStatementContext(
- databaseType, selectStatement, Collections.emptyList(), createShardingSphereMetaData(), "foo_db", Collections.emptyList());
+ SelectStatementContext selectStatementContext = new SelectStatementContext(selectStatement, Collections.emptyList(), createShardingSphereMetaData(), "foo_db", Collections.emptyList());
ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
QueryResult queryResult1 = createQueryResult("1", "2");
OrderByValue orderByValue1 = new OrderByValue(queryResult1, Arrays.asList(
@@ -99,8 +98,7 @@ class OrderByValueTest {
ProjectionsSegment projectionsSegment = new ProjectionsSegment(0, 0);
selectStatement.setProjections(projectionsSegment);
selectStatement.setOrderBy(createOrderBySegment());
- SelectStatementContext selectStatementContext = new SelectStatementContext(
- databaseType, selectStatement, Collections.emptyList(), createShardingSphereMetaData(), "foo_db", Collections.emptyList());
+ SelectStatementContext selectStatementContext = new SelectStatementContext(selectStatement, Collections.emptyList(), createShardingSphereMetaData(), "foo_db", Collections.emptyList());
ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
when(schema.getTable("foo_tbl")).thenReturn(new ShardingSphereTable("foo_tbl", Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), TableType.TABLE));
QueryResult queryResult1 = createQueryResult("1", "2");
@@ -128,8 +126,7 @@ class OrderByValueTest {
ProjectionsSegment projectionsSegment = new ProjectionsSegment(0, 0);
selectStatement.setProjections(projectionsSegment);
selectStatement.setOrderBy(createOrderBySegment());
- SelectStatementContext selectStatementContext = new SelectStatementContext(
- databaseType, selectStatement, Collections.emptyList(), createShardingSphereMetaData(), "foo_db", Collections.emptyList());
+ SelectStatementContext selectStatementContext = new SelectStatementContext(selectStatement, Collections.emptyList(), createShardingSphereMetaData(), "foo_db", Collections.emptyList());
ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
QueryResult queryResult1 = createQueryResult("1", "2");
OrderByValue orderByValue1 = new OrderByValue(queryResult1, Arrays.asList(
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/pagination/LimitDecoratorMergedResultTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/pagination/LimitDecoratorMergedResultTest.java
index e21b5107323..3c205bcc206 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/pagination/LimitDecoratorMergedResultTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/pagination/LimitDecoratorMergedResultTest.java
@@ -54,7 +54,7 @@ class LimitDecoratorMergedResultTest {
selectStatement.setProjections(new ProjectionsSegment(0, 0));
selectStatement.setLimit(new LimitSegment(0, 0, new NumberLiteralLimitValueSegment(0, 0, Long.MAX_VALUE), null));
SelectStatementContext selectStatementContext = new SelectStatementContext(
- databaseType, selectStatement, Collections.emptyList(), new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), mock()), "foo_db", Collections.emptyList());
+ selectStatement, Collections.emptyList(), new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), mock()), "foo_db", Collections.emptyList());
ShardingDQLResultMerger resultMerger = new ShardingDQLResultMerger(databaseType);
MergedResult actual = resultMerger.merge(Arrays.asList(mockQueryResult(), mockQueryResult(), mockQueryResult(), mockQueryResult()), selectStatementContext, database,
mock(ConnectionContext.class));
@@ -69,7 +69,7 @@ class LimitDecoratorMergedResultTest {
selectStatement.setProjections(new ProjectionsSegment(0, 0));
selectStatement.setLimit(new LimitSegment(0, 0, new NumberLiteralLimitValueSegment(0, 0, 2L), null));
SelectStatementContext selectStatementContext = new SelectStatementContext(
- databaseType, selectStatement, Collections.emptyList(), new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), mock()), "foo_db", Collections.emptyList());
+ selectStatement, Collections.emptyList(), new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), mock()), "foo_db", Collections.emptyList());
ShardingDQLResultMerger resultMerger = new ShardingDQLResultMerger(databaseType);
MergedResult actual = resultMerger.merge(Arrays.asList(mockQueryResult(), mockQueryResult(), mockQueryResult(), mockQueryResult()), selectStatementContext, database,
mock(ConnectionContext.class));
@@ -87,7 +87,7 @@ class LimitDecoratorMergedResultTest {
selectStatement.setProjections(new ProjectionsSegment(0, 0));
selectStatement.setLimit(new LimitSegment(0, 0, new NumberLiteralLimitValueSegment(0, 0, 2L), new NumberLiteralLimitValueSegment(0, 0, 2L)));
SelectStatementContext selectStatementContext = new SelectStatementContext(
- databaseType, selectStatement, Collections.emptyList(), new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), mock()), "foo_db", Collections.emptyList());
+ selectStatement, Collections.emptyList(), new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), mock()), "foo_db", Collections.emptyList());
ShardingDQLResultMerger resultMerger = new ShardingDQLResultMerger(databaseType);
MergedResult actual = resultMerger.merge(
Arrays.asList(mockQueryResult(), mockQueryResult(), mockQueryResult(), mockQueryResult()), selectStatementContext, database, mock(ConnectionContext.class));
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/pagination/RowNumberDecoratorMergedResultTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/pagination/RowNumberDecoratorMergedResultTest.java
index 325ef4ddc64..eb67722c0b2 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/pagination/RowNumberDecoratorMergedResultTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/pagination/RowNumberDecoratorMergedResultTest.java
@@ -68,6 +68,7 @@ class RowNumberDecoratorMergedResultTest {
SubqueryTableSegment subqueryTableSegment = mock(SubqueryTableSegment.class);
SubquerySegment subquerySegment = mock(SubquerySegment.class);
SelectStatement subSelectStatement = mock(SelectStatement.class);
+ when(subSelectStatement.getDatabaseType()).thenReturn(databaseType);
ProjectionsSegment subProjectionsSegment = mock(ProjectionsSegment.class);
when(subSelectStatement.getProjections()).thenReturn(subProjectionsSegment);
when(subquerySegment.getSelect()).thenReturn(subSelectStatement);
@@ -77,7 +78,7 @@ class RowNumberDecoratorMergedResultTest {
ShardingDQLResultMerger resultMerger = new ShardingDQLResultMerger(databaseType);
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
when(database.getName()).thenReturn("foo_db");
- SelectStatementContext selectStatementContext = new SelectStatementContext(databaseType, selectStatement, null, createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
+ SelectStatementContext selectStatementContext = new SelectStatementContext(selectStatement, null, createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
MergedResult actual = resultMerger.merge(
Arrays.asList(mockQueryResult(), mockQueryResult(), mockQueryResult(), mockQueryResult()), selectStatementContext, database, mock(ConnectionContext.class));
for (int i = 0; i < 8; i++) {
@@ -93,7 +94,7 @@ class RowNumberDecoratorMergedResultTest {
when(database.getName()).thenReturn("foo_db");
SelectStatement selectStatement = new SelectStatement(databaseType);
selectStatement.setProjections(new ProjectionsSegment(0, 0));
- SelectStatementContext selectStatementContext = new SelectStatementContext(databaseType, selectStatement, null, createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
+ SelectStatementContext selectStatementContext = new SelectStatementContext(selectStatement, null, createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
MergedResult actual = resultMerger.merge(Arrays.asList(mockQueryResult(), mockQueryResult(), mockQueryResult(), mockQueryResult()), selectStatementContext, database,
mock(ConnectionContext.class));
for (int i = 0; i < 8; i++) {
@@ -116,6 +117,7 @@ class RowNumberDecoratorMergedResultTest {
SubqueryTableSegment subqueryTableSegment = mock(SubqueryTableSegment.class);
SubquerySegment subquerySegment = mock(SubquerySegment.class);
SelectStatement subSelectStatement = mock(SelectStatement.class);
+ when(subSelectStatement.getDatabaseType()).thenReturn(databaseType);
ProjectionsSegment subProjectionsSegment = mock(ProjectionsSegment.class);
when(subSelectStatement.getProjections()).thenReturn(subProjectionsSegment);
when(subquerySegment.getSelect()).thenReturn(subSelectStatement);
@@ -125,7 +127,7 @@ class RowNumberDecoratorMergedResultTest {
ShardingDQLResultMerger resultMerger = new ShardingDQLResultMerger(databaseType);
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
when(database.getName()).thenReturn("foo_db");
- SelectStatementContext selectStatementContext = new SelectStatementContext(databaseType, selectStatement, null, createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
+ SelectStatementContext selectStatementContext = new SelectStatementContext(selectStatement, null, createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
MergedResult actual = resultMerger.merge(Arrays.asList(mockQueryResult(), mockQueryResult(), mockQueryResult(), mockQueryResult()), selectStatementContext, database,
mock(ConnectionContext.class));
for (int i = 0; i < 8; i++) {
@@ -148,6 +150,7 @@ class RowNumberDecoratorMergedResultTest {
SubqueryTableSegment subqueryTableSegment = mock(SubqueryTableSegment.class);
SubquerySegment subquerySegment = mock(SubquerySegment.class);
SelectStatement subSelectStatement = mock(SelectStatement.class);
+ when(subSelectStatement.getDatabaseType()).thenReturn(databaseType);
ProjectionsSegment subProjectionsSegment = mock(ProjectionsSegment.class);
when(subSelectStatement.getProjections()).thenReturn(subProjectionsSegment);
when(subquerySegment.getSelect()).thenReturn(subSelectStatement);
@@ -157,7 +160,7 @@ class RowNumberDecoratorMergedResultTest {
ShardingDQLResultMerger resultMerger = new ShardingDQLResultMerger(databaseType);
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
when(database.getName()).thenReturn("foo_db");
- SelectStatementContext selectStatementContext = new SelectStatementContext(databaseType, selectStatement, null, createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
+ SelectStatementContext selectStatementContext = new SelectStatementContext(selectStatement, null, createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
MergedResult actual =
resultMerger.merge(Arrays.asList(mockQueryResult(), mockQueryResult(), mockQueryResult(), mockQueryResult()), selectStatementContext, database, mock(ConnectionContext.class));
for (int i = 0; i < 8; i++) {
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/pagination/TopAndRowNumberDecoratorMergedResultTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/pagination/TopAndRowNumberDecoratorMergedResultTest.java
index b487449058a..47b0f48d5c8 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/pagination/TopAndRowNumberDecoratorMergedResultTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/pagination/TopAndRowNumberDecoratorMergedResultTest.java
@@ -55,7 +55,7 @@ class TopAndRowNumberDecoratorMergedResultTest {
sqlStatement.setProjections(new ProjectionsSegment(0, 0));
sqlStatement.setLimit(new LimitSegment(0, 0, new NumberLiteralRowNumberValueSegment(0, 0, Long.MAX_VALUE, true), null));
SelectStatementContext selectStatementContext = new SelectStatementContext(
- databaseType, sqlStatement, Collections.emptyList(), new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), mock()), "foo_db", Collections.emptyList());
+ sqlStatement, Collections.emptyList(), new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), mock()), "foo_db", Collections.emptyList());
ShardingDQLResultMerger resultMerger = new ShardingDQLResultMerger(databaseType);
MergedResult actual = resultMerger.merge(
Arrays.asList(mockQueryResult(), mockQueryResult(), mockQueryResult(), mockQueryResult()), selectStatementContext, mockDatabase(), mock(ConnectionContext.class));
@@ -71,7 +71,7 @@ class TopAndRowNumberDecoratorMergedResultTest {
sqlStatement.setProjections(new ProjectionsSegment(0, 0));
sqlStatement.setLimit(new LimitSegment(0, 0, null, new NumberLiteralLimitValueSegment(0, 0, 5L)));
SelectStatementContext selectStatementContext = new SelectStatementContext(
- databaseType, sqlStatement, Collections.emptyList(), new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), mock()), "foo_db", Collections.emptyList());
+ sqlStatement, Collections.emptyList(), new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), mock()), "foo_db", Collections.emptyList());
MergedResult actual = resultMerger.merge(
Arrays.asList(mockQueryResult(), mockQueryResult(), mockQueryResult(), mockQueryResult()), selectStatementContext, mockDatabase(), mock(ConnectionContext.class));
for (int i = 0; i < 5; i++) {
@@ -88,7 +88,7 @@ class TopAndRowNumberDecoratorMergedResultTest {
sqlStatement.setProjections(new ProjectionsSegment(0, 0));
sqlStatement.setLimit(new LimitSegment(0, 0, new NumberLiteralRowNumberValueSegment(0, 0, 2L, true), null));
SelectStatementContext selectStatementContext = new SelectStatementContext(
- databaseType, sqlStatement, Collections.emptyList(), new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), mock()), "foo_db", Collections.emptyList());
+ sqlStatement, Collections.emptyList(), new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), mock()), "foo_db", Collections.emptyList());
ShardingDQLResultMerger resultMerger = new ShardingDQLResultMerger(databaseType);
MergedResult actual = resultMerger.merge(
Arrays.asList(mockQueryResult(), mockQueryResult(), mockQueryResult(), mockQueryResult()), selectStatementContext, mockDatabase(), mock(ConnectionContext.class));
@@ -107,7 +107,7 @@ class TopAndRowNumberDecoratorMergedResultTest {
sqlStatement.setProjections(new ProjectionsSegment(0, 0));
sqlStatement.setLimit(new LimitSegment(0, 0, new NumberLiteralRowNumberValueSegment(0, 0, 2L, false), new NumberLiteralLimitValueSegment(0, 0, 4L)));
SelectStatementContext selectStatementContext = new SelectStatementContext(
- databaseType, sqlStatement, Collections.emptyList(), new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), mock()), "foo_db", Collections.emptyList());
+ sqlStatement, Collections.emptyList(), new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), mock()), "foo_db", Collections.emptyList());
MergedResult actual = resultMerger.merge(
Arrays.asList(mockQueryResult(), mockQueryResult(), mockQueryResult(), mockQueryResult()), selectStatementContext, mockDatabase(), mock(ConnectionContext.class));
assertTrue(actual.next());
@@ -124,7 +124,7 @@ class TopAndRowNumberDecoratorMergedResultTest {
sqlStatement.setProjections(new ProjectionsSegment(0, 0));
sqlStatement.setLimit(new LimitSegment(0, 0, new NumberLiteralRowNumberValueSegment(0, 0, 2L, true), new NumberLiteralLimitValueSegment(0, 0, 4L)));
SelectStatementContext selectStatementContext = new SelectStatementContext(
- databaseType, sqlStatement, Collections.emptyList(), new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), mock()), "foo_db", Collections.emptyList());
+ sqlStatement, Collections.emptyList(), new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), mock()), "foo_db", Collections.emptyList());
MergedResult actual = resultMerger.merge(
Arrays.asList(mockQueryResult(), mockQueryResult(), mockQueryResult(), mockQueryResult()), selectStatementContext, mockDatabase(), mock(ConnectionContext.class));
assertTrue(actual.next());
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/generator/impl/ShardingIndexTokenGeneratorTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/generator/impl/ShardingIndexTokenGeneratorTest.java
index c7c6354745f..6d8c9904538 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/generator/impl/ShardingIndexTokenGeneratorTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/generator/impl/ShardingIndexTokenGeneratorTest.java
@@ -61,7 +61,7 @@ class ShardingIndexTokenGeneratorTest {
@Test
void assertIsNotGenerateSQLTokenWithEmptyIndex() {
- CommonSQLStatementContext sqlStatementContext = new CommonSQLStatementContext(postgreSQLDatabaseType, new AlterIndexStatement(postgreSQLDatabaseType));
+ CommonSQLStatementContext sqlStatementContext = new CommonSQLStatementContext(new AlterIndexStatement(postgreSQLDatabaseType));
assertFalse(generator.isGenerateSQLToken(sqlStatementContext));
}
@@ -69,13 +69,13 @@ class ShardingIndexTokenGeneratorTest {
void assertIsGenerateSQLToken() {
AlterIndexStatement sqlStatement = new AlterIndexStatement(postgreSQLDatabaseType);
sqlStatement.setIndex(mock(IndexSegment.class));
- CommonSQLStatementContext sqlStatementContext = new CommonSQLStatementContext(postgreSQLDatabaseType, sqlStatement);
+ CommonSQLStatementContext sqlStatementContext = new CommonSQLStatementContext(sqlStatement);
assertTrue(generator.isGenerateSQLToken(sqlStatementContext));
}
@Test
void assertGenerateSQLTokensWithNotIndexContextAvailable() {
- CommonSQLStatementContext sqlStatementContext = new CommonSQLStatementContext(mock(), new AlterIndexStatement(databaseType));
+ CommonSQLStatementContext sqlStatementContext = new CommonSQLStatementContext(new AlterIndexStatement(databaseType));
Collection<SQLToken> actual = generator.generateSQLTokens(sqlStatementContext);
assertTrue(actual.isEmpty());
}
@@ -104,7 +104,7 @@ class ShardingIndexTokenGeneratorTest {
private CommonSQLStatementContext mockAlterIndexStatementContext(final IndexSegment indexSegment) {
AlterIndexStatement sqlStatement = new AlterIndexStatement(databaseType);
sqlStatement.setIndex(indexSegment);
- return new CommonSQLStatementContext(databaseType, sqlStatement);
+ return new CommonSQLStatementContext(sqlStatement);
}
private void assertTokens(final Collection<SQLToken> actual, final ShardingSphereSchema schema) throws ReflectiveOperationException {
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/generator/impl/ShardingRemoveTokenGeneratorTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/generator/impl/ShardingRemoveTokenGeneratorTest.java
index cba77d48965..c6273744e51 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/generator/impl/ShardingRemoveTokenGeneratorTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/generator/impl/ShardingRemoveTokenGeneratorTest.java
@@ -87,9 +87,8 @@ class ShardingRemoveTokenGeneratorTest {
selectStatement.setProjections(createProjectionsSegment());
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
when(database.getName()).thenReturn("foo_db");
- DatabaseType databaseType = TypedSPILoader.getService(DatabaseType.class, "FIXTURE");
return new SelectStatementContext(
- databaseType, selectStatement, Collections.emptyList(), new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), mock()), "foo_db", Collections.emptyList());
+ selectStatement, Collections.emptyList(), new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), mock()), "foo_db", Collections.emptyList());
}
private ProjectionsSegment createProjectionsSegment() {
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/pojo/IndexTokenTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/pojo/IndexTokenTest.java
index 4f79794427d..404b0af71ec 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/pojo/IndexTokenTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/pojo/IndexTokenTest.java
@@ -63,7 +63,7 @@ class IndexTokenTest {
@Test
void assertToStringWithShardingTableAndGeneratedIndex() {
- CommonSQLStatementContext sqlStatementContext = new CommonSQLStatementContext(mock(), new CreateIndexStatement(databaseType));
+ CommonSQLStatementContext sqlStatementContext = new CommonSQLStatementContext(new CreateIndexStatement(databaseType));
IndexToken indexToken = new IndexToken(0, 0, new IdentifierValue("bar_idx"), sqlStatementContext, mock(ShardingRule.class), mockSchema());
assertThat(indexToken.toString(mockRouteUnit()), is(" bar_idx_foo_tbl_0 "));
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingAlterTableRouteContextCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingAlterTableRouteContextCheckerTest.java
index d75fb0cdd91..8c0d95a49b3 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingAlterTableRouteContextCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingAlterTableRouteContextCheckerTest.java
@@ -76,7 +76,7 @@ class ShardingAlterTableRouteContextCheckerTest {
routeUnits.add(new RouteUnit(new RouteMapper("ds_0", "ds_0"), Collections.singletonList(new RouteMapper("t_order", "t_order_0"))));
routeUnits.add(new RouteUnit(new RouteMapper("ds_1", "ds_1"), Collections.singletonList(new RouteMapper("t_order", "t_order_0"))));
when(routeContext.getRouteUnits()).thenReturn(routeUnits);
- when(queryContext.getSqlStatementContext()).thenReturn(new CommonSQLStatementContext(mock(), sqlStatement));
+ when(queryContext.getSqlStatementContext()).thenReturn(new CommonSQLStatementContext(sqlStatement));
assertDoesNotThrow(() -> new ShardingAlterTableRouteContextChecker().check(shardingRule, queryContext, database, mock(ConfigurationProperties.class), routeContext));
}
@@ -89,7 +89,7 @@ class ShardingAlterTableRouteContextCheckerTest {
Collection<RouteUnit> routeUnits = new LinkedList<>();
routeUnits.add(new RouteUnit(new RouteMapper("ds_0", "ds_0"), Collections.singletonList(new RouteMapper("t_order", "t_order_0"))));
when(routeContext.getRouteUnits()).thenReturn(routeUnits);
- when(queryContext.getSqlStatementContext()).thenReturn(new CommonSQLStatementContext(mock(), sqlStatement));
+ when(queryContext.getSqlStatementContext()).thenReturn(new CommonSQLStatementContext(sqlStatement));
assertThrows(ShardingDDLRouteException.class, () -> new ShardingAlterTableRouteContextChecker().check(shardingRule, queryContext, database, mock(ConfigurationProperties.class), routeContext));
}
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingCreateTableRouteContextCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingCreateTableRouteContextCheckerTest.java
index e16f0e00859..9bd56250813 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingCreateTableRouteContextCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingCreateTableRouteContextCheckerTest.java
@@ -77,7 +77,7 @@ class ShardingCreateTableRouteContextCheckerTest {
routeUnits.add(new RouteUnit(new RouteMapper("ds_0", "ds_0"), Collections.singletonList(new RouteMapper("t_order", "t_order_0"))));
routeUnits.add(new RouteUnit(new RouteMapper("ds_1", "ds_1"), Collections.singletonList(new RouteMapper("t_order", "t_order_0"))));
when(routeContext.getRouteUnits()).thenReturn(routeUnits);
- when(queryContext.getSqlStatementContext()).thenReturn(new CommonSQLStatementContext(mock(), sqlStatement));
+ when(queryContext.getSqlStatementContext()).thenReturn(new CommonSQLStatementContext(sqlStatement));
assertDoesNotThrow(() -> new ShardingCreateTableRouteContextChecker().check(shardingRule, queryContext, database, mock(ConfigurationProperties.class), routeContext));
}
@@ -91,7 +91,7 @@ class ShardingCreateTableRouteContextCheckerTest {
Collection<RouteUnit> routeUnits = new LinkedList<>();
routeUnits.add(new RouteUnit(new RouteMapper("ds_0", "ds_0"), Collections.singletonList(new RouteMapper("t_order", "t_order_0"))));
when(routeContext.getRouteUnits()).thenReturn(routeUnits);
- when(queryContext.getSqlStatementContext()).thenReturn(new CommonSQLStatementContext(mock(), sqlStatement));
+ when(queryContext.getSqlStatementContext()).thenReturn(new CommonSQLStatementContext(sqlStatement));
assertThrows(ShardingDDLRouteException.class,
() -> new ShardingCreateTableRouteContextChecker().check(shardingRule, queryContext, database, mock(ConfigurationProperties.class), routeContext));
}
@@ -101,7 +101,7 @@ class ShardingCreateTableRouteContextCheckerTest {
CreateTableStatement sqlStatement = new CreateTableStatement(databaseType);
sqlStatement.setIfNotExists(false);
sqlStatement.setTable(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("t_config"))));
- when(queryContext.getSqlStatementContext()).thenReturn(new CommonSQLStatementContext(mock(), sqlStatement));
+ when(queryContext.getSqlStatementContext()).thenReturn(new CommonSQLStatementContext(sqlStatement));
assertDoesNotThrow(() -> new ShardingCreateTableRouteContextChecker().check(shardingRule, queryContext, database, mock(ConfigurationProperties.class), routeContext));
}
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingDropIndexRouteContextCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingDropIndexRouteContextCheckerTest.java
index cc227a8e08f..f4fbf294fd0 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingDropIndexRouteContextCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingDropIndexRouteContextCheckerTest.java
@@ -83,7 +83,7 @@ class ShardingDropIndexRouteContextCheckerTest {
routeUnits.add(new RouteUnit(new RouteMapper("ds_0", "ds_0"), Collections.singletonList(new RouteMapper("t_order", "t_order_0"))));
routeUnits.add(new RouteUnit(new RouteMapper("ds_1", "ds_1"), Collections.singletonList(new RouteMapper("t_order", "t_order_0"))));
when(routeContext.getRouteUnits()).thenReturn(routeUnits);
- when(queryContext.getSqlStatementContext()).thenReturn(new CommonSQLStatementContext(databaseType, sqlStatement));
+ when(queryContext.getSqlStatementContext()).thenReturn(new CommonSQLStatementContext(sqlStatement));
assertDoesNotThrow(() -> new ShardingDropIndexRouteContextChecker().check(shardingRule, queryContext, database, mock(ConfigurationProperties.class), routeContext));
}
@@ -102,7 +102,7 @@ class ShardingDropIndexRouteContextCheckerTest {
Collection<RouteUnit> routeUnits = new LinkedList<>();
routeUnits.add(new RouteUnit(new RouteMapper("ds_0", "ds_0"), Collections.singletonList(new RouteMapper("t_order", "t_order_0"))));
when(routeContext.getRouteUnits()).thenReturn(routeUnits);
- when(queryContext.getSqlStatementContext()).thenReturn(new CommonSQLStatementContext(databaseType, sqlStatement));
+ when(queryContext.getSqlStatementContext()).thenReturn(new CommonSQLStatementContext(sqlStatement));
assertThrows(ShardingDDLRouteException.class, () -> new ShardingDropIndexRouteContextChecker().check(shardingRule, queryContext, database, mock(ConfigurationProperties.class), routeContext));
}
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingDropTableRouteContextCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingDropTableRouteContextCheckerTest.java
index 7d86e33de7c..450ab6b0c71 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingDropTableRouteContextCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingDropTableRouteContextCheckerTest.java
@@ -98,7 +98,7 @@ class ShardingDropTableRouteContextCheckerTest {
routeUnits.add(routeUnit);
RouteContext routeContext = mock(RouteContext.class);
when(routeContext.getRouteUnits()).thenReturn(routeUnits);
- when(queryContext.getSqlStatementContext()).thenReturn(new CommonSQLStatementContext(mock(), sqlStatement));
+ when(queryContext.getSqlStatementContext()).thenReturn(new CommonSQLStatementContext(sqlStatement));
assertThrows(InUsedTablesException.class, () -> new ShardingDropTableRouteContextChecker().check(shardingRule, queryContext, database, mock(ConfigurationProperties.class), routeContext));
}
@@ -132,7 +132,7 @@ class ShardingDropTableRouteContextCheckerTest {
routeUnits.add(new RouteUnit(new RouteMapper("ds_0", "ds_0"), Collections.singleton(new RouteMapper("t_order", "t_order_0"))));
routeUnits.add(new RouteUnit(new RouteMapper("ds_1", "ds_1"), Collections.singleton(new RouteMapper("t_order", "t_order_0"))));
when(routeContext.getRouteUnits()).thenReturn(routeUnits);
- when(queryContext.getSqlStatementContext()).thenReturn(new CommonSQLStatementContext(mock(), sqlStatement));
+ when(queryContext.getSqlStatementContext()).thenReturn(new CommonSQLStatementContext(sqlStatement));
assertDoesNotThrow(() -> new ShardingDropTableRouteContextChecker().check(shardingRule, queryContext, mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS),
mock(ConfigurationProperties.class), routeContext));
}
@@ -147,7 +147,7 @@ class ShardingDropTableRouteContextCheckerTest {
Collection<RouteUnit> routeUnits = new LinkedList<>();
routeUnits.add(new RouteUnit(new RouteMapper("ds_0", "ds_0"), Collections.singleton(new RouteMapper("t_order", "t_order_0"))));
when(routeContext.getRouteUnits()).thenReturn(routeUnits);
- when(queryContext.getSqlStatementContext()).thenReturn(new CommonSQLStatementContext(mock(), sqlStatement));
+ when(queryContext.getSqlStatementContext()).thenReturn(new CommonSQLStatementContext(sqlStatement));
assertThrows(ShardingDDLRouteException.class, () -> new ShardingDropTableRouteContextChecker().check(shardingRule, queryContext, mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS),
mock(ConfigurationProperties.class), routeContext));
}
@@ -162,7 +162,7 @@ class ShardingDropTableRouteContextCheckerTest {
routeUnits.add(new RouteUnit(new RouteMapper("ds_0", "ds_0"), Collections.singleton(new RouteMapper("t_config", "t_config"))));
routeUnits.add(new RouteUnit(new RouteMapper("ds_1", "ds_1"), Collections.singleton(new RouteMapper("t_config", "t_config"))));
when(routeContext.getRouteUnits()).thenReturn(routeUnits);
- when(queryContext.getSqlStatementContext()).thenReturn(new CommonSQLStatementContext(mock(), sqlStatement));
+ when(queryContext.getSqlStatementContext()).thenReturn(new CommonSQLStatementContext(sqlStatement));
assertDoesNotThrow(() -> new ShardingDropTableRouteContextChecker().check(shardingRule, queryContext, mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS),
mock(ConfigurationProperties.class), routeContext));
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingRenameTableRouteContextCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingRenameTableRouteContextCheckerTest.java
index 33fe7ea552e..4bdbb0357cb 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingRenameTableRouteContextCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingRenameTableRouteContextCheckerTest.java
@@ -96,6 +96,6 @@ class ShardingRenameTableRouteContextCheckerTest {
renameTableDefinitionSegment.setRenameTable(renameTable);
when(sqlStatement.getRenameTables()).thenReturn(Collections.singleton(renameTableDefinitionSegment));
when(sqlStatement.getAttributes()).thenReturn(new SQLStatementAttributes(new TableSQLStatementAttribute(Arrays.asList(table, renameTable))));
- return new CommonSQLStatementContext(mock(), sqlStatement);
+ return new CommonSQLStatementContext(sqlStatement);
}
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/dml/ShardingInsertRouteContextCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/dml/ShardingInsertRouteContextCheckerTest.java
index 665e99b5ddf..4ea96341c95 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/dml/ShardingInsertRouteContextCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/dml/ShardingInsertRouteContextCheckerTest.java
@@ -98,7 +98,7 @@ class ShardingInsertRouteContextCheckerTest {
private InsertStatementContext createInsertStatementContext(final List<Object> params, final InsertStatement insertStatement) {
when(database.getName()).thenReturn("foo_db");
ShardingSphereMetaData metaData = new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), mock());
- return new InsertStatementContext(databaseType, insertStatement, params, metaData, "foo_db");
+ return new InsertStatementContext(insertStatement, params, metaData, "foo_db");
}
@Test
@@ -210,6 +210,7 @@ class ShardingInsertRouteContextCheckerTest {
private InsertStatement createInsertStatement() {
InsertStatement result = mock(InsertStatement.class);
+ when(result.getDatabaseType()).thenReturn(databaseType);
when(result.getTable()).thenReturn(Optional.of(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("user")))));
ColumnSegment columnSegment = new ColumnSegment(0, 0, new IdentifierValue("id"));
ColumnAssignmentSegment assignmentSegment = new ColumnAssignmentSegment(0, 0, Collections.singletonList(columnSegment), new ParameterMarkerExpressionSegment(0, 0, 0));
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/dml/ShardingUpdateRouteContextCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/dml/ShardingUpdateRouteContextCheckerTest.java
index 5d76dd00d82..c31fa4af30d 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/dml/ShardingUpdateRouteContextCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/dml/ShardingUpdateRouteContextCheckerTest.java
@@ -74,7 +74,7 @@ class ShardingUpdateRouteContextCheckerTest {
@Test
void assertCheckWhenNotUpdateShardingColumn() {
- UpdateStatementContext sqlStatementContext = new UpdateStatementContext(mock(), createUpdateStatement());
+ UpdateStatementContext sqlStatementContext = new UpdateStatementContext(createUpdateStatement());
when(queryContext.getSqlStatementContext()).thenReturn(sqlStatementContext);
assertDoesNotThrow(() -> new ShardingUpdateRouteContextChecker().check(shardingRule, queryContext, database, mock(ConfigurationProperties.class), mock(RouteContext.class)));
}
@@ -82,14 +82,14 @@ class ShardingUpdateRouteContextCheckerTest {
@Test
void assertCheckWhenUpdateShardingColumnWithSameRouteContext() {
mockShardingRuleForUpdateShardingColumn();
- when(queryContext.getSqlStatementContext()).thenReturn(new UpdateStatementContext(mock(), createUpdateStatement()));
+ when(queryContext.getSqlStatementContext()).thenReturn(new UpdateStatementContext(createUpdateStatement()));
assertDoesNotThrow(() -> new ShardingUpdateRouteContextChecker().check(shardingRule, queryContext, database, mock(ConfigurationProperties.class), createSingleRouteContext()));
}
@Test
void assertCheckWhenUpdateShardingColumnWithDifferentRouteContext() {
mockShardingRuleForUpdateShardingColumn();
- when(queryContext.getSqlStatementContext()).thenReturn(new UpdateStatementContext(mock(), createUpdateStatement()));
+ when(queryContext.getSqlStatementContext()).thenReturn(new UpdateStatementContext(createUpdateStatement()));
assertThrows(UnsupportedUpdatingShardingValueException.class,
() -> new ShardingUpdateRouteContextChecker().check(shardingRule, queryContext, database, mock(ConfigurationProperties.class), createFullRouteContext()));
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/ShardingRouteEngineFactoryTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/ShardingRouteEngineFactoryTest.java
index 2190a6a3617..c8718debbdd 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/ShardingRouteEngineFactoryTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/ShardingRouteEngineFactoryTest.java
@@ -134,7 +134,7 @@ class ShardingRouteEngineFactoryTest {
void assertNewInstanceForDCLForSingleTable() {
GrantStatement sqlStatement = new GrantStatement(databaseType);
sqlStatement.getTables().add(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("tbl"))));
- SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(mock(), sqlStatement);
+ SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(sqlStatement);
QueryContext queryContext = new QueryContext(sqlStatementContext, "", Collections.emptyList(), new HintValueContext(), mockConnectionContext(), mock(ShardingSphereMetaData.class));
ShardingRouteEngine actual = ShardingRouteEngineFactory.newInstance(shardingRule, database, queryContext, shardingConditions, Collections.singletonList("tbl"), props);
assertThat(actual, instanceOf(ShardingTableBroadcastRouteEngine.class));
diff --git a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/SQLStatementContextFactory.java b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/SQLStatementContextFactory.java
index 7b89596e7a0..264b89f9a40 100644
--- a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/SQLStatementContextFactory.java
+++ b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/SQLStatementContextFactory.java
@@ -32,7 +32,6 @@ import org.apache.shardingsphere.infra.binder.context.statement.type.dml.InsertS
import org.apache.shardingsphere.infra.binder.context.statement.type.dml.SelectStatementContext;
import org.apache.shardingsphere.infra.binder.context.statement.type.dml.UpdateStatementContext;
import org.apache.shardingsphere.infra.database.core.spi.DatabaseTypedSPILoader;
-import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.sql.parser.statement.core.statement.SQLStatement;
import org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.CursorSQLStatementAttribute;
@@ -64,80 +63,75 @@ public final class SQLStatementContextFactory {
* Create SQL statement context.
*
* @param metaData metadata
- * @param databaseType database type
* @param sqlStatement SQL statement
* @param params SQL parameters
* @param currentDatabaseName current database name
* @return SQL statement context
*/
- public static SQLStatementContext newInstance(final ShardingSphereMetaData metaData,
- final DatabaseType databaseType, final SQLStatement sqlStatement, final List<Object> params, final String currentDatabaseName) {
+ public static SQLStatementContext newInstance(final ShardingSphereMetaData metaData, final SQLStatement sqlStatement, final List<Object> params, final String currentDatabaseName) {
if (sqlStatement.getAttributes().findAttribute(TableSQLStatementAttribute.class).isPresent()
- && DatabaseTypedSPILoader.findService(DialectCommonSQLStatementContextWarpProvider.class, databaseType)
+ && DatabaseTypedSPILoader.findService(DialectCommonSQLStatementContextWarpProvider.class, sqlStatement.getDatabaseType())
.map(optional -> optional.getNeedToWarpSQLStatementTypes().contains(sqlStatement.getClass())).orElse(false)) {
- return new CommonSQLStatementContext(databaseType, sqlStatement);
+ return new CommonSQLStatementContext(sqlStatement);
}
if (sqlStatement instanceof DMLStatement) {
- return getDMLStatementContext(metaData, databaseType, (DMLStatement) sqlStatement, params, currentDatabaseName);
+ return getDMLStatementContext(metaData, (DMLStatement) sqlStatement, params, currentDatabaseName);
}
if (sqlStatement instanceof DDLStatement) {
- return getDDLStatementContext(metaData, databaseType, (DDLStatement) sqlStatement, params, currentDatabaseName);
+ return getDDLStatementContext(metaData, (DDLStatement) sqlStatement, params, currentDatabaseName);
}
if (sqlStatement instanceof DCLStatement) {
- return getDCLStatementContext(databaseType, (DCLStatement) sqlStatement);
+ return getDCLStatementContext((DCLStatement) sqlStatement);
}
if (sqlStatement instanceof DALStatement) {
- return getDALStatementContext(metaData, databaseType, (DALStatement) sqlStatement, params, currentDatabaseName);
+ return getDALStatementContext(metaData, (DALStatement) sqlStatement, params, currentDatabaseName);
}
- return new CommonSQLStatementContext(databaseType, sqlStatement);
+ return new CommonSQLStatementContext(sqlStatement);
}
- private static SQLStatementContext getDMLStatementContext(final ShardingSphereMetaData metaData, final DatabaseType databaseType,
- final DMLStatement sqlStatement, final List<Object> params, final String currentDatabaseName) {
+ private static SQLStatementContext getDMLStatementContext(final ShardingSphereMetaData metaData, final DMLStatement sqlStatement, final List<Object> params, final String currentDatabaseName) {
if (sqlStatement instanceof SelectStatement) {
- return new SelectStatementContext(databaseType, (SelectStatement) sqlStatement, params, metaData, currentDatabaseName, Collections.emptyList());
+ return new SelectStatementContext((SelectStatement) sqlStatement, params, metaData, currentDatabaseName, Collections.emptyList());
}
if (sqlStatement instanceof UpdateStatement) {
- return new UpdateStatementContext(databaseType, (UpdateStatement) sqlStatement);
+ return new UpdateStatementContext((UpdateStatement) sqlStatement);
}
if (sqlStatement instanceof DeleteStatement) {
- return new DeleteStatementContext(databaseType, (DeleteStatement) sqlStatement);
+ return new DeleteStatementContext((DeleteStatement) sqlStatement);
}
if (sqlStatement instanceof InsertStatement) {
- return new InsertStatementContext(databaseType, (InsertStatement) sqlStatement, params, metaData, currentDatabaseName);
+ return new InsertStatementContext((InsertStatement) sqlStatement, params, metaData, currentDatabaseName);
}
- return new CommonSQLStatementContext(databaseType, sqlStatement);
+ return new CommonSQLStatementContext(sqlStatement);
}
- private static SQLStatementContext getDDLStatementContext(final ShardingSphereMetaData metaData, final DatabaseType databaseType,
- final DDLStatement sqlStatement, final List<Object> params, final String currentDatabaseName) {
+ private static SQLStatementContext getDDLStatementContext(final ShardingSphereMetaData metaData, final DDLStatement sqlStatement, final List<Object> params, final String currentDatabaseName) {
if (sqlStatement instanceof CreateProcedureStatement) {
- return new CreateProcedureStatementContext(databaseType, (CreateProcedureStatement) sqlStatement);
+ return new CreateProcedureStatementContext((CreateProcedureStatement) sqlStatement);
}
if (sqlStatement instanceof CreateViewStatement) {
- return new CreateViewStatementContext(metaData, databaseType, params, (CreateViewStatement) sqlStatement, currentDatabaseName);
+ return new CreateViewStatementContext(metaData, params, (CreateViewStatement) sqlStatement, currentDatabaseName);
}
if (sqlStatement instanceof AlterViewStatement) {
- return new AlterViewStatementContext(metaData, databaseType, params, (AlterViewStatement) sqlStatement, currentDatabaseName);
+ return new AlterViewStatementContext(metaData, params, (AlterViewStatement) sqlStatement, currentDatabaseName);
}
if (sqlStatement instanceof CursorStatement) {
- return new CursorStatementContext(metaData, databaseType, params, (CursorStatement) sqlStatement, currentDatabaseName);
+ return new CursorStatementContext(metaData, params, (CursorStatement) sqlStatement, currentDatabaseName);
}
if (sqlStatement.getAttributes().findAttribute(CursorSQLStatementAttribute.class).isPresent()) {
- return new CursorHeldSQLStatementContext(databaseType, sqlStatement);
+ return new CursorHeldSQLStatementContext(sqlStatement);
}
- return new CommonSQLStatementContext(databaseType, sqlStatement);
+ return new CommonSQLStatementContext(sqlStatement);
}
- private static SQLStatementContext getDCLStatementContext(final DatabaseType databaseType, final DCLStatement sqlStatement) {
- return new CommonSQLStatementContext(databaseType, sqlStatement);
+ private static SQLStatementContext getDCLStatementContext(final DCLStatement sqlStatement) {
+ return new CommonSQLStatementContext(sqlStatement);
}
- private static SQLStatementContext getDALStatementContext(final ShardingSphereMetaData metaData, final DatabaseType databaseType,
- final DALStatement sqlStatement, final List<Object> params, final String currentDatabaseName) {
+ private static SQLStatementContext getDALStatementContext(final ShardingSphereMetaData metaData, final DALStatement sqlStatement, final List<Object> params, final String currentDatabaseName) {
if (sqlStatement instanceof ExplainStatement) {
- return new ExplainStatementContext(metaData, databaseType, (ExplainStatement) sqlStatement, params, currentDatabaseName);
+ return new ExplainStatementContext(metaData, (ExplainStatement) sqlStatement, params, currentDatabaseName);
}
- return new CommonSQLStatementContext(databaseType, sqlStatement);
+ return new CommonSQLStatementContext(sqlStatement);
}
}
diff --git a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/SQLStatementContext.java b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/SQLStatementContext.java
index 0019995fe12..cc8bb56de85 100644
--- a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/SQLStatementContext.java
+++ b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/SQLStatementContext.java
@@ -18,7 +18,6 @@
package org.apache.shardingsphere.infra.binder.context.statement;
import org.apache.shardingsphere.infra.binder.context.segment.table.TablesContext;
-import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
import org.apache.shardingsphere.sql.parser.statement.core.statement.SQLStatement;
/**
@@ -39,11 +38,4 @@ public interface SQLStatementContext {
* @return tables context
*/
TablesContext getTablesContext();
-
- /**
- * Get database type.
- *
- * @return database type
- */
- DatabaseType getDatabaseType();
}
diff --git a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/CommonSQLStatementContext.java b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/CommonSQLStatementContext.java
index cc1f8f4a404..ef4ba6d7ae9 100644
--- a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/CommonSQLStatementContext.java
+++ b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/CommonSQLStatementContext.java
@@ -21,7 +21,6 @@ import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.binder.context.segment.table.TablesContext;
import org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
-import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
import org.apache.shardingsphere.sql.parser.statement.core.statement.SQLStatement;
import org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.TableSQLStatementAttribute;
@@ -34,14 +33,11 @@ import java.util.Collections;
@Getter
public final class CommonSQLStatementContext implements SQLStatementContext {
- private final DatabaseType databaseType;
-
private final SQLStatement sqlStatement;
private final TablesContext tablesContext;
- public CommonSQLStatementContext(final DatabaseType databaseType, final SQLStatement sqlStatement) {
- this.databaseType = databaseType;
+ public CommonSQLStatementContext(final SQLStatement sqlStatement) {
this.sqlStatement = sqlStatement;
tablesContext = new TablesContext(sqlStatement.getAttributes().findAttribute(TableSQLStatementAttribute.class).map(TableSQLStatementAttribute::getTables).orElse(Collections.emptyList()));
}
diff --git a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/dal/ExplainStatementContext.java b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/dal/ExplainStatementContext.java
index 0d7f98e0eb2..9a8af9910b9 100644
--- a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/dal/ExplainStatementContext.java
+++ b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/dal/ExplainStatementContext.java
@@ -18,10 +18,9 @@
package org.apache.shardingsphere.infra.binder.context.statement.type.dal;
import lombok.Getter;
+import org.apache.shardingsphere.infra.binder.context.SQLStatementContextFactory;
import org.apache.shardingsphere.infra.binder.context.segment.table.TablesContext;
import org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
-import org.apache.shardingsphere.infra.binder.context.SQLStatementContextFactory;
-import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.TableSQLStatementAttribute;
import org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.ExplainStatement;
@@ -35,19 +34,15 @@ import java.util.List;
@Getter
public final class ExplainStatementContext implements SQLStatementContext {
- private final DatabaseType databaseType;
-
private final ExplainStatement sqlStatement;
private final TablesContext tablesContext;
private final SQLStatementContext explainableSQLStatementContext;
- public ExplainStatementContext(final ShardingSphereMetaData metaData,
- final DatabaseType databaseType, final ExplainStatement sqlStatement, final List<Object> params, final String currentDatabaseName) {
- this.databaseType = databaseType;
+ public ExplainStatementContext(final ShardingSphereMetaData metaData, final ExplainStatement sqlStatement, final List<Object> params, final String currentDatabaseName) {
this.sqlStatement = sqlStatement;
tablesContext = new TablesContext(sqlStatement.getAttributes().findAttribute(TableSQLStatementAttribute.class).map(TableSQLStatementAttribute::getTables).orElse(Collections.emptyList()));
- explainableSQLStatementContext = SQLStatementContextFactory.newInstance(metaData, databaseType, sqlStatement.getExplainableSQLStatement(), params, currentDatabaseName);
+ explainableSQLStatementContext = SQLStatementContextFactory.newInstance(metaData, sqlStatement.getExplainableSQLStatement(), params, currentDatabaseName);
}
}
diff --git a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/AlterViewStatementContext.java b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/AlterViewStatementContext.java
index 1e47d173f10..93cca937766 100644
--- a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/AlterViewStatementContext.java
+++ b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/AlterViewStatementContext.java
@@ -22,7 +22,6 @@ import org.apache.shardingsphere.infra.binder.context.available.WhereContextAvai
import org.apache.shardingsphere.infra.binder.context.segment.table.TablesContext;
import org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
import org.apache.shardingsphere.infra.binder.context.statement.type.dml.SelectStatementContext;
-import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.sql.parser.statement.core.enums.SubqueryType;
import org.apache.shardingsphere.sql.parser.statement.core.extractor.TableExtractor;
@@ -45,17 +44,14 @@ import java.util.Optional;
@Getter
public final class AlterViewStatementContext implements SQLStatementContext, WhereContextAvailable {
- private final DatabaseType databaseType;
-
private final AlterViewStatement sqlStatement;
private final TablesContext tablesContext;
private final SelectStatementContext selectStatementContext;
- public AlterViewStatementContext(final ShardingSphereMetaData metaData, final DatabaseType databaseType, final List<Object> params,
+ public AlterViewStatementContext(final ShardingSphereMetaData metaData, final List<Object> params,
final AlterViewStatement sqlStatement, final String currentDatabaseName) {
- this.databaseType = databaseType;
this.sqlStatement = sqlStatement;
Collection<SimpleTableSegment> tables = new LinkedList<>();
tables.add(sqlStatement.getView());
@@ -63,12 +59,12 @@ public final class AlterViewStatementContext implements SQLStatementContext, Whe
selectStatement.ifPresent(optional -> extractTables(optional, tables));
sqlStatement.getRenameView().ifPresent(tables::add);
tablesContext = new TablesContext(tables);
- selectStatementContext = selectStatement.map(optional -> createSelectStatementContext(metaData, databaseType, params, optional, currentDatabaseName)).orElse(null);
+ selectStatementContext = selectStatement.map(optional -> createSelectStatementContext(metaData, params, optional, currentDatabaseName)).orElse(null);
}
- private SelectStatementContext createSelectStatementContext(final ShardingSphereMetaData metaData, final DatabaseType databaseType, final List<Object> params,
+ private SelectStatementContext createSelectStatementContext(final ShardingSphereMetaData metaData, final List<Object> params,
final SelectStatement selectStatement, final String currentDatabaseName) {
- SelectStatementContext result = new SelectStatementContext(databaseType, selectStatement, params, metaData, currentDatabaseName, Collections.emptyList());
+ SelectStatementContext result = new SelectStatementContext(selectStatement, params, metaData, currentDatabaseName, Collections.emptyList());
result.setSubqueryType(SubqueryType.VIEW_DEFINITION);
return result;
}
diff --git a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/CreateProcedureStatementContext.java b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/CreateProcedureStatementContext.java
index 88266c19409..b3ae6f7869a 100644
--- a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/CreateProcedureStatementContext.java
+++ b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/CreateProcedureStatementContext.java
@@ -20,7 +20,6 @@ package org.apache.shardingsphere.infra.binder.context.statement.type.ddl;
import lombok.Getter;
import org.apache.shardingsphere.infra.binder.context.segment.table.TablesContext;
import org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
-import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
import org.apache.shardingsphere.sql.parser.statement.core.extractor.TableExtractor;
import org.apache.shardingsphere.sql.parser.statement.core.segment.ddl.routine.RoutineBodySegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
@@ -36,14 +35,11 @@ import java.util.Optional;
@Getter
public final class CreateProcedureStatementContext implements SQLStatementContext {
- private final DatabaseType databaseType;
-
private final CreateProcedureStatement sqlStatement;
private final TablesContext tablesContext;
- public CreateProcedureStatementContext(final DatabaseType databaseType, final CreateProcedureStatement sqlStatement) {
- this.databaseType = databaseType;
+ public CreateProcedureStatementContext(final CreateProcedureStatement sqlStatement) {
this.sqlStatement = sqlStatement;
Optional<RoutineBodySegment> routineBodySegment = sqlStatement.getRoutineBody();
Collection<SimpleTableSegment> tables = routineBodySegment.map(optional -> new TableExtractor().extractExistTableFromRoutineBody(optional)).orElseGet(Collections::emptyList);
diff --git a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/CreateViewStatementContext.java b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/CreateViewStatementContext.java
index f25d30435aa..67d29fadda3 100644
--- a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/CreateViewStatementContext.java
+++ b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/CreateViewStatementContext.java
@@ -22,7 +22,6 @@ import org.apache.shardingsphere.infra.binder.context.available.WhereContextAvai
import org.apache.shardingsphere.infra.binder.context.segment.table.TablesContext;
import org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
import org.apache.shardingsphere.infra.binder.context.statement.type.dml.SelectStatementContext;
-import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.sql.parser.statement.core.enums.SubqueryType;
import org.apache.shardingsphere.sql.parser.statement.core.extractor.TableExtractor;
@@ -41,22 +40,18 @@ import java.util.List;
@Getter
public final class CreateViewStatementContext implements SQLStatementContext, WhereContextAvailable {
- private final DatabaseType databaseType;
-
private final CreateViewStatement sqlStatement;
private final TablesContext tablesContext;
private final SelectStatementContext selectStatementContext;
- public CreateViewStatementContext(final ShardingSphereMetaData metaData, final DatabaseType databaseType, final List<Object> params,
- final CreateViewStatement sqlStatement, final String currentDatabaseName) {
- this.databaseType = databaseType;
+ public CreateViewStatementContext(final ShardingSphereMetaData metaData, final List<Object> params, final CreateViewStatement sqlStatement, final String currentDatabaseName) {
this.sqlStatement = sqlStatement;
TableExtractor extractor = new TableExtractor();
extractor.extractTablesFromCreateViewStatement(sqlStatement);
tablesContext = new TablesContext(extractor.getRewriteTables());
- selectStatementContext = new SelectStatementContext(databaseType, sqlStatement.getSelect(), params, metaData, currentDatabaseName, Collections.emptyList());
+ selectStatementContext = new SelectStatementContext(sqlStatement.getSelect(), params, metaData, currentDatabaseName, Collections.emptyList());
selectStatementContext.setSubqueryType(SubqueryType.VIEW_DEFINITION);
}
diff --git a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/CursorHeldSQLStatementContext.java b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/CursorHeldSQLStatementContext.java
index 2a3fdc99d12..00981eef7f2 100644
--- a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/CursorHeldSQLStatementContext.java
+++ b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/CursorHeldSQLStatementContext.java
@@ -21,7 +21,6 @@ import lombok.Getter;
import org.apache.shardingsphere.infra.binder.context.available.WhereContextAvailable;
import org.apache.shardingsphere.infra.binder.context.segment.table.TablesContext;
import org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
-import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.column.ColumnSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.expr.BinaryOperationExpression;
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.predicate.WhereSegment;
@@ -36,16 +35,13 @@ import java.util.Collections;
@Getter
public final class CursorHeldSQLStatementContext implements SQLStatementContext, WhereContextAvailable {
- private final DatabaseType databaseType;
-
private final SQLStatement sqlStatement;
private TablesContext tablesContext;
private CursorStatementContext cursorStatementContext;
- public CursorHeldSQLStatementContext(final DatabaseType databaseType, final SQLStatement sqlStatement) {
- this.databaseType = databaseType;
+ public CursorHeldSQLStatementContext(final SQLStatement sqlStatement) {
this.sqlStatement = sqlStatement;
tablesContext = new TablesContext(Collections.emptyList());
}
diff --git a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/CursorStatementContext.java b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/CursorStatementContext.java
index 64f87b0f7ff..c0742b8bec7 100644
--- a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/CursorStatementContext.java
+++ b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/CursorStatementContext.java
@@ -22,7 +22,6 @@ import org.apache.shardingsphere.infra.binder.context.available.WhereContextAvai
import org.apache.shardingsphere.infra.binder.context.segment.table.TablesContext;
import org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
import org.apache.shardingsphere.infra.binder.context.statement.type.dml.SelectStatementContext;
-import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.sql.parser.statement.core.extractor.TableExtractor;
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.column.ColumnSegment;
@@ -42,8 +41,6 @@ import java.util.List;
@Getter
public final class CursorStatementContext implements SQLStatementContext, WhereContextAvailable {
- private final DatabaseType databaseType;
-
private final CursorStatement sqlStatement;
private final TablesContext tablesContext;
@@ -56,12 +53,10 @@ public final class CursorStatementContext implements SQLStatementContext, WhereC
private final SelectStatementContext selectStatementContext;
- public CursorStatementContext(final ShardingSphereMetaData metaData, final DatabaseType databaseType,
- final List<Object> params, final CursorStatement sqlStatement, final String currentDatabaseName) {
- this.databaseType = databaseType;
+ public CursorStatementContext(final ShardingSphereMetaData metaData, final List<Object> params, final CursorStatement sqlStatement, final String currentDatabaseName) {
this.sqlStatement = sqlStatement;
tablesContext = new TablesContext(getSimpleTableSegments());
- selectStatementContext = new SelectStatementContext(databaseType, sqlStatement.getSelect(), params, metaData, currentDatabaseName, Collections.emptyList());
+ selectStatementContext = new SelectStatementContext(sqlStatement.getSelect(), params, metaData, currentDatabaseName, Collections.emptyList());
whereSegments.addAll(selectStatementContext.getWhereSegments());
columnSegments.addAll(selectStatementContext.getColumnSegments());
joinConditions.addAll(selectStatementContext.getJoinConditions());
diff --git a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/dml/DeleteStatementContext.java b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/dml/DeleteStatementContext.java
index 576b4343fae..23fefc6b014 100644
--- a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/dml/DeleteStatementContext.java
+++ b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/dml/DeleteStatementContext.java
@@ -18,10 +18,9 @@
package org.apache.shardingsphere.infra.binder.context.statement.type.dml;
import lombok.Getter;
+import org.apache.shardingsphere.infra.binder.context.available.WhereContextAvailable;
import org.apache.shardingsphere.infra.binder.context.segment.table.TablesContext;
import org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
-import org.apache.shardingsphere.infra.binder.context.available.WhereContextAvailable;
-import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
import org.apache.shardingsphere.sql.parser.statement.core.extractor.ColumnExtractor;
import org.apache.shardingsphere.sql.parser.statement.core.extractor.ExpressionExtractor;
import org.apache.shardingsphere.sql.parser.statement.core.extractor.TableExtractor;
@@ -42,8 +41,6 @@ import java.util.Map;
@Getter
public final class DeleteStatementContext implements SQLStatementContext, WhereContextAvailable {
- private final DatabaseType databaseType;
-
private final DeleteStatement sqlStatement;
private final TablesContext tablesContext;
@@ -54,8 +51,7 @@ public final class DeleteStatementContext implements SQLStatementContext, WhereC
private final Collection<BinaryOperationExpression> joinConditions = new LinkedList<>();
- public DeleteStatementContext(final DatabaseType databaseType, final DeleteStatement sqlStatement) {
- this.databaseType = databaseType;
+ public DeleteStatementContext(final DeleteStatement sqlStatement) {
this.sqlStatement = sqlStatement;
tablesContext = new TablesContext(getAllSimpleTableSegments());
whereSegments = createWhereSegments(sqlStatement);
diff --git a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/dml/InsertStatementContext.java b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/dml/InsertStatementContext.java
index 8b55d34d41d..b3b62a25c9a 100644
--- a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/dml/InsertStatementContext.java
+++ b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/dml/InsertStatementContext.java
@@ -19,6 +19,7 @@ package org.apache.shardingsphere.infra.binder.context.statement.type.dml;
import com.cedarsoftware.util.CaseInsensitiveMap;
import lombok.Getter;
+import org.apache.shardingsphere.infra.binder.context.available.WhereContextAvailable;
import org.apache.shardingsphere.infra.binder.context.aware.ParameterAware;
import org.apache.shardingsphere.infra.binder.context.segment.insert.keygen.GeneratedKeyContext;
import org.apache.shardingsphere.infra.binder.context.segment.insert.keygen.engine.GeneratedKeyContextEngine;
@@ -27,8 +28,6 @@ import org.apache.shardingsphere.infra.binder.context.segment.insert.values.Inse
import org.apache.shardingsphere.infra.binder.context.segment.insert.values.OnDuplicateUpdateContext;
import org.apache.shardingsphere.infra.binder.context.segment.table.TablesContext;
import org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
-import org.apache.shardingsphere.infra.binder.context.available.WhereContextAvailable;
-import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
import org.apache.shardingsphere.infra.database.core.type.DatabaseTypeRegistry;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import org.apache.shardingsphere.infra.exception.dialect.exception.syntax.database.NoDatabaseSelectedException;
@@ -69,9 +68,6 @@ public final class InsertStatementContext implements SQLStatementContext, Parame
private final ShardingSphereMetaData metaData;
- @Getter
- private final DatabaseType databaseType;
-
@Getter
private final InsertStatement sqlStatement;
@@ -98,10 +94,8 @@ public final class InsertStatementContext implements SQLStatementContext, Parame
private GeneratedKeyContext generatedKeyContext;
- public InsertStatementContext(final DatabaseType databaseType, final InsertStatement sqlStatement,
- final List<Object> params, final ShardingSphereMetaData metaData, final String currentDatabaseName) {
+ public InsertStatementContext(final InsertStatement sqlStatement, final List<Object> params, final ShardingSphereMetaData metaData, final String currentDatabaseName) {
this.metaData = metaData;
- this.databaseType = databaseType;
this.sqlStatement = sqlStatement;
this.currentDatabaseName = currentDatabaseName;
valueExpressions = getAllValueExpressions(sqlStatement);
@@ -147,7 +141,7 @@ public final class InsertStatementContext implements SQLStatementContext, Parame
return Optional.empty();
}
SubquerySegment insertSelectSegment = sqlStatement.getInsertSelect().get();
- SelectStatementContext selectStatementContext = new SelectStatementContext(databaseType, insertSelectSegment.getSelect(), params, metaData, currentDatabaseName, Collections.emptyList());
+ SelectStatementContext selectStatementContext = new SelectStatementContext(insertSelectSegment.getSelect(), params, metaData, currentDatabaseName, Collections.emptyList());
selectStatementContext.setSubqueryType(SubqueryType.INSERT_SELECT);
setCombineSelectSubqueryType(selectStatementContext);
setProjectionSelectSubqueryType(selectStatementContext);
@@ -196,7 +190,7 @@ public final class InsertStatementContext implements SQLStatementContext, Parame
ShardingSpherePreconditions.checkNotNull(databaseName, NoDatabaseSelectedException::new);
ShardingSphereDatabase database = metaData.getDatabase(databaseName);
ShardingSpherePreconditions.checkNotNull(database, () -> new UnknownDatabaseException(databaseName));
- String defaultSchema = new DatabaseTypeRegistry(databaseType).getDefaultSchemaName(databaseName);
+ String defaultSchema = new DatabaseTypeRegistry(sqlStatement.getDatabaseType()).getDefaultSchemaName(databaseName);
return tablesContext.getSchemaName().map(database::getSchema).orElseGet(() -> database.getSchema(defaultSchema));
}
diff --git a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/dml/SelectStatementContext.java b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/dml/SelectStatementContext.java
index cf8b44f1c41..7a0e4a2cba9 100644
--- a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/dml/SelectStatementContext.java
+++ b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/dml/SelectStatementContext.java
@@ -40,7 +40,6 @@ import org.apache.shardingsphere.infra.binder.context.segment.select.projection.
import org.apache.shardingsphere.infra.binder.context.segment.table.TablesContext;
import org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
import org.apache.shardingsphere.infra.database.core.metadata.database.metadata.option.pagination.DialectPaginationOption;
-import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
import org.apache.shardingsphere.infra.database.core.type.DatabaseTypeRegistry;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import org.apache.shardingsphere.infra.exception.dialect.exception.syntax.database.NoDatabaseSelectedException;
@@ -90,8 +89,6 @@ import java.util.Optional;
@Setter
public final class SelectStatementContext implements SQLStatementContext, WhereContextAvailable, ParameterAware {
- private final DatabaseType databaseType;
-
private final SelectStatement sqlStatement;
private final TablesContext tablesContext;
@@ -118,20 +115,19 @@ public final class SelectStatementContext implements SQLStatementContext, WhereC
private PaginationContext paginationContext;
- public SelectStatementContext(final DatabaseType databaseType, final SelectStatement sqlStatement,
+ public SelectStatementContext(final SelectStatement sqlStatement,
final List<Object> params, final ShardingSphereMetaData metaData, final String currentDatabaseName, final Collection<TableSegment> inheritedTables) {
- this.databaseType = databaseType;
this.sqlStatement = sqlStatement;
whereSegments = createWhereSegments(sqlStatement);
columnSegments = ColumnExtractor.extractColumnSegments(whereSegments);
Collection<TableSegment> tableSegments = getAllTableSegments(inheritedTables);
ExpressionExtractor.extractJoinConditions(joinConditions, whereSegments);
- subqueryContexts = createSubqueryContexts(databaseType, params, metaData, currentDatabaseName, tableSegments);
+ subqueryContexts = createSubqueryContexts(params, metaData, currentDatabaseName, tableSegments);
tablesContext = new TablesContext(tableSegments, subqueryContexts);
groupByContext = new GroupByContextEngine().createGroupByContext(sqlStatement);
- orderByContext = new OrderByContextEngine(databaseType).createOrderBy(sqlStatement, groupByContext);
- projectionsContext = new ProjectionsContextEngine(databaseType).createProjectionsContext(sqlStatement.getProjections(), groupByContext, orderByContext);
- DialectPaginationOption paginationOption = new DatabaseTypeRegistry(databaseType).getDialectDatabaseMetaData().getPaginationOption();
+ orderByContext = new OrderByContextEngine(sqlStatement.getDatabaseType()).createOrderBy(sqlStatement, groupByContext);
+ projectionsContext = new ProjectionsContextEngine(sqlStatement.getDatabaseType()).createProjectionsContext(sqlStatement.getProjections(), groupByContext, orderByContext);
+ DialectPaginationOption paginationOption = new DatabaseTypeRegistry(sqlStatement.getDatabaseType()).getDialectDatabaseMetaData().getPaginationOption();
paginationContext = new PaginationContextEngine(paginationOption).createPaginationContext(sqlStatement, projectionsContext, params, whereSegments);
containsEnhancedTable = isContainsEnhancedTable(metaData, tablesContext.getDatabaseNames(), currentDatabaseName);
}
@@ -195,12 +191,12 @@ public final class SelectStatementContext implements SQLStatementContext, WhereC
return database.getRuleMetaData().getAttributes(TableMapperRuleAttribute.class);
}
- private Map<Integer, SelectStatementContext> createSubqueryContexts(final DatabaseType databaseType, final List<Object> params, final ShardingSphereMetaData metaData,
+ private Map<Integer, SelectStatementContext> createSubqueryContexts(final List<Object> params, final ShardingSphereMetaData metaData,
final String currentDatabaseName, final Collection<TableSegment> tableSegments) {
Collection<SubquerySegment> subquerySegments = SubqueryExtractor.extractSubquerySegments(sqlStatement, false);
Map<Integer, SelectStatementContext> result = new HashMap<>(subquerySegments.size(), 1F);
for (SubquerySegment each : subquerySegments) {
- SelectStatementContext subqueryContext = new SelectStatementContext(databaseType, each.getSelect(), params, metaData, currentDatabaseName, tableSegments);
+ SelectStatementContext subqueryContext = new SelectStatementContext(each.getSelect(), params, metaData, currentDatabaseName, tableSegments);
each.getSelect().getSubqueryType().ifPresent(subqueryContext::setSubqueryType);
result.put(each.getStartIndex(), subqueryContext);
}
@@ -432,7 +428,7 @@ public final class SelectStatementContext implements SQLStatementContext, WhereC
@Override
public void setUpParameters(final List<Object> params) {
- DialectPaginationOption paginationOption = new DatabaseTypeRegistry(databaseType).getDialectDatabaseMetaData().getPaginationOption();
+ DialectPaginationOption paginationOption = new DatabaseTypeRegistry(sqlStatement.getDatabaseType()).getDialectDatabaseMetaData().getPaginationOption();
paginationContext = new PaginationContextEngine(paginationOption).createPaginationContext(sqlStatement, projectionsContext, params, whereSegments);
}
}
diff --git a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/dml/UpdateStatementContext.java b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/dml/UpdateStatementContext.java
index e93654aa5cf..7df7c2bb520 100644
--- a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/dml/UpdateStatementContext.java
+++ b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/dml/UpdateStatementContext.java
@@ -18,10 +18,9 @@
package org.apache.shardingsphere.infra.binder.context.statement.type.dml;
import lombok.Getter;
+import org.apache.shardingsphere.infra.binder.context.available.WhereContextAvailable;
import org.apache.shardingsphere.infra.binder.context.segment.table.TablesContext;
import org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
-import org.apache.shardingsphere.infra.binder.context.available.WhereContextAvailable;
-import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
import org.apache.shardingsphere.sql.parser.statement.core.extractor.ColumnExtractor;
import org.apache.shardingsphere.sql.parser.statement.core.extractor.ExpressionExtractor;
import org.apache.shardingsphere.sql.parser.statement.core.extractor.TableExtractor;
@@ -40,8 +39,6 @@ import java.util.LinkedList;
@Getter
public final class UpdateStatementContext implements SQLStatementContext, WhereContextAvailable {
- private final DatabaseType databaseType;
-
private final UpdateStatement sqlStatement;
private final TablesContext tablesContext;
@@ -52,8 +49,7 @@ public final class UpdateStatementContext implements SQLStatementContext, WhereC
private final Collection<BinaryOperationExpression> joinConditions = new LinkedList<>();
- public UpdateStatementContext(final DatabaseType databaseType, final UpdateStatement sqlStatement) {
- this.databaseType = databaseType;
+ public UpdateStatementContext(final UpdateStatement sqlStatement) {
this.sqlStatement = sqlStatement;
tablesContext = new TablesContext(getAllSimpleTableSegments());
whereSegments = createWhereSegments(sqlStatement);
diff --git a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/engine/SQLBindEngine.java b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/engine/SQLBindEngine.java
index ce469f50863..b68a3eda60c 100644
--- a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/engine/SQLBindEngine.java
+++ b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/engine/SQLBindEngine.java
@@ -57,7 +57,7 @@ public final class SQLBindEngine {
*/
public SQLStatementContext bind(final SQLStatement sqlStatement, final List<Object> params) {
SQLStatement boundSQLStatement = isNeedBind() ? bind(sqlStatement) : sqlStatement;
- return SQLStatementContextFactory.newInstance(metaData, sqlStatement.getDatabaseType(), boundSQLStatement, params, currentDatabaseName);
+ return SQLStatementContextFactory.newInstance(metaData, boundSQLStatement, params, currentDatabaseName);
}
private SQLStatement bind(final SQLStatement sqlStatement) {
diff --git a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/segment/select/pagination/PaginationContextTest.java b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/segment/select/pagination/PaginationContextTest.java
index 41b34386a5d..aed9fe6b433 100644
--- a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/segment/select/pagination/PaginationContextTest.java
+++ b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/segment/select/pagination/PaginationContextTest.java
@@ -139,7 +139,7 @@ class PaginationContextTest {
selectStatement.setProjections(new ProjectionsSegment(0, 0));
ShardingSphereDatabase database = new ShardingSphereDatabase("foo_db", mock(), mock(), mock(), Collections.emptyList());
ShardingSphereMetaData metaData = new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), mock());
- SelectStatementContext selectStatementContext = new SelectStatementContext(databaseType, selectStatement, Collections.emptyList(), metaData, "foo_db", Collections.emptyList());
+ SelectStatementContext selectStatementContext = new SelectStatementContext(selectStatement, Collections.emptyList(), metaData, "foo_db", Collections.emptyList());
assertThat(new PaginationContext(getOffsetSegment(), getRowCountSegment(), getParameters()).getRevisedRowCount(selectStatementContext), is(50L));
}
@@ -151,7 +151,7 @@ class PaginationContextTest {
selectStatement.setOrderBy(new OrderBySegment(0, 0, Collections.singletonList(new IndexOrderByItemSegment(0, 0, 1, OrderDirection.DESC, NullsOrderType.LAST))));
ShardingSphereDatabase database = new ShardingSphereDatabase("foo_db", mock(), mock(), mock(), Collections.emptyList());
ShardingSphereMetaData metaData = new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), mock());
- SelectStatementContext selectStatementContext = new SelectStatementContext(databaseType, selectStatement, Collections.emptyList(), metaData, "foo_db", Collections.emptyList());
+ SelectStatementContext selectStatementContext = new SelectStatementContext(selectStatement, Collections.emptyList(), metaData, "foo_db", Collections.emptyList());
assertThat(new PaginationContext(getOffsetSegment(), getRowCountSegment(), getParameters()).getRevisedRowCount(selectStatementContext), is((long) Integer.MAX_VALUE));
}
}
diff --git a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/dal/ExplainStatementContextTest.java b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/dal/ExplainStatementContextTest.java
index b9e3dad880c..6bb3d2e06e1 100644
--- a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/dal/ExplainStatementContextTest.java
+++ b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/dal/ExplainStatementContextTest.java
@@ -54,13 +54,13 @@ class ExplainStatementContextTest {
@BeforeEach
void setUp() {
- when(SQLStatementContextFactory.newInstance(metaData, databaseType, explainableSQLStatement, Collections.emptyList(), "foo_db")).thenReturn(explainableSQLStatementContext);
+ when(SQLStatementContextFactory.newInstance(metaData, explainableSQLStatement, Collections.emptyList(), "foo_db")).thenReturn(explainableSQLStatementContext);
}
@Test
void assertNewInstance() {
ExplainStatement explainStatement = new ExplainStatement(databaseType, explainableSQLStatement);
- ExplainStatementContext actual = new ExplainStatementContext(metaData, databaseType, explainStatement, Collections.emptyList(), "foo_db");
+ ExplainStatementContext actual = new ExplainStatementContext(metaData, explainStatement, Collections.emptyList(), "foo_db");
assertThat(actual.getSqlStatement(), is(explainStatement));
assertThat(actual.getTablesContext().getSimpleTables(), is(Collections.emptyList()));
assertThat(actual.getExplainableSQLStatementContext(), is(explainableSQLStatementContext));
diff --git a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/AlterViewStatementContextTest.java b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/AlterViewStatementContextTest.java
index e68ed644e80..69589c54b8b 100644
--- a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/AlterViewStatementContextTest.java
+++ b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/AlterViewStatementContextTest.java
@@ -17,11 +17,9 @@
package org.apache.shardingsphere.infra.binder.context.statement.type.ddl;
-import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.rule.attribute.table.TableMapperRuleAttribute;
-import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.bound.TableSegmentBoundInfo;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.TableNameSegment;
@@ -42,8 +40,6 @@ import static org.mockito.Mockito.when;
class AlterViewStatementContextTest {
- private final DatabaseType databaseType = TypedSPILoader.getService(DatabaseType.class, "FIXTURE");
-
@Test
void assertNewInstance() {
AlterViewStatement alterViewStatement = mock(AlterViewStatement.class);
@@ -53,7 +49,7 @@ class AlterViewStatementContextTest {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
when(database.getRuleMetaData().getAttributes(TableMapperRuleAttribute.class)).thenReturn(Collections.emptyList());
when(metaData.getDatabase("foo_db")).thenReturn(database);
- AlterViewStatementContext actual = new AlterViewStatementContext(metaData, databaseType, Collections.emptyList(), alterViewStatement, "foo_db");
+ AlterViewStatementContext actual = new AlterViewStatementContext(metaData, Collections.emptyList(), alterViewStatement, "foo_db");
assertThat(actual.getSqlStatement(), is(alterViewStatement));
assertThat(actual.getTablesContext().getSimpleTables().size(), is(2));
assertThat(actual.getTablesContext().getSimpleTables().stream().map(each -> each.getTableName().getIdentifier().getValue()).collect(Collectors.toList()),
diff --git a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/CreateProcedureStatementContextTest.java b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/CreateProcedureStatementContextTest.java
index a82df34ec9f..bb6e3c4ae50 100644
--- a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/CreateProcedureStatementContextTest.java
+++ b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/CreateProcedureStatementContextTest.java
@@ -29,7 +29,7 @@ class CreateProcedureStatementContextTest {
@Test
void assertNewInstance() {
CreateProcedureStatement sqlStatement = mock(CreateProcedureStatement.class);
- CreateProcedureStatementContext actual = new CreateProcedureStatementContext(mock(), sqlStatement);
+ CreateProcedureStatementContext actual = new CreateProcedureStatementContext(sqlStatement);
assertThat(actual.getSqlStatement(), is(sqlStatement));
}
}
diff --git a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/CreateViewStatementContextTest.java b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/CreateViewStatementContextTest.java
index abcef7dc90d..842cb71bd8f 100644
--- a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/CreateViewStatementContextTest.java
+++ b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/CreateViewStatementContextTest.java
@@ -46,18 +46,20 @@ class CreateViewStatementContextTest {
@Test
void assertNewInstance() {
CreateViewStatement createViewStatement = mock(CreateViewStatement.class);
+ when(createViewStatement.getDatabaseType()).thenReturn(databaseType);
TableNameSegment tableNameSegment = new TableNameSegment(0, 0, new IdentifierValue("view"));
tableNameSegment.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
SimpleTableSegment view = new SimpleTableSegment(tableNameSegment);
when(createViewStatement.getView()).thenReturn(view);
SelectStatement selectStatement = mock(SelectStatement.class);
+ when(selectStatement.getDatabaseType()).thenReturn(databaseType);
when(selectStatement.getProjections()).thenReturn(new ProjectionsSegment(0, 0));
when(createViewStatement.getSelect()).thenReturn(selectStatement);
ShardingSphereMetaData metaData = mock(ShardingSphereMetaData.class);
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
when(database.getRuleMetaData().getAttributes(TableMapperRuleAttribute.class)).thenReturn(Collections.emptyList());
when(metaData.getDatabase("foo_db")).thenReturn(database);
- CreateViewStatementContext actual = new CreateViewStatementContext(metaData, databaseType, Collections.emptyList(), createViewStatement, "foo_db");
+ CreateViewStatementContext actual = new CreateViewStatementContext(metaData, Collections.emptyList(), createViewStatement, "foo_db");
assertThat(actual.getSqlStatement(), is(createViewStatement));
}
}
diff --git a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/dml/DeleteStatementContextTest.java b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/dml/DeleteStatementContextTest.java
index d942caf02dc..7ce62a887c9 100644
--- a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/dml/DeleteStatementContextTest.java
+++ b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/dml/DeleteStatementContextTest.java
@@ -53,7 +53,7 @@ class DeleteStatementContextTest {
tableSegment.setLeft(new SimpleTableSegment(createTableNameSegment("foo_tbl")));
tableSegment.setRight(new SimpleTableSegment(createTableNameSegment("bar_tbl")));
deleteStatement.setTable(tableSegment);
- DeleteStatementContext actual = new DeleteStatementContext(mock(), deleteStatement);
+ DeleteStatementContext actual = new DeleteStatementContext(deleteStatement);
assertThat(actual.getTablesContext().getTableNames(), is(new HashSet<>(Arrays.asList("foo_tbl", "bar_tbl"))));
assertThat(actual.getWhereSegments(), is(Collections.singletonList(whereSegment)));
assertThat(actual.getTablesContext().getSimpleTables().stream().map(each -> each.getTableName().getIdentifier().getValue()).collect(Collectors.toList()),
diff --git a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/dml/InsertStatementContextTest.java b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/dml/InsertStatementContextTest.java
index 1c1c18f3066..8f09690672b 100644
--- a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/dml/InsertStatementContextTest.java
+++ b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/dml/InsertStatementContextTest.java
@@ -65,6 +65,7 @@ class InsertStatementContextTest {
@Test
void assertInsertStatementContextWithColumnNames() {
InsertStatement insertStatement = mock(InsertStatement.class);
+ when(insertStatement.getDatabaseType()).thenReturn(databaseType);
TableNameSegment tableNameSegment = new TableNameSegment(0, 0, new IdentifierValue("tbl"));
tableNameSegment.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
SimpleTableSegment tableSegment = new SimpleTableSegment(tableNameSegment);
@@ -84,12 +85,13 @@ class InsertStatementContextTest {
when(schema.getName()).thenReturn("foo_db");
when(schema.getVisibleColumnNames("tbl")).thenReturn(Arrays.asList("id", "name", "status"));
ShardingSphereDatabase database = new ShardingSphereDatabase("foo_db", mock(), mock(), mock(), Collections.singleton(schema));
- return new InsertStatementContext(databaseType, insertStatement, params, new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), mock()), "foo_db");
+ return new InsertStatementContext(insertStatement, params, new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), mock()), "foo_db");
}
@Test
void assertInsertStatementContextWithoutColumnNames() {
InsertStatement insertStatement = mock(InsertStatement.class);
+ when(insertStatement.getDatabaseType()).thenReturn(databaseType);
TableNameSegment tableNameSegment = new TableNameSegment(0, 0, new IdentifierValue("tbl"));
tableNameSegment.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
when(insertStatement.getTable()).thenReturn(Optional.of(new SimpleTableSegment(tableNameSegment)));
@@ -102,6 +104,7 @@ class InsertStatementContextTest {
@Test
void assertGetGroupedParametersWithoutOnDuplicateParameter() {
InsertStatement insertStatement = mock(InsertStatement.class);
+ when(insertStatement.getDatabaseType()).thenReturn(databaseType);
TableNameSegment tableNameSegment = new TableNameSegment(0, 0, new IdentifierValue("tbl"));
tableNameSegment.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
when(insertStatement.getTable()).thenReturn(Optional.of(new SimpleTableSegment(tableNameSegment)));
@@ -116,6 +119,7 @@ class InsertStatementContextTest {
@Test
void assertGetGroupedParametersWithOnDuplicateParameters() {
InsertStatement insertStatement = mock(InsertStatement.class);
+ when(insertStatement.getDatabaseType()).thenReturn(databaseType);
TableNameSegment tableNameSegment = new TableNameSegment(0, 0, new IdentifierValue("tbl"));
tableNameSegment.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
when(insertStatement.getTable()).thenReturn(Optional.of(new SimpleTableSegment(tableNameSegment)));
@@ -219,6 +223,7 @@ class InsertStatementContextTest {
@Test
void assertContainsInsertColumnsWithSetAssignment() {
InsertStatement insertStatement = mock(InsertStatement.class);
+ when(insertStatement.getDatabaseType()).thenReturn(databaseType);
when(insertStatement.getSetAssignment()).thenReturn(Optional.of(new SetAssignmentSegment(0, 0, Collections.emptyList())));
TableNameSegment tableNameSegment = new TableNameSegment(0, 0, new IdentifierValue(""));
tableNameSegment.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
@@ -242,6 +247,7 @@ class InsertStatementContextTest {
@Test
void assertGetValueListCountWithSetAssignment() {
InsertStatement insertStatement = mock(InsertStatement.class);
+ when(insertStatement.getDatabaseType()).thenReturn(databaseType);
List<ColumnSegment> columns = new LinkedList<>();
columns.add(new ColumnSegment(0, 0, new IdentifierValue("col")));
ColumnAssignmentSegment insertStatementAssignment = new ColumnAssignmentSegment(0, 0, columns, new LiteralExpressionSegment(0, 0, 1));
@@ -270,6 +276,7 @@ class InsertStatementContextTest {
@Test
void assertGetInsertColumnNamesForSetAssignment() {
InsertStatement insertStatement = mock(InsertStatement.class);
+ when(insertStatement.getDatabaseType()).thenReturn(databaseType);
List<ColumnSegment> columns = new LinkedList<>();
columns.add(new ColumnSegment(0, 0, new IdentifierValue("col")));
ColumnAssignmentSegment insertStatementAssignment = new ColumnAssignmentSegment(0, 0, columns, new LiteralExpressionSegment(0, 0, 1));
diff --git a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/dml/SelectStatementContextTest.java b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/dml/SelectStatementContextTest.java
index 400a339f418..3a9a46e1c41 100644
--- a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/dml/SelectStatementContextTest.java
+++ b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/dml/SelectStatementContextTest.java
@@ -91,8 +91,8 @@ class SelectStatementContextTest {
tableNameSegment.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
selectStatement.setFrom(new SimpleTableSegment(tableNameSegment));
ShardingSphereDatabase database = mockDatabase();
- SelectStatementContext selectStatementContext =
- new SelectStatementContext(databaseType, selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
+ SelectStatementContext selectStatementContext = new SelectStatementContext(
+ selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
selectStatementContext.setIndexes(Collections.emptyMap());
assertThat(selectStatementContext.getOrderByContext().getItems().iterator().next().getIndex(), is(4));
}
@@ -117,8 +117,8 @@ class SelectStatementContextTest {
tableSegment.setOwner(new OwnerSegment(0, 0, new IdentifierValue("foo_db".toUpperCase())));
selectStatement.setFrom(tableSegment);
ShardingSphereDatabase database = mockDatabase();
- SelectStatementContext selectStatementContext =
- new SelectStatementContext(databaseType, selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
+ SelectStatementContext selectStatementContext = new SelectStatementContext(
+ selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
selectStatementContext.setIndexes(Collections.emptyMap());
assertThat(selectStatementContext.getOrderByContext().getItems().iterator().next().getIndex(), is(1));
}
@@ -129,8 +129,8 @@ class SelectStatementContextTest {
ShardingSphereDatabase database = mockDatabase();
selectStatement.setOrderBy(new OrderBySegment(0, 0, Collections.singletonList(createOrderByItemSegment(COLUMN_ORDER_BY_WITH_ALIAS))));
selectStatement.setProjections(createProjectionsSegment());
- SelectStatementContext selectStatementContext =
- new SelectStatementContext(databaseType, selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
+ SelectStatementContext selectStatementContext = new SelectStatementContext(
+ selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
selectStatementContext.setIndexes(Collections.singletonMap("n", 2));
assertThat(selectStatementContext.getOrderByContext().getItems().iterator().next().getIndex(), is(2));
}
@@ -141,8 +141,8 @@ class SelectStatementContextTest {
ShardingSphereDatabase database = mockDatabase();
selectStatement.setOrderBy(new OrderBySegment(0, 0, Collections.singletonList(createOrderByItemSegment(COLUMN_ORDER_BY_WITHOUT_OWNER_ALIAS))));
selectStatement.setProjections(createProjectionsSegment());
- SelectStatementContext selectStatementContext =
- new SelectStatementContext(databaseType, selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
+ SelectStatementContext selectStatementContext = new SelectStatementContext(
+ selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
selectStatementContext.setIndexes(Collections.singletonMap("id", 3));
assertThat(selectStatementContext.getOrderByContext().getItems().iterator().next().getIndex(), is(3));
}
@@ -160,7 +160,7 @@ class SelectStatementContextTest {
private SelectStatementContext createSelectStatementContext(final SelectStatement selectStatement) {
ShardingSphereMetaData metaData = new ShardingSphereMetaData(
Collections.singleton(mockDatabase()), mock(ResourceMetaData.class), mock(RuleMetaData.class), mock(ConfigurationProperties.class));
- return new SelectStatementContext(databaseType, selectStatement, Collections.emptyList(), metaData, "foo_db", Collections.emptyList());
+ return new SelectStatementContext(selectStatement, Collections.emptyList(), metaData, "foo_db", Collections.emptyList());
}
@Test
@@ -191,8 +191,8 @@ class SelectStatementContextTest {
projectionsSegment.getProjections().add(aggregationProjectionSegment);
selectStatement.setProjections(projectionsSegment);
ShardingSphereDatabase database = mockDatabase();
- SelectStatementContext selectStatementContext =
- new SelectStatementContext(databaseType, selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
+ SelectStatementContext selectStatementContext = new SelectStatementContext(
+ selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
selectStatementContext.setIndexes(Collections.singletonMap("id", 3));
assertThat(selectStatementContext.getOrderByContext().getItems().iterator().next().getIndex(), is(3));
}
@@ -205,8 +205,7 @@ class SelectStatementContextTest {
selectStatement.setWhere(whereSegment);
ShardingSphereDatabase database = mockDatabase();
selectStatement.setProjections(new ProjectionsSegment(0, 0));
- SelectStatementContext actual =
- new SelectStatementContext(databaseType, selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
+ SelectStatementContext actual = new SelectStatementContext(selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
assertThat(actual.getTablesContext().getTableNames(), is(Collections.emptySet()));
assertThat(actual.getTablesContext().getSimpleTables(), is(Collections.emptyList()));
assertThat(actual.getGroupByContext().getItems(), is(Collections.emptyList()));
@@ -230,7 +229,7 @@ class SelectStatementContextTest {
SelectStatement selectStatement = new SelectStatement(databaseType);
selectStatement.setProjections(projectionsSegment);
ShardingSphereDatabase database = mockDatabase();
- assertTrue(new SelectStatementContext(databaseType, selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList()).isContainsSubquery());
+ assertTrue(new SelectStatementContext(selectStatement, Collections.emptyList(), createShardingSphereMetaData(database), "foo_db", Collections.emptyList()).isContainsSubquery());
}
@Test
@@ -256,7 +255,7 @@ class SelectStatementContextTest {
selectStatement.setProjections(projectionsSegment);
ShardingSphereMetaData metaData = new ShardingSphereMetaData(
Collections.singleton(mockDatabase()), mock(ResourceMetaData.class), mock(RuleMetaData.class), mock(ConfigurationProperties.class));
- assertTrue(new SelectStatementContext(databaseType, selectStatement, Collections.emptyList(), metaData, "foo_db", Collections.emptyList()).isContainsSubquery());
+ assertTrue(new SelectStatementContext(selectStatement, Collections.emptyList(), metaData, "foo_db", Collections.emptyList()).isContainsSubquery());
}
@Test
@@ -267,13 +266,13 @@ class SelectStatementContextTest {
selectStatement.setProjections(projectionsSegment);
ShardingSphereMetaData metaData = new ShardingSphereMetaData(
Collections.singleton(mockDatabase()), mock(ResourceMetaData.class), mock(RuleMetaData.class), mock(ConfigurationProperties.class));
- SelectStatementContext selectStatementContext = new SelectStatementContext(databaseType, selectStatement, Collections.emptyList(), metaData, "foo_db", Collections.emptyList());
+ SelectStatementContext selectStatementContext = new SelectStatementContext(selectStatement, Collections.emptyList(), metaData, "foo_db", Collections.emptyList());
assertTrue(selectStatementContext.isContainsDollarParameterMarker());
selectStatement.setProjections(new ProjectionsSegment(0, 0));
JoinTableSegment joinTableSegment = new JoinTableSegment();
joinTableSegment.setCondition(new ParameterMarkerExpressionSegment(0, 0, 0, ParameterMarkerType.DOLLAR));
selectStatement.setFrom(joinTableSegment);
- selectStatementContext = new SelectStatementContext(databaseType, selectStatement, Collections.emptyList(), metaData, "foo_db", Collections.emptyList());
+ selectStatementContext = new SelectStatementContext(selectStatement, Collections.emptyList(), metaData, "foo_db", Collections.emptyList());
assertTrue(selectStatementContext.isContainsDollarParameterMarker());
}
@@ -286,7 +285,7 @@ class SelectStatementContextTest {
selectStatement.setProjections(projectionsSegment);
ShardingSphereMetaData metaData = new ShardingSphereMetaData(
Collections.singleton(mockDatabase()), mock(ResourceMetaData.class), mock(RuleMetaData.class), mock(ConfigurationProperties.class));
- SelectStatementContext selectStatementContext = new SelectStatementContext(databaseType, selectStatement, Collections.emptyList(), metaData, "foo_db", Collections.emptyList());
+ SelectStatementContext selectStatementContext = new SelectStatementContext(selectStatement, Collections.emptyList(), metaData, "foo_db", Collections.emptyList());
assertTrue(selectStatementContext.isContainsPartialDistinctAggregation());
}
@@ -344,7 +343,7 @@ class SelectStatementContextTest {
selectStatement.setFrom(new SimpleTableSegment(tableNameSegment));
ShardingSphereMetaData metaData = new ShardingSphereMetaData(
Collections.singleton(mockDatabase()), mock(ResourceMetaData.class), mock(RuleMetaData.class), mock(ConfigurationProperties.class));
- SelectStatementContext actual = new SelectStatementContext(databaseType, selectStatement, Collections.emptyList(), metaData, "foo_db", Collections.emptyList());
+ SelectStatementContext actual = new SelectStatementContext(selectStatement, Collections.emptyList(), metaData, "foo_db", Collections.emptyList());
assertTrue(actual.isContainsEnhancedTable());
}
@@ -355,7 +354,7 @@ class SelectStatementContextTest {
selectStatement.setFrom(new SubqueryTableSegment(0, 0, new SubquerySegment(0, 0, createSubSelectStatement(), "")));
ShardingSphereMetaData metaData = new ShardingSphereMetaData(
Collections.singleton(mockDatabase()), mock(ResourceMetaData.class), mock(RuleMetaData.class), mock(ConfigurationProperties.class));
- SelectStatementContext actual = new SelectStatementContext(databaseType, selectStatement, Collections.emptyList(), metaData, "foo_db", Collections.emptyList());
+ SelectStatementContext actual = new SelectStatementContext(selectStatement, Collections.emptyList(), metaData, "foo_db", Collections.emptyList());
assertTrue(actual.containsTableSubquery());
}
diff --git a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/dml/UpdateStatementContextTest.java b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/dml/UpdateStatementContextTest.java
index b00c2f5befd..f9c8a8b2f60 100644
--- a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/dml/UpdateStatementContextTest.java
+++ b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/dml/UpdateStatementContextTest.java
@@ -43,7 +43,6 @@ import java.util.stream.Collectors;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@ExtendWith(MockitoExtension.class)
@@ -77,7 +76,7 @@ class UpdateStatementContextTest {
updateStatement.setWhere(whereSegment);
updateStatement.setTable(joinTableSegment);
updateStatement.setSetAssignment(new SetAssignmentSegment(0, 0, Collections.emptyList()));
- UpdateStatementContext actual = new UpdateStatementContext(mock(), updateStatement);
+ UpdateStatementContext actual = new UpdateStatementContext(updateStatement);
assertThat(actual.getTablesContext().getTableNames(), is(new HashSet<>(Arrays.asList("tbl_1", "tbl_2"))));
assertThat(actual.getWhereSegments(), is(Collections.singletonList(whereSegment)));
assertThat(actual.getTablesContext().getSimpleTables().stream().map(each -> each.getTableName().getIdentifier().getValue()).collect(Collectors.toList()),
diff --git a/infra/context/src/test/java/org/apache/shardingsphere/infra/connection/kernel/KernelProcessorTest.java b/infra/context/src/test/java/org/apache/shardingsphere/infra/connection/kernel/KernelProcessorTest.java
index 32c42dd613c..a3c1081688d 100644
--- a/infra/context/src/test/java/org/apache/shardingsphere/infra/connection/kernel/KernelProcessorTest.java
+++ b/infra/context/src/test/java/org/apache/shardingsphere/infra/connection/kernel/KernelProcessorTest.java
@@ -61,7 +61,7 @@ class KernelProcessorTest {
@Test
void assertGenerateExecutionContext() {
- SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(databaseType, new SelectStatement(databaseType));
+ SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(new SelectStatement(databaseType));
ConnectionContext connectionContext = mock(ConnectionContext.class);
when(connectionContext.getCurrentDatabaseName()).thenReturn(Optional.of("foo_db"));
ShardingSphereMetaData metaData = mock(ShardingSphereMetaData.class);
diff --git a/infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/process/ProcessEngineTest.java b/infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/process/ProcessEngineTest.java
index dba7668e3b8..86bbe582824 100644
--- a/infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/process/ProcessEngineTest.java
+++ b/infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/process/ProcessEngineTest.java
@@ -68,7 +68,7 @@ class ProcessEngineTest {
ShardingSphereMetaData metaData = mock(ShardingSphereMetaData.class);
ExecutionGroupContext<? extends SQLExecutionUnit> executionGroupContext = mockExecutionGroupContext();
new ProcessEngine().executeSQL(executionGroupContext,
- new QueryContext(new UpdateStatementContext(mock(), getSQLStatement()), null, null, new HintValueContext(), connectionContext, metaData));
+ new QueryContext(new UpdateStatementContext(getSQLStatement()), null, null, new HintValueContext(), connectionContext, metaData));
verify(processRegistry).add(any());
}
diff --git a/infra/rewrite/core/src/main/java/org/apache/shardingsphere/infra/rewrite/sql/impl/AbstractSQLBuilder.java b/infra/rewrite/core/src/main/java/org/apache/shardingsphere/infra/rewrite/sql/impl/AbstractSQLBuilder.java
index ec94f012d4d..0dbbb24741a 100644
--- a/infra/rewrite/core/src/main/java/org/apache/shardingsphere/infra/rewrite/sql/impl/AbstractSQLBuilder.java
+++ b/infra/rewrite/core/src/main/java/org/apache/shardingsphere/infra/rewrite/sql/impl/AbstractSQLBuilder.java
@@ -47,8 +47,7 @@ public abstract class AbstractSQLBuilder implements SQLBuilder {
result.append(sql, 0, sqlTokens.get(0).getStartIndex());
Optional<SQLToken> previousToken = Optional.empty();
for (SQLToken each : sqlTokens) {
- if (isContainsAttachableToken(each, previousToken.orElse(null))
- || each.getStartIndex() > previousToken.map(SQLToken::getStopIndex).orElse(0)) {
+ if (isContainsAttachableToken(each, previousToken.orElse(null)) || each.getStartIndex() > previousToken.map(SQLToken::getStopIndex).orElse(0)) {
appendRewriteSQL(each, result);
previousToken = Optional.of(each);
}
diff --git a/infra/rewrite/core/src/main/java/org/apache/shardingsphere/infra/rewrite/sql/impl/RouteSQLBuilder.java b/infra/rewrite/core/src/main/java/org/apache/shardingsphere/infra/rewrite/sql/impl/RouteSQLBuilder.java
index cedd401df7d..baf24ad18dc 100644
--- a/infra/rewrite/core/src/main/java/org/apache/shardingsphere/infra/rewrite/sql/impl/RouteSQLBuilder.java
+++ b/infra/rewrite/core/src/main/java/org/apache/shardingsphere/infra/rewrite/sql/impl/RouteSQLBuilder.java
@@ -37,9 +37,6 @@ public final class RouteSQLBuilder extends AbstractSQLBuilder {
@Override
protected String getSQLTokenText(final SQLToken sqlToken) {
- if (sqlToken instanceof RouteUnitAware) {
- return ((RouteUnitAware) sqlToken).toString(routeUnit);
- }
- return sqlToken.toString();
+ return sqlToken instanceof RouteUnitAware ? ((RouteUnitAware) sqlToken).toString(routeUnit) : sqlToken.toString();
}
}
diff --git a/kernel/single/core/src/test/java/org/apache/shardingsphere/single/checker/sql/SingleDropSchemaSupportedCheckerTest.java b/kernel/single/core/src/test/java/org/apache/shardingsphere/single/checker/sql/SingleDropSchemaSupportedCheckerTest.java
index 909ef8a357a..ae4d9aad053 100644
--- a/kernel/single/core/src/test/java/org/apache/shardingsphere/single/checker/sql/SingleDropSchemaSupportedCheckerTest.java
+++ b/kernel/single/core/src/test/java/org/apache/shardingsphere/single/checker/sql/SingleDropSchemaSupportedCheckerTest.java
@@ -79,6 +79,6 @@ class SingleDropSchemaSupportedCheckerTest {
when(dropSchemaStatement.isContainsCascade()).thenReturn(containsCascade);
when(dropSchemaStatement.getSchemaNames()).thenReturn(Collections.singleton(new IdentifierValue(schemaName)));
when(dropSchemaStatement.getAttributes()).thenReturn(new SQLStatementAttributes());
- return new CommonSQLStatementContext(mock(), dropSchemaStatement);
+ return new CommonSQLStatementContext(dropSchemaStatement);
}
}
diff --git a/kernel/single/core/src/test/java/org/apache/shardingsphere/single/checker/sql/SingleDropTableSupportedCheckerTest.java b/kernel/single/core/src/test/java/org/apache/shardingsphere/single/checker/sql/SingleDropTableSupportedCheckerTest.java
index eb645d8ba82..e465429e961 100644
--- a/kernel/single/core/src/test/java/org/apache/shardingsphere/single/checker/sql/SingleDropTableSupportedCheckerTest.java
+++ b/kernel/single/core/src/test/java/org/apache/shardingsphere/single/checker/sql/SingleDropTableSupportedCheckerTest.java
@@ -69,6 +69,6 @@ class SingleDropTableSupportedCheckerTest {
when(dropSchemaStatement.isContainsCascade()).thenReturn(containsCascade);
when(dropSchemaStatement.getTables()).thenReturn(Collections.emptyList());
when(dropSchemaStatement.getAttributes()).thenReturn(new SQLStatementAttributes());
- return new CommonSQLStatementContext(mock(), dropSchemaStatement);
+ return new CommonSQLStatementContext(dropSchemaStatement);
}
}
diff --git a/kernel/single/core/src/test/java/org/apache/shardingsphere/single/route/SingleSQLRouterTest.java b/kernel/single/core/src/test/java/org/apache/shardingsphere/single/route/SingleSQLRouterTest.java
index e7bd061b239..c4a2abb04b8 100644
--- a/kernel/single/core/src/test/java/org/apache/shardingsphere/single/route/SingleSQLRouterTest.java
+++ b/kernel/single/core/src/test/java/org/apache/shardingsphere/single/route/SingleSQLRouterTest.java
@@ -224,6 +224,6 @@ class SingleSQLRouterTest {
ShardingSphereMetaData metaData = mock(ShardingSphereMetaData.class);
when(metaData.containsDatabase("foo_db")).thenReturn(true);
when(metaData.getDatabase("foo_db")).thenReturn(mock(ShardingSphereDatabase.class));
- return new QueryContext(new CommonSQLStatementContext(databaseType, createTableStatement), "CREATE TABLE", new LinkedList<>(), new HintValueContext(), connectionContext, metaData);
+ return new QueryContext(new CommonSQLStatementContext(createTableStatement), "CREATE TABLE", new LinkedList<>(), new HintValueContext(), connectionContext, metaData);
}
}
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/StandardDatabaseConnector.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/StandardDatabaseConnector.java
index f7aa7b9bed5..b5a2e590ce6 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/StandardDatabaseConnector.java
+++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/StandardDatabaseConnector.java
@@ -250,8 +250,7 @@ public final class StandardDatabaseConnector implements DatabaseConnector {
private ResultSet doExecuteFederation() throws SQLException {
SQLStatement sqlStatement = queryContext.getSqlStatementContext().getSqlStatement();
DialectDatabaseMetaData dialectDatabaseMetaData = new DatabaseTypeRegistry(sqlStatement.getDatabaseType()).getDialectDatabaseMetaData();
- boolean isReturnGeneratedKeys = sqlStatement instanceof InsertStatement
- && dialectDatabaseMetaData.getGeneratedKeyOption().isSupportReturnGeneratedKeys();
+ boolean isReturnGeneratedKeys = sqlStatement instanceof InsertStatement && dialectDatabaseMetaData.getGeneratedKeyOption().isSupportReturnGeneratedKeys();
DatabaseType protocolType = database.getProtocolType();
ProxyJDBCExecutorCallback callback = ProxyJDBCExecutorCallbackFactory.newInstance(driverType, protocolType, database.getResourceMetaData(),
sqlStatement, this, isReturnGeneratedKeys, SQLExecutorExceptionHandler.isExceptionThrown(), true);
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/distsql/DistSQLStatementContext.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/distsql/DistSQLStatementContext.java
index 80c994ba738..30058bf2805 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/distsql/DistSQLStatementContext.java
+++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/distsql/DistSQLStatementContext.java
@@ -22,7 +22,6 @@ import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.distsql.statement.DistSQLStatement;
import org.apache.shardingsphere.infra.binder.context.segment.table.TablesContext;
import org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
-import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
import java.util.Collections;
@@ -39,9 +38,4 @@ public final class DistSQLStatementContext implements SQLStatementContext {
public TablesContext getTablesContext() {
return new TablesContext(Collections.emptyList());
}
-
- @Override
- public DatabaseType getDatabaseType() {
- throw new UnsupportedOperationException("Cannot get database type of DistSQLStatementContext");
- }
}
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/ProxySQLExecutorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/ProxySQLExecutorTest.java
index 9ad35e5e88f..0e0d950d405 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/ProxySQLExecutorTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/ProxySQLExecutorTest.java
@@ -256,12 +256,12 @@ class ProxySQLExecutorTest {
private CommonSQLStatementContext createCreateTableStatementContext(final DatabaseType databaseType) {
CreateTableStatement sqlStatement = new CreateTableStatement(databaseType);
sqlStatement.setTable(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("t_order"))));
- return new CommonSQLStatementContext(databaseType, sqlStatement);
+ return new CommonSQLStatementContext(sqlStatement);
}
private SQLStatementContext createTruncateStatementContext(final DatabaseType databaseType) {
TruncateStatement sqlStatement = new TruncateStatement(databaseType, Collections.singleton(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("t_order")))));
- return new CommonSQLStatementContext(databaseType, sqlStatement);
+ return new CommonSQLStatementContext(sqlStatement);
}
private CursorStatementContext mockCursorStatementContext() {
@@ -276,6 +276,6 @@ class ProxySQLExecutorTest {
sqlStatement.setTable(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("t_order"))));
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
when(database.getName()).thenReturn("foo_db");
- return new InsertStatementContext(databaseType, sqlStatement, Collections.emptyList(), new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), mock()), "foo_db");
+ return new InsertStatementContext(sqlStatement, Collections.emptyList(), new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), mock()), "foo_db");
}
}
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/data/DatabaseBackendHandlerFactoryTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/data/DatabaseBackendHandlerFactoryTest.java
index ad72eba3520..bf05917b345 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/data/DatabaseBackendHandlerFactoryTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/data/DatabaseBackendHandlerFactoryTest.java
@@ -80,7 +80,7 @@ class DatabaseBackendHandlerFactoryTest {
@Test
void assertNewInstanceReturnedUnicastDatabaseBackendHandlerWithQueryWithoutFrom() {
String sql = "SELECT 1";
- SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(mock(), new SelectStatement(databaseType));
+ SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(new SelectStatement(databaseType));
DatabaseBackendHandler actual = DatabaseBackendHandlerFactory.newInstance(
new QueryContext(sqlStatementContext, sql, Collections.emptyList(), new HintValueContext(), mockConnectionContext(), mock()), mock(), false);
assertThat(actual, instanceOf(UnicastDatabaseBackendHandler.class));
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/tcl/TCLBackendHandlerFactoryTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/tcl/TCLBackendHandlerFactoryTest.java
index e934c17db05..5b68e313290 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/tcl/TCLBackendHandlerFactoryTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/tcl/TCLBackendHandlerFactoryTest.java
@@ -77,7 +77,7 @@ class TCLBackendHandlerFactoryTest {
when(databaseConnectionManager.getConnectionSession().getConnectionContext().getTransactionContext()).thenReturn(new TransactionConnectionContext());
ContextManager contextManager = mockContextManager();
when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager);
- ProxyBackendHandler proxyBackendHandler = TCLBackendHandlerFactory.newInstance(new CommonSQLStatementContext(databaseType, new CommitStatement(databaseType)), null, connectionSession);
+ ProxyBackendHandler proxyBackendHandler = TCLBackendHandlerFactory.newInstance(new CommonSQLStatementContext(new CommitStatement(databaseType)), null, connectionSession);
assertThat(proxyBackendHandler, instanceOf(TCLBackendHandler.class));
TCLBackendHandler backendHandler = (TCLBackendHandler) proxyBackendHandler;
assertFieldOfInstance(backendHandler, "operationType", is(TransactionOperationType.COMMIT));
@@ -95,7 +95,7 @@ class TCLBackendHandlerFactoryTest {
when(connectionSession.getDatabaseConnectionManager().getConnectionSession().getConnectionContext().getTransactionContext()).thenReturn(new TransactionConnectionContext());
ContextManager contextManager = mockContextManager();
when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager);
- ProxyBackendHandler proxyBackendHandler = TCLBackendHandlerFactory.newInstance(new CommonSQLStatementContext(databaseType, new RollbackStatement(databaseType)), null, connectionSession);
+ ProxyBackendHandler proxyBackendHandler = TCLBackendHandlerFactory.newInstance(new CommonSQLStatementContext(new RollbackStatement(databaseType)), null, connectionSession);
assertThat(proxyBackendHandler, instanceOf(TCLBackendHandler.class));
TCLBackendHandler backendHandler = (TCLBackendHandler) proxyBackendHandler;
assertFieldOfInstance(backendHandler, "operationType", is(TransactionOperationType.ROLLBACK));
diff --git a/proxy/backend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/MySQLAdminExecutorCreatorTest.java b/proxy/backend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/MySQLAdminExecutorCreatorTest.java
index 8f8567c3e08..8b0963f0479 100644
--- a/proxy/backend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/MySQLAdminExecutorCreatorTest.java
+++ b/proxy/backend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/MySQLAdminExecutorCreatorTest.java
@@ -95,7 +95,7 @@ class MySQLAdminExecutorCreatorTest {
@Test
void assertCreateWithMySQLShowFunctionStatus() {
- SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(databaseType, new MySQLShowFunctionStatusStatement(databaseType, null));
+ SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(new MySQLShowFunctionStatusStatement(databaseType, null));
Optional<DatabaseAdminExecutor> actual = new MySQLAdminExecutorCreator().create(sqlStatementContext, "", "", Collections.emptyList());
assertTrue(actual.isPresent());
assertThat(actual.get(), instanceOf(ShowFunctionStatusExecutor.class));
@@ -103,7 +103,7 @@ class MySQLAdminExecutorCreatorTest {
@Test
void assertCreateWithShowProcedureStatus() {
- SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(databaseType, new MySQLShowProcedureStatusStatement(databaseType, null));
+ SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(new MySQLShowProcedureStatusStatement(databaseType, null));
Optional<DatabaseAdminExecutor> actual = new MySQLAdminExecutorCreator().create(sqlStatementContext, "", "", Collections.emptyList());
assertTrue(actual.isPresent());
assertThat(actual.get(), instanceOf(ShowProcedureStatusExecutor.class));
@@ -111,7 +111,7 @@ class MySQLAdminExecutorCreatorTest {
@Test
void assertCreateWithShowTables() {
- SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(databaseType, new MySQLShowTablesStatement(databaseType, null, null, false));
+ SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(new MySQLShowTablesStatement(databaseType, null, null, false));
Optional<DatabaseAdminExecutor> actual = new MySQLAdminExecutorCreator().create(sqlStatementContext, "", "", Collections.emptyList());
assertTrue(actual.isPresent());
assertThat(actual.get(), instanceOf(ShowTablesExecutor.class));
@@ -125,7 +125,7 @@ class MySQLAdminExecutorCreatorTest {
@Test
void assertCreateWithUse() {
- SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(databaseType, new MySQLUseStatement(databaseType, null));
+ SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(new MySQLUseStatement(databaseType, null));
Optional<DatabaseAdminExecutor> actual = new MySQLAdminExecutorCreator().create(sqlStatementContext, "use db", "", Collections.emptyList());
assertTrue(actual.isPresent());
assertThat(actual.get(), instanceOf(UseDatabaseExecutor.class));
@@ -133,7 +133,7 @@ class MySQLAdminExecutorCreatorTest {
@Test
void assertCreateWithShowDatabasesStatement() {
- SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(databaseType, new MySQLShowDatabasesStatement(databaseType, null));
+ SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(new MySQLShowDatabasesStatement(databaseType, null));
Optional<DatabaseAdminExecutor> actual = new MySQLAdminExecutorCreator().create(sqlStatementContext, "", "", Collections.emptyList());
assertTrue(actual.isPresent());
assertThat(actual.get(), instanceOf(ShowDatabasesExecutor.class));
@@ -141,7 +141,7 @@ class MySQLAdminExecutorCreatorTest {
@Test
void assertCreateWithMySQLShowProcessListStatement() {
- SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(databaseType, new MySQLShowProcessListStatement(databaseType, false));
+ SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(new MySQLShowProcessListStatement(databaseType, false));
Optional<DatabaseAdminExecutor> actual = new MySQLAdminExecutorCreator().create(sqlStatementContext, "", "", Collections.emptyList());
assertTrue(actual.isPresent());
assertThat(actual.get(), instanceOf(ShowProcessListExecutor.class));
@@ -149,7 +149,7 @@ class MySQLAdminExecutorCreatorTest {
@Test
void assertCreateWithMySQLShowCreateDatabaseStatement() {
- SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(databaseType, new MySQLShowCreateDatabaseStatement(databaseType, null));
+ SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(new MySQLShowCreateDatabaseStatement(databaseType, null));
Optional<DatabaseAdminExecutor> actual = new MySQLAdminExecutorCreator().create(sqlStatementContext, "", "", Collections.emptyList());
assertTrue(actual.isPresent());
assertThat(actual.get(), instanceOf(ShowCreateDatabaseExecutor.class));
@@ -157,7 +157,7 @@ class MySQLAdminExecutorCreatorTest {
@Test
void assertCreateWithSetStatement() {
- SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(databaseType, new SetStatement(databaseType, Collections.emptyList()));
+ SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(new SetStatement(databaseType, Collections.emptyList()));
Optional<DatabaseAdminExecutor> actual = new MySQLAdminExecutorCreator().create(sqlStatementContext, "", "", Collections.emptyList());
assertTrue(actual.isPresent());
assertThat(actual.get(), instanceOf(MySQLSetVariableAdminExecutor.class));
@@ -372,7 +372,7 @@ class MySQLAdminExecutorCreatorTest {
@Test
void assertCreateWithDMLStatement() {
- SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(mock(), new DeleteStatement(databaseType));
+ SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(new DeleteStatement(databaseType));
Optional<DatabaseAdminExecutor> actual = new MySQLAdminExecutorCreator().create(sqlStatementContext, "delete from t", "", Collections.emptyList());
assertThat(actual, is(Optional.empty()));
}
diff --git a/proxy/backend/type/opengauss/src/test/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/OpenGaussAdminExecutorFactoryTest.java b/proxy/backend/type/opengauss/src/test/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/OpenGaussAdminExecutorFactoryTest.java
index 2895f7455eb..fe7dcb57bcb 100644
--- a/proxy/backend/type/opengauss/src/test/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/OpenGaussAdminExecutorFactoryTest.java
+++ b/proxy/backend/type/opengauss/src/test/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/OpenGaussAdminExecutorFactoryTest.java
@@ -68,7 +68,7 @@ class OpenGaussAdminExecutorFactoryTest {
@Test
void assertNewInstanceWithSQLStatementContext() {
- SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(mock(), new ShowStatement(databaseType, "all"));
+ SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(new ShowStatement(databaseType, "all"));
Optional<DatabaseAdminExecutor> actual = openGaussAdminExecutorFactory.create(sqlStatementContext);
assertTrue(actual.isPresent());
}
diff --git a/proxy/backend/type/opengauss/src/test/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/OpenGaussSystemCatalogAdminQueryExecutorTest.java b/proxy/backend/type/opengauss/src/test/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/OpenGaussSystemCatalogAdminQueryExecutorTest.java
index fd025fc1d4f..24c546ec348 100644
--- a/proxy/backend/type/opengauss/src/test/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/OpenGaussSystemCatalogAdminQueryExecutorTest.java
+++ b/proxy/backend/type/opengauss/src/test/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/OpenGaussSystemCatalogAdminQueryExecutorTest.java
@@ -94,7 +94,7 @@ class OpenGaussSystemCatalogAdminQueryExecutorTest {
ShardingSphereMetaData metaData = new ShardingSphereMetaData(databases,
mock(ResourceMetaData.class, RETURNS_DEEP_STUBS), new RuleMetaData(Collections.singletonList(sqlFederationRule)), props);
when(ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData()).thenReturn(metaData);
- SelectStatementContext sqlStatementContext = new SelectStatementContext(databaseType, sqlStatement, Collections.emptyList(), metaData, "sharding_db", Collections.emptyList());
+ SelectStatementContext sqlStatementContext = new SelectStatementContext(sqlStatement, Collections.emptyList(), metaData, "sharding_db", Collections.emptyList());
OpenGaussSystemCatalogAdminQueryExecutor executor = new OpenGaussSystemCatalogAdminQueryExecutor(sqlStatementContext,
"select datname, datcompatibility from pg_database where datname = 'sharding_db'", "sharding_db", Collections.emptyList());
executor.execute(connectionSession);
@@ -156,7 +156,7 @@ class OpenGaussSystemCatalogAdminQueryExecutorTest {
ShardingSphereMetaData metaData =
new ShardingSphereMetaData(databases, mock(ResourceMetaData.class, RETURNS_DEEP_STUBS), new RuleMetaData(Collections.singletonList(sqlFederationRule)), props);
when(ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData()).thenReturn(metaData);
- SelectStatementContext sqlStatementContext = new SelectStatementContext(databaseType, sqlStatement, Collections.emptyList(), metaData, "sharding_db", Collections.emptyList());
+ SelectStatementContext sqlStatementContext = new SelectStatementContext(sqlStatement, Collections.emptyList(), metaData, "sharding_db", Collections.emptyList());
ConnectionSession connectionSession = mock(ConnectionSession.class);
when(connectionSession.getProcessId()).thenReturn("1");
when(connectionSession.getProtocolType()).thenReturn(databaseType);
@@ -193,7 +193,7 @@ class OpenGaussSystemCatalogAdminQueryExecutorTest {
ShardingSphereMetaData metaData =
new ShardingSphereMetaData(databases, mock(ResourceMetaData.class, RETURNS_DEEP_STUBS), new RuleMetaData(Collections.singletonList(sqlFederationRule)), props);
when(ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData()).thenReturn(metaData);
- SelectStatementContext sqlStatementContext = new SelectStatementContext(databaseType, sqlStatement, Collections.emptyList(), metaData, "sharding_db", Collections.emptyList());
+ SelectStatementContext sqlStatementContext = new SelectStatementContext(sqlStatement, Collections.emptyList(), metaData, "sharding_db", Collections.emptyList());
ConnectionSession connectionSession = mock(ConnectionSession.class);
when(connectionSession.getProtocolType()).thenReturn(databaseType);
when(connectionSession.getProcessId()).thenReturn("1");
@@ -232,7 +232,7 @@ class OpenGaussSystemCatalogAdminQueryExecutorTest {
ShardingSphereMetaData metaData = new ShardingSphereMetaData(
databases, mock(ResourceMetaData.class, RETURNS_DEEP_STUBS), new RuleMetaData(Collections.singletonList(sqlFederationRule)), props);
when(ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData()).thenReturn(metaData);
- SelectStatementContext sqlStatementContext = new SelectStatementContext(databaseType, sqlStatement, Collections.emptyList(), metaData, "sharding_db", Collections.emptyList());
+ SelectStatementContext sqlStatementContext = new SelectStatementContext(sqlStatement, Collections.emptyList(), metaData, "sharding_db", Collections.emptyList());
ConnectionSession connectionSession = mock(ConnectionSession.class);
when(connectionSession.getProtocolType()).thenReturn(databaseType);
when(connectionSession.getProcessId()).thenReturn("1");
diff --git a/proxy/backend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/backend/postgresql/handler/admin/PostgreSQLAdminExecutorCreatorTest.java b/proxy/backend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/backend/postgresql/handler/admin/PostgreSQLAdminExecutorCreatorTest.java
index f2f136fb8fd..a880be33931 100644
--- a/proxy/backend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/backend/postgresql/handler/admin/PostgreSQLAdminExecutorCreatorTest.java
+++ b/proxy/backend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/backend/postgresql/handler/admin/PostgreSQLAdminExecutorCreatorTest.java
@@ -87,12 +87,12 @@ class PostgreSQLAdminExecutorCreatorTest {
@Test
void assertCreateWithOtherSQLStatementContextOnly() {
- assertThat(new PostgreSQLAdminExecutorCreator().create(new CommonSQLStatementContext(databaseType, new InsertStatement(databaseType))), is(Optional.empty()));
+ assertThat(new PostgreSQLAdminExecutorCreator().create(new CommonSQLStatementContext(new InsertStatement(databaseType))), is(Optional.empty()));
}
@Test
void assertCreateWithShowSQLStatement() {
- Optional<DatabaseAdminExecutor> actual = new PostgreSQLAdminExecutorCreator().create(new CommonSQLStatementContext(databaseType, new ShowStatement(databaseType, "client_encoding")));
+ Optional<DatabaseAdminExecutor> actual = new PostgreSQLAdminExecutorCreator().create(new CommonSQLStatementContext(new ShowStatement(databaseType, "client_encoding")));
assertTrue(actual.isPresent());
assertThat(actual.get(), instanceOf(PostgreSQLShowVariableExecutor.class));
}
@@ -148,7 +148,7 @@ class PostgreSQLAdminExecutorCreatorTest {
@Test
void assertCreateWithSetStatement() {
- SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(databaseType, new SetStatement(databaseType, Collections.emptyList()));
+ SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(new SetStatement(databaseType, Collections.emptyList()));
Optional<DatabaseAdminExecutor> actual = new PostgreSQLAdminExecutorCreator().create(sqlStatementContext, "SET client_encoding = utf8", "", Collections.emptyList());
assertTrue(actual.isPresent());
assertThat(actual.get(), instanceOf(PostgreSQLSetVariableAdminExecutor.class));
@@ -157,14 +157,14 @@ class PostgreSQLAdminExecutorCreatorTest {
@Test
void assertCreateWithResetStatement() {
Optional<DatabaseAdminExecutor> actual = new PostgreSQLAdminExecutorCreator()
- .create(new CommonSQLStatementContext(databaseType, new PostgreSQLResetParameterStatement(databaseType, "client_encoding")), "RESET client_encoding", "", Collections.emptyList());
+ .create(new CommonSQLStatementContext(new PostgreSQLResetParameterStatement(databaseType, "client_encoding")), "RESET client_encoding", "", Collections.emptyList());
assertTrue(actual.isPresent());
assertThat(actual.get(), instanceOf(PostgreSQLResetVariableAdminExecutor.class));
}
@Test
void assertCreateWithDMLStatement() {
- DeleteStatementContext sqlStatementContext = new DeleteStatementContext(databaseType, new DeleteStatement(databaseType));
+ DeleteStatementContext sqlStatementContext = new DeleteStatementContext(new DeleteStatement(databaseType));
assertThat(new PostgreSQLAdminExecutorCreator().create(sqlStatementContext, "delete from t where id = 1", "", Collections.emptyList()), is(Optional.empty()));
}
}
diff --git a/proxy/frontend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandPacketFactoryTest.java b/proxy/frontend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandPacketFactoryTest.java
index 7c3bdb66aed..7be5c30ccf4 100644
--- a/proxy/frontend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandPacketFactoryTest.java
+++ b/proxy/frontend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandPacketFactoryTest.java
@@ -53,7 +53,6 @@ import java.util.Collections;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.ArgumentMatchers.anyInt;
-import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@ExtendWith(MockitoExtension.class)
@@ -101,7 +100,7 @@ class MySQLCommandPacketFactoryTest {
when(payload.getByteBuf().getIntLE(anyInt())).thenReturn(1);
ServerPreparedStatementRegistry serverPreparedStatementRegistry = new ServerPreparedStatementRegistry();
when(connectionSession.getServerPreparedStatementRegistry()).thenReturn(serverPreparedStatementRegistry);
- SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(mock(), new SelectStatement(databaseType));
+ SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(new SelectStatement(databaseType));
serverPreparedStatementRegistry.addPreparedStatement(1, new MySQLServerPreparedStatement("select 1", sqlStatementContext, new HintValueContext(), Collections.emptyList()));
assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_STMT_EXECUTE, payload, connectionSession), instanceOf(MySQLComStmtExecutePacket.class));
}
diff --git a/proxy/frontend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/execute/MySQLComStmtExecuteExecutorTest.java b/proxy/frontend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/execute/MySQLComStmtExecuteExecutorTest.java
index 08a59bbde98..933bb2c018a 100644
--- a/proxy/frontend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/execute/MySQLComStmtExecuteExecutorTest.java
+++ b/proxy/frontend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/execute/MySQLComStmtExecuteExecutorTest.java
@@ -118,7 +118,7 @@ class MySQLComStmtExecuteExecutorTest {
.thenReturn(new MySQLServerPreparedStatement("UPDATE tbl SET col=1 WHERE id = ?", updateStatementContext, new HintValueContext(), Collections.emptyList()));
when(connectionSession.getServerPreparedStatementRegistry().getPreparedStatement(3))
.thenReturn(
- new MySQLServerPreparedStatement("COMMIT", new CommonSQLStatementContext(databaseType, new CommitStatement(databaseType)), new HintValueContext(), Collections.emptyList()));
+ new MySQLServerPreparedStatement("COMMIT", new CommonSQLStatementContext(new CommitStatement(databaseType)), new HintValueContext(), Collections.emptyList()));
ConnectionContext connectionContext = mockConnectionContext();
when(connectionSession.getConnectionContext()).thenReturn(connectionContext);
when(ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData()).thenReturn(new ShardingSphereMetaData());
diff --git a/proxy/frontend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PortalTest.java b/proxy/frontend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PortalTest.java
index 4da30de262d..06b5ae38d3b 100644
--- a/proxy/frontend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PortalTest.java
+++ b/proxy/frontend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PortalTest.java
@@ -142,7 +142,7 @@ class PortalTest {
@Test
void assertGetName() throws SQLException {
PostgreSQLServerPreparedStatement preparedStatement = new PostgreSQLServerPreparedStatement("",
- new CommonSQLStatementContext(databaseType, new EmptyStatement(databaseType)), new HintValueContext(), Collections.emptyList(), Collections.emptyList());
+ new CommonSQLStatementContext(new EmptyStatement(databaseType)), new HintValueContext(), Collections.emptyList(), Collections.emptyList());
Portal portal = new Portal("", preparedStatement, Collections.emptyList(), Collections.emptyList(), databaseConnectionManager);
assertThat(portal.getName(), is(""));
}
@@ -231,7 +231,7 @@ class PortalTest {
when(proxyBackendHandler.execute()).thenReturn(mock(UpdateResponseHeader.class));
when(proxyBackendHandler.next()).thenReturn(false);
PostgreSQLServerPreparedStatement preparedStatement = new PostgreSQLServerPreparedStatement("",
- new CommonSQLStatementContext(databaseType, new EmptyStatement(databaseType)), new HintValueContext(), Collections.emptyList(), Collections.emptyList());
+ new CommonSQLStatementContext(new EmptyStatement(databaseType)), new HintValueContext(), Collections.emptyList(), Collections.emptyList());
Portal portal = new Portal("", preparedStatement, Collections.emptyList(), Collections.emptyList(), databaseConnectionManager);
portal.bind();
assertThat(portal.describe(), is(PostgreSQLNoDataPacket.getInstance()));
@@ -246,7 +246,7 @@ class PortalTest {
String sql = "set client_encoding = utf8";
SetStatement setStatement = new SetStatement(databaseType, Collections.singletonList(new VariableAssignSegment(0, 0, new VariableSegment(0, 0, "client_encoding"), null)));
PostgreSQLServerPreparedStatement preparedStatement = new PostgreSQLServerPreparedStatement(
- sql, new CommonSQLStatementContext(databaseType, setStatement), new HintValueContext(), Collections.emptyList(), Collections.emptyList());
+ sql, new CommonSQLStatementContext(setStatement), new HintValueContext(), Collections.emptyList(), Collections.emptyList());
Portal portal = new Portal("", preparedStatement, Collections.emptyList(), Collections.emptyList(), databaseConnectionManager);
portal.bind();
List<DatabasePacket> actualPackets = portal.execute(0);
@@ -268,7 +268,7 @@ class PortalTest {
@Test
void assertClose() throws SQLException {
PostgreSQLServerPreparedStatement preparedStatement = new PostgreSQLServerPreparedStatement("",
- new CommonSQLStatementContext(databaseType, new EmptyStatement(databaseType)), new HintValueContext(), Collections.emptyList(), Collections.emptyList());
+ new CommonSQLStatementContext(new EmptyStatement(databaseType)), new HintValueContext(), Collections.emptyList(), Collections.emptyList());
new Portal("", preparedStatement, Collections.emptyList(), Collections.emptyList(), databaseConnectionManager).close();
verify(databaseConnectionManager).unmarkResourceInUse(proxyBackendHandler);
verify(proxyBackendHandler).close();
diff --git a/proxy/frontend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/bind/PostgreSQLComBindExecutorTest.java b/proxy/frontend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/bind/PostgreSQLComBindExecutorTest.java
index 4fa301565f7..2ff3c7b1def 100644
--- a/proxy/frontend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/bind/PostgreSQLComBindExecutorTest.java
+++ b/proxy/frontend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/bind/PostgreSQLComBindExecutorTest.java
@@ -99,7 +99,7 @@ class PostgreSQLComBindExecutorTest {
when(databaseConnectionManager.getConnectionSession()).thenReturn(connectionSession);
String statementId = "S_1";
connectionSession.getServerPreparedStatementRegistry().addPreparedStatement(statementId, new PostgreSQLServerPreparedStatement(
- "", new CommonSQLStatementContext(databaseType, new EmptyStatement(databaseType)), new HintValueContext(), Collections.emptyList(), Collections.emptyList()));
+ "", new CommonSQLStatementContext(new EmptyStatement(databaseType)), new HintValueContext(), Collections.emptyList(), Collections.emptyList()));
when(bindPacket.getStatementId()).thenReturn(statementId);
when(bindPacket.getPortal()).thenReturn("C_1");
when(bindPacket.readParameters(anyList())).thenReturn(Collections.emptyList());
@@ -128,7 +128,7 @@ class PostgreSQLComBindExecutorTest {
String statementId = "S_1";
List<Object> parameters = Arrays.asList(1, "updated_name");
PostgreSQLServerPreparedStatement serverPreparedStatement = new PostgreSQLServerPreparedStatement("update test set name = $2 where id = $1",
- new CommonSQLStatementContext(databaseType, new EmptyStatement(databaseType)), new HintValueContext(),
+ new CommonSQLStatementContext(new EmptyStatement(databaseType)), new HintValueContext(),
Arrays.asList(PostgreSQLColumnType.VARCHAR, PostgreSQLColumnType.INT4), Arrays.asList(1, 0));
connectionSession.getServerPreparedStatementRegistry().addPreparedStatement(statementId, serverPreparedStatement);
when(bindPacket.getStatementId()).thenReturn(statementId);