You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2022/05/15 10:48:55 UTC
[shardingsphere] branch master updated: Remove DatabaseTypeEngine.getDefaultDatabaseType() (#17671)
This is an automated email from the ASF dual-hosted git repository.
panjuan 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 eec970fb0ee Remove DatabaseTypeEngine.getDefaultDatabaseType() (#17671)
eec970fb0ee is described below
commit eec970fb0eeca885878f1d6dc2d2a27f36b8bf52
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Sun May 15 18:48:49 2022 +0800
Remove DatabaseTypeEngine.getDefaultDatabaseType() (#17671)
---
.../dal/impl/fixture/TestStatementContext.java | 2 +-
.../impl/EncryptOrderByItemTokenGeneratorTest.java | 2 +-
.../impl/EncryptProjectionTokenGeneratorTest.java | 6 ++--
.../dml/ShardingInsertStatementValidatorTest.java | 4 +--
.../sharding/rule/ShardingRuleTest.java | 2 +-
.../binder/segment/table/TablesContextTest.java | 34 +++++++++++-----------
.../infra/database/type/DatabaseTypeEngine.java | 11 +------
.../database/type/DatabaseTypeEngineTest.java | 5 ----
.../mode/metadata/MetaDataContextsBuilderTest.java | 2 +-
...QLStatementContextInstanceOfTableAvailable.java | 2 +-
.../mysql/executor/ShowTablesExecutorTest.java | 2 +-
11 files changed, 29 insertions(+), 43 deletions(-)
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/impl/fixture/TestStatementContext.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/impl/fixture/TestStatementContext.java
index 39bbe708fb6..143ff917994 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/impl/fixture/TestStatementContext.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/impl/fixture/TestStatementContext.java
@@ -54,6 +54,6 @@ public final class TestStatementContext implements SQLStatementContext<SQLStatem
@Override
public DatabaseType getDatabaseType() {
- return DatabaseTypeEngine.getDefaultDatabaseType();
+ return DatabaseTypeEngine.getDatabaseType("MySQL");
}
}
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/impl/EncryptOrderByItemTokenGeneratorTest.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/impl/EncryptOrderByItemTokenGeneratorTest.java
index 3d303ad1128..7d74615d407 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/impl/EncryptOrderByItemTokenGeneratorTest.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/impl/EncryptOrderByItemTokenGeneratorTest.java
@@ -78,7 +78,7 @@ public final class EncryptOrderByItemTokenGeneratorTest {
when(result.getOrderByContext().getItems()).thenReturn(Collections.singletonList(orderByItem));
when(result.getGroupByContext().getItems()).thenReturn(Collections.emptyList());
when(result.getSubqueryContexts().values()).thenReturn(Collections.emptyList());
- when(result.getTablesContext()).thenReturn(new TablesContext(Collections.singletonList(simpleTableSegment), DatabaseTypeEngine.getDefaultDatabaseType()));
+ when(result.getTablesContext()).thenReturn(new TablesContext(Collections.singletonList(simpleTableSegment), DatabaseTypeEngine.getDatabaseType("MySQL")));
return result;
}
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/impl/EncryptProjectionTokenGeneratorTest.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/impl/EncryptProjectionTokenGeneratorTest.java
index a40b9a88e00..68757972f6c 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/impl/EncryptProjectionTokenGeneratorTest.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/impl/EncryptProjectionTokenGeneratorTest.java
@@ -87,7 +87,7 @@ public final class EncryptProjectionTokenGeneratorTest {
when(sqlStatementContext.getSqlStatement().getProjections()).thenReturn(projections);
when(sqlStatementContext.getSubqueryContexts().values()).thenReturn(Collections.emptyList());
SimpleTableSegment doctorOneTable = new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("doctor1")));
- when(sqlStatementContext.getTablesContext()).thenReturn(new TablesContext(Arrays.asList(doctorTable, doctorOneTable), DatabaseTypeEngine.getDefaultDatabaseType()));
+ when(sqlStatementContext.getTablesContext()).thenReturn(new TablesContext(Arrays.asList(doctorTable, doctorOneTable), DatabaseTypeEngine.getDatabaseType("MySQL")));
when(sqlStatementContext.getProjectionsContext().getProjections()).thenReturn(Collections.singletonList(new ColumnProjection("a", "mobile", null)));
Collection<SubstitutableColumnNameToken> actual = generator.generateSQLTokens(sqlStatementContext);
assertThat(actual.size(), is(1));
@@ -105,7 +105,7 @@ public final class EncryptProjectionTokenGeneratorTest {
when(sqlStatementContext.getSqlStatement().getProjections()).thenReturn(projections);
when(sqlStatementContext.getSubqueryContexts().values()).thenReturn(Collections.emptyList());
SimpleTableSegment sameDoctorTable = new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("doctor")));
- when(sqlStatementContext.getTablesContext()).thenReturn(new TablesContext(Arrays.asList(doctorTable, sameDoctorTable), DatabaseTypeEngine.getDefaultDatabaseType()));
+ when(sqlStatementContext.getTablesContext()).thenReturn(new TablesContext(Arrays.asList(doctorTable, sameDoctorTable), DatabaseTypeEngine.getDatabaseType("MySQL")));
when(sqlStatementContext.getProjectionsContext().getProjections()).thenReturn(Collections.singletonList(new ColumnProjection("a", "mobile", null)));
Collection<SubstitutableColumnNameToken> actual = generator.generateSQLTokens(sqlStatementContext);
assertThat(actual.size(), is(1));
@@ -122,7 +122,7 @@ public final class EncryptProjectionTokenGeneratorTest {
when(sqlStatementContext.getSubqueryContexts().values()).thenReturn(Collections.emptyList());
SimpleTableSegment doctorTable = new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("doctor")));
SimpleTableSegment doctorOneTable = new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("doctor1")));
- when(sqlStatementContext.getTablesContext()).thenReturn(new TablesContext(Arrays.asList(doctorTable, doctorOneTable), DatabaseTypeEngine.getDefaultDatabaseType()));
+ when(sqlStatementContext.getTablesContext()).thenReturn(new TablesContext(Arrays.asList(doctorTable, doctorOneTable), DatabaseTypeEngine.getDatabaseType("MySQL")));
when(sqlStatementContext.getProjectionsContext().getProjections()).thenReturn(Collections.singletonList(new ColumnProjection("doctor", "mobile", null)));
Collection<SubstitutableColumnNameToken> actual = generator.generateSQLTokens(sqlStatementContext);
assertThat(actual.size(), is(1));
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingInsertStatementValidatorTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingInsertStatementValidatorTest.java
index 0c90bb68514..0c0b8793237 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingInsertStatementValidatorTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingInsertStatementValidatorTest.java
@@ -281,13 +281,13 @@ public final class ShardingInsertStatementValidatorTest {
private TablesContext createSingleTablesContext() {
List<SimpleTableSegment> result = new LinkedList<>();
result.add(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("user"))));
- return new TablesContext(result, DatabaseTypeEngine.getDefaultDatabaseType());
+ return new TablesContext(result, DatabaseTypeEngine.getDatabaseType("MySQL"));
}
private TablesContext createMultiTablesContext() {
List<SimpleTableSegment> result = new LinkedList<>();
result.add(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("user"))));
result.add(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("order"))));
- return new TablesContext(result, DatabaseTypeEngine.getDefaultDatabaseType());
+ return new TablesContext(result, DatabaseTypeEngine.getDatabaseType("MySQL"));
}
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java
index 0b355fef537..d3e0d593e45 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java
@@ -582,7 +582,7 @@ public final class ShardingRuleTest {
Collection<SimpleTableSegment> tableSegments = Arrays.asList(
new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("LOGIC_TABLE"))),
new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("SUB_LOGIC_TABLE"))));
- TablesContext tablesContext = new TablesContext(tableSegments, Collections.emptyMap(), DatabaseTypeEngine.getDefaultDatabaseType());
+ TablesContext tablesContext = new TablesContext(tableSegments, Collections.emptyMap(), DatabaseTypeEngine.getDatabaseType("MySQL"));
when(sqlStatementContext.getTablesContext()).thenReturn(tablesContext);
when(sqlStatementContext.getDatabaseType()).thenReturn(new MySQLDatabaseType());
ShardingSphereMetaData metaData = mock(ShardingSphereMetaData.class, RETURNS_DEEP_STUBS);
diff --git a/shardingsphere-infra/shardingsphere-infra-binder/src/test/java/org/apache/shardingsphere/infra/binder/segment/table/TablesContextTest.java b/shardingsphere-infra/shardingsphere-infra-binder/src/test/java/org/apache/shardingsphere/infra/binder/segment/table/TablesContextTest.java
index 26e4e6adab3..f7620626a30 100644
--- a/shardingsphere-infra/shardingsphere-infra-binder/src/test/java/org/apache/shardingsphere/infra/binder/segment/table/TablesContextTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-binder/src/test/java/org/apache/shardingsphere/infra/binder/segment/table/TablesContextTest.java
@@ -49,7 +49,7 @@ public final class TablesContextTest {
@Test
public void assertGetTableNames() {
TablesContext tablesContext = new TablesContext(Arrays.asList(createTableSegment("table_1", "tbl_1"),
- createTableSegment("table_2", "tbl_2")), DatabaseTypeEngine.getDefaultDatabaseType());
+ createTableSegment("table_2", "tbl_2")), DatabaseTypeEngine.getDatabaseType("MySQL"));
assertThat(tablesContext.getTableNames(), is(Sets.newHashSet("table_1", "table_2")));
}
@@ -57,7 +57,7 @@ public final class TablesContextTest {
public void assertInstanceCreatedWhenNoExceptionThrown() {
SimpleTableSegment tableSegment = new SimpleTableSegment(new TableNameSegment(0, 10, new IdentifierValue("tbl")));
tableSegment.setOwner(new OwnerSegment(0, 0, new IdentifierValue("schema")));
- new TablesContext(Collections.singleton(tableSegment), DatabaseTypeEngine.getDefaultDatabaseType());
+ new TablesContext(Collections.singleton(tableSegment), DatabaseTypeEngine.getDatabaseType("MySQL"));
// TODO add assertion
}
@@ -65,7 +65,7 @@ public final class TablesContextTest {
public void assertFindTableNameWhenSingleTable() {
SimpleTableSegment tableSegment = createTableSegment("table_1", "tbl_1");
ColumnSegment columnSegment = createColumnSegment(null, "col");
- Map<String, String> actual = new TablesContext(Collections.singletonList(tableSegment), DatabaseTypeEngine.getDefaultDatabaseType())
+ Map<String, String> actual = new TablesContext(Collections.singletonList(tableSegment), DatabaseTypeEngine.getDatabaseType("MySQL"))
.findTableNamesByColumnSegment(Collections.singletonList(columnSegment), mock(ShardingSphereSchema.class));
assertFalse(actual.isEmpty());
assertThat(actual.get("col"), is("table_1"));
@@ -76,7 +76,7 @@ public final class TablesContextTest {
SimpleTableSegment tableSegment1 = createTableSegment("table_1", "tbl_1");
SimpleTableSegment tableSegment2 = createTableSegment("table_2", "tbl_2");
ColumnSegment columnSegment = createColumnSegment("table_1", "col");
- Map<String, String> actual = new TablesContext(Arrays.asList(tableSegment1, tableSegment2), DatabaseTypeEngine.getDefaultDatabaseType())
+ Map<String, String> actual = new TablesContext(Arrays.asList(tableSegment1, tableSegment2), DatabaseTypeEngine.getDatabaseType("MySQL"))
.findTableNamesByColumnSegment(Collections.singletonList(columnSegment), mock(ShardingSphereSchema.class));
assertFalse(actual.isEmpty());
assertThat(actual.get("table_1.col"), is("table_1"));
@@ -87,7 +87,7 @@ public final class TablesContextTest {
SimpleTableSegment tableSegment1 = createTableSegment("table_1", "tbl_1");
SimpleTableSegment tableSegment2 = createTableSegment("table_2", "tbl_2");
ColumnSegment columnSegment = createColumnSegment(null, "col");
- Map<String, String> actual = new TablesContext(Arrays.asList(tableSegment1, tableSegment2), DatabaseTypeEngine.getDefaultDatabaseType())
+ Map<String, String> actual = new TablesContext(Arrays.asList(tableSegment1, tableSegment2), DatabaseTypeEngine.getDatabaseType("MySQL"))
.findTableNamesByColumnSegment(Collections.singletonList(columnSegment), mock(ShardingSphereSchema.class));
assertTrue(actual.isEmpty());
}
@@ -100,7 +100,7 @@ public final class TablesContextTest {
when(schema.getAllColumnNames("table_1")).thenReturn(Collections.singletonList("col"));
ColumnSegment columnSegment = createColumnSegment(null, "col");
Map<String, String> actual = new TablesContext(Arrays.asList(tableSegment1, tableSegment2),
- DatabaseTypeEngine.getDefaultDatabaseType()).findTableNamesByColumnSegment(Collections.singletonList(columnSegment), schema);
+ DatabaseTypeEngine.getDatabaseType("MySQL")).findTableNamesByColumnSegment(Collections.singletonList(columnSegment), schema);
assertFalse(actual.isEmpty());
assertThat(actual.get("col"), is("table_1"));
}
@@ -114,7 +114,7 @@ public final class TablesContextTest {
ShardingSphereSchema schema = new ShardingSphereSchema(Stream.of(tableMetaData).collect(Collectors.toMap(TableMetaData::getName, value -> value)));
ColumnSegment columnSegment = createColumnSegment(null, "COL");
Map<String, String> actual = new TablesContext(Arrays.asList(tableSegment1, tableSegment2),
- DatabaseTypeEngine.getDefaultDatabaseType()).findTableNamesByColumnSegment(Collections.singletonList(columnSegment), schema);
+ DatabaseTypeEngine.getDatabaseType("MySQL")).findTableNamesByColumnSegment(Collections.singletonList(columnSegment), schema);
assertFalse(actual.isEmpty());
assertThat(actual.get("col"), is("TABLE_1"));
}
@@ -123,7 +123,7 @@ public final class TablesContextTest {
public void assertFindTableNameWhenColumnProjectionWhenSingleTable() {
SimpleTableSegment tableSegment = createTableSegment("table_1", "tbl_1");
ColumnProjection columnProjection = new ColumnProjection(null, "col", "cl");
- Map<String, String> actual = new TablesContext(Collections.singletonList(tableSegment), DatabaseTypeEngine.getDefaultDatabaseType())
+ Map<String, String> actual = new TablesContext(Collections.singletonList(tableSegment), DatabaseTypeEngine.getDatabaseType("MySQL"))
.findTableNamesByColumnProjection(Collections.singletonList(columnProjection), mock(ShardingSphereSchema.class));
assertFalse(actual.isEmpty());
assertThat(actual.get("col"), is("table_1"));
@@ -134,7 +134,7 @@ public final class TablesContextTest {
SimpleTableSegment tableSegment1 = createTableSegment("table_1", "tbl_1");
SimpleTableSegment tableSegment2 = createTableSegment("table_2", "tbl_2");
ColumnProjection columnProjection = new ColumnProjection("table_1", "col", "cl");
- Map<String, String> actual = new TablesContext(Arrays.asList(tableSegment1, tableSegment2), DatabaseTypeEngine.getDefaultDatabaseType())
+ Map<String, String> actual = new TablesContext(Arrays.asList(tableSegment1, tableSegment2), DatabaseTypeEngine.getDatabaseType("MySQL"))
.findTableNamesByColumnProjection(Collections.singletonList(columnProjection), mock(ShardingSphereSchema.class));
assertFalse(actual.isEmpty());
assertThat(actual.get("table_1.col"), is("table_1"));
@@ -145,7 +145,7 @@ public final class TablesContextTest {
SimpleTableSegment tableSegment1 = createTableSegment("table_1", "tbl_1");
SimpleTableSegment tableSegment2 = createTableSegment("table_2", "tbl_2");
ColumnProjection columnProjection = new ColumnProjection(null, "col", "cl");
- Map<String, String> actual = new TablesContext(Arrays.asList(tableSegment1, tableSegment2), DatabaseTypeEngine.getDefaultDatabaseType())
+ Map<String, String> actual = new TablesContext(Arrays.asList(tableSegment1, tableSegment2), DatabaseTypeEngine.getDatabaseType("MySQL"))
.findTableNamesByColumnProjection(Collections.singletonList(columnProjection), mock(ShardingSphereSchema.class));
assertTrue(actual.isEmpty());
}
@@ -157,7 +157,7 @@ public final class TablesContextTest {
ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
when(schema.getAllColumnNames("table_1")).thenReturn(Collections.singletonList("col"));
ColumnProjection columnProjection = new ColumnProjection(null, "col", "cl");
- Map<String, String> actual = new TablesContext(Arrays.asList(tableSegment1, tableSegment2), DatabaseTypeEngine.getDefaultDatabaseType())
+ Map<String, String> actual = new TablesContext(Arrays.asList(tableSegment1, tableSegment2), DatabaseTypeEngine.getDatabaseType("MySQL"))
.findTableNamesByColumnProjection(Collections.singletonList(columnProjection), schema);
assertFalse(actual.isEmpty());
assertThat(actual.get("col"), is("table_1"));
@@ -170,7 +170,7 @@ public final class TablesContextTest {
TableMetaData tableMetaData = new TableMetaData("TABLE_1", Collections.singletonList(new ColumnMetaData("COL", 0, false, false, true)), Collections.emptyList(), Collections.emptyList());
ShardingSphereSchema schema = new ShardingSphereSchema(Stream.of(tableMetaData).collect(Collectors.toMap(TableMetaData::getName, value -> value)));
ColumnProjection columnProjection = new ColumnProjection(null, "COL", "CL");
- Map<String, String> actual = new TablesContext(Arrays.asList(tableSegment1, tableSegment2), DatabaseTypeEngine.getDefaultDatabaseType())
+ Map<String, String> actual = new TablesContext(Arrays.asList(tableSegment1, tableSegment2), DatabaseTypeEngine.getDatabaseType("MySQL"))
.findTableNamesByColumnProjection(Collections.singletonList(columnProjection), schema);
assertFalse(actual.isEmpty());
assertThat(actual.get("col"), is("TABLE_1"));
@@ -197,7 +197,7 @@ public final class TablesContextTest {
tableSegment1.setOwner(new OwnerSegment(0, 0, new IdentifierValue("sharding_db_1")));
SimpleTableSegment tableSegment2 = createTableSegment("table_1", "tbl_1");
tableSegment2.setOwner(new OwnerSegment(0, 0, new IdentifierValue("sharding_db_1")));
- TablesContext tablesContext = new TablesContext(Arrays.asList(tableSegment1, tableSegment2), DatabaseTypeEngine.getDefaultDatabaseType());
+ TablesContext tablesContext = new TablesContext(Arrays.asList(tableSegment1, tableSegment2), DatabaseTypeEngine.getDatabaseType("MySQL"));
assertTrue(tablesContext.getDatabaseName().isPresent());
assertThat(tablesContext.getDatabaseName().get(), is("sharding_db_1"));
}
@@ -208,7 +208,7 @@ public final class TablesContextTest {
tableSegment1.setOwner(new OwnerSegment(0, 0, new IdentifierValue("sharding_db_1")));
SimpleTableSegment tableSegment2 = createTableSegment("table_2", "tbl_2");
tableSegment2.setOwner(new OwnerSegment(0, 0, new IdentifierValue("sharding_db_1")));
- TablesContext tablesContext = new TablesContext(Arrays.asList(tableSegment1, tableSegment2), DatabaseTypeEngine.getDefaultDatabaseType());
+ TablesContext tablesContext = new TablesContext(Arrays.asList(tableSegment1, tableSegment2), DatabaseTypeEngine.getDatabaseType("MySQL"));
assertTrue(tablesContext.getDatabaseName().isPresent());
assertThat(tablesContext.getDatabaseName().get(), is("sharding_db_1"));
}
@@ -219,7 +219,7 @@ public final class TablesContextTest {
tableSegment1.setOwner(new OwnerSegment(0, 0, new IdentifierValue("sharding_db_1")));
SimpleTableSegment tableSegment2 = createTableSegment("table_1", "tbl_1");
tableSegment2.setOwner(new OwnerSegment(0, 0, new IdentifierValue("sharding_db_2")));
- new TablesContext(Arrays.asList(tableSegment1, tableSegment2), DatabaseTypeEngine.getDefaultDatabaseType()).getDatabaseName();
+ new TablesContext(Arrays.asList(tableSegment1, tableSegment2), DatabaseTypeEngine.getDatabaseType("MySQL")).getDatabaseName();
}
@Test(expected = IllegalStateException.class)
@@ -228,7 +228,7 @@ public final class TablesContextTest {
tableSegment1.setOwner(new OwnerSegment(0, 0, new IdentifierValue("sharding_db_1")));
SimpleTableSegment tableSegment2 = createTableSegment("table_2", "tbl_2");
tableSegment2.setOwner(new OwnerSegment(0, 0, new IdentifierValue("sharding_db_2")));
- new TablesContext(Arrays.asList(tableSegment1, tableSegment2), DatabaseTypeEngine.getDefaultDatabaseType()).getDatabaseName();
+ new TablesContext(Arrays.asList(tableSegment1, tableSegment2), DatabaseTypeEngine.getDatabaseType("MySQL")).getDatabaseName();
}
@Test
@@ -237,7 +237,7 @@ public final class TablesContextTest {
tableSegment1.setOwner(new OwnerSegment(0, 0, new IdentifierValue("sharding_db_1")));
SimpleTableSegment tableSegment2 = createTableSegment("table_2", "tbl_2");
tableSegment2.setOwner(new OwnerSegment(0, 0, new IdentifierValue("sharding_db_1")));
- TablesContext tablesContext = new TablesContext(Arrays.asList(tableSegment1, tableSegment2), DatabaseTypeEngine.getDefaultDatabaseType());
+ TablesContext tablesContext = new TablesContext(Arrays.asList(tableSegment1, tableSegment2), DatabaseTypeEngine.getDatabaseType("MySQL"));
assertTrue(tablesContext.getSchemaName().isPresent());
assertThat(tablesContext.getSchemaName().get(), is("sharding_db_1"));
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/type/DatabaseTypeEngine.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/type/DatabaseTypeEngine.java
index cbd9ffe8d37..a52320de0bd 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/type/DatabaseTypeEngine.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/type/DatabaseTypeEngine.java
@@ -91,7 +91,7 @@ public final class DatabaseTypeEngine {
Preconditions.checkState(null == result || result == databaseType, "Database type inconsistent with '%s' and '%s'", result, databaseType);
result = databaseType;
}
- return null == result ? DatabaseTypeEngine.getDefaultDatabaseType() : result;
+ return null == result ? DatabaseTypeFactory.getInstance(DEFAULT_DATABASE_TYPE) : result;
}
private static DatabaseType getDatabaseType(final DataSource dataSource) {
@@ -135,13 +135,4 @@ public final class DatabaseTypeEngine {
public static String getTrunkDatabaseTypeName(final DatabaseType databaseType) {
return databaseType instanceof BranchDatabaseType ? ((BranchDatabaseType) databaseType).getTrunkDatabaseType().getType() : databaseType.getType();
}
-
- /**
- * Get default database type.
- *
- * @return default database type
- */
- public static DatabaseType getDefaultDatabaseType() {
- return DatabaseTypeFactory.getInstance(DEFAULT_DATABASE_TYPE);
- }
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/database/type/DatabaseTypeEngineTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/database/type/DatabaseTypeEngineTest.java
index c21bdf3274a..d0a87026af4 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/database/type/DatabaseTypeEngineTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/database/type/DatabaseTypeEngineTest.java
@@ -181,9 +181,4 @@ public final class DatabaseTypeEngineTest {
public void assertGetTrunkDatabaseTypeNameWithBranchDatabaseType() {
assertThat(DatabaseTypeEngine.getTrunkDatabaseTypeName(new MariaDBDatabaseType()), is("MySQL"));
}
-
- @Test
- public void assertGetDefaultDatabaseType() {
- assertThat(DatabaseTypeEngine.getDefaultDatabaseType().getType(), is("MySQL"));
- }
}
diff --git a/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/metadata/MetaDataContextsBuilderTest.java b/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/metadata/MetaDataContextsBuilderTest.java
index 88fcf8776de..a801a5aa5bd 100644
--- a/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/metadata/MetaDataContextsBuilderTest.java
+++ b/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/metadata/MetaDataContextsBuilderTest.java
@@ -56,7 +56,7 @@ public final class MetaDataContextsBuilderTest {
AuthorityRuleConfiguration authorityRuleConfig = new AuthorityRuleConfiguration(Collections.singleton(user),
new ShardingSphereAlgorithmConfiguration("ALL_PERMITTED", new Properties()));
MetaDataContextsBuilder builder = new MetaDataContextsBuilder(Collections.singleton(authorityRuleConfig), props);
- builder.addDatabase("logic_db", DatabaseTypeEngine.getDefaultDatabaseType(), DatabaseTypeEngine.getDefaultDatabaseType(),
+ builder.addDatabase("logic_db", DatabaseTypeEngine.getDatabaseType("MySQL"), DatabaseTypeEngine.getDatabaseType("MySQL"),
new DataSourceProvidedDatabaseConfiguration(Collections.emptyMap(), Collections.singletonList(new FixtureRuleConfiguration())), props);
MetaDataContexts actual = builder.build(mock(MetaDataPersistService.class));
assertRules(actual);
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/exception/fixture/TestSQLStatementContextInstanceOfTableAvailable.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/exception/fixture/TestSQLStatementContextInstanceOfTableAvailable.java
index f3fa14701a5..1a9f0d24d90 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/exception/fixture/TestSQLStatementContextInstanceOfTableAvailable.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/exception/fixture/TestSQLStatementContextInstanceOfTableAvailable.java
@@ -49,7 +49,7 @@ public final class TestSQLStatementContextInstanceOfTableAvailable implements SQ
@Override
public DatabaseType getDatabaseType() {
- return DatabaseTypeEngine.getDefaultDatabaseType();
+ return DatabaseTypeEngine.getDatabaseType("MySQL");
}
@Override
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowTablesExecutorTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowTablesExecutorTest.java
index 752200231f4..dadf27929fa 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowTablesExecutorTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowTablesExecutorTest.java
@@ -85,7 +85,7 @@ public final class ShowTablesExecutorTest {
@Test
public void assertShowTablesExecutorWithoutFilter() throws SQLException {
- ShowTablesExecutor showTablesExecutor = new ShowTablesExecutor(new MySQLShowTablesStatement(), DatabaseTypeEngine.getDefaultDatabaseType());
+ ShowTablesExecutor showTablesExecutor = new ShowTablesExecutor(new MySQLShowTablesStatement(), DatabaseTypeEngine.getDatabaseType("MySQL"));
showTablesExecutor.execute(mockConnectionSession());
assertThat(showTablesExecutor.getQueryResultMetaData().getColumnCount(), is(2));
showTablesExecutor.getMergedResult().next();