You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by tu...@apache.org on 2022/06/30 08:27:03 UTC
[shardingsphere] branch master updated: Remove route to the specified database with Hint (#18620) (#18727)
This is an automated email from the ASF dual-hosted git repository.
tuichenchuxin 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 eaafe79870b Remove route to the specified database with Hint (#18620) (#18727)
eaafe79870b is described below
commit eaafe79870b4a58939014d7d411c57c6cd06d8dc
Author: Cheng Zhang <fl...@outlook.com>
AuthorDate: Thu Jun 30 16:26:56 2022 +0800
Remove route to the specified database with Hint (#18620) (#18727)
* Remove route to the specified database with Hint (#18620)
* Remove route to the specified database with Hint (#18620)
---
.../infra/hint/SQLHintExtractor.java | 11 ---------
.../infra/hint/SQLHintPropertiesKey.java | 5 ----
.../infra/hint/SQLHintExtractorTest.java | 27 ----------------------
3 files changed, 43 deletions(-)
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/hint/SQLHintExtractor.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/hint/SQLHintExtractor.java
index 06cd7176465..c023ef97cf8 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/hint/SQLHintExtractor.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/hint/SQLHintExtractor.java
@@ -22,7 +22,6 @@ import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.CommentSe
import org.apache.shardingsphere.sql.parser.sql.common.statement.AbstractSQLStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
-import java.util.Optional;
import java.util.Properties;
/**
@@ -48,16 +47,6 @@ public final class SQLHintExtractor {
return new SQLHintProperties(props);
}
- /**
- * Find hint data source name.
- *
- * @return data source name
- */
- public Optional<String> findHintDataSourceName() {
- String result = sqlHintProperties.getValue(SQLHintPropertiesKey.DATASOURCE_NAME_KEY);
- return result.isEmpty() ? Optional.empty() : Optional.of(result);
- }
-
/**
* Judge whether is hint routed to write data source or not.
*
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/hint/SQLHintPropertiesKey.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/hint/SQLHintPropertiesKey.java
index 348a131004c..4a94830be97 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/hint/SQLHintPropertiesKey.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/hint/SQLHintPropertiesKey.java
@@ -28,11 +28,6 @@ import org.apache.shardingsphere.infra.properties.TypedPropertyKey;
@Getter
public enum SQLHintPropertiesKey implements TypedPropertyKey {
- /**
- * Hint data source name.
- */
- DATASOURCE_NAME_KEY("dataSourceName", "", String.class),
-
/**
* Whether hint route write data source or not.
*/
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/hint/SQLHintExtractorTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/hint/SQLHintExtractorTest.java
index b1ec3a3d78e..5e27b72ff7b 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/hint/SQLHintExtractorTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/hint/SQLHintExtractorTest.java
@@ -22,26 +22,13 @@ import org.apache.shardingsphere.sql.parser.sql.common.statement.AbstractSQLStat
import org.junit.Test;
import java.util.Collections;
-import java.util.Optional;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public final class SQLHintExtractorTest {
- @Test
- public void assertFindHintDataSourceNameExist() {
- AbstractSQLStatement statement = mock(AbstractSQLStatement.class);
- when(statement.getCommentSegments()).thenReturn(Collections.singletonList(new CommentSegment("/* ShardingSphere hint: dataSourceName=ds_1 */", 0, 0)));
- Optional<String> dataSourceName = new SQLHintExtractor(statement).findHintDataSourceName();
- assertTrue(dataSourceName.isPresent());
- assertThat(dataSourceName.get(), is("ds_1"));
- }
-
@Test
public void assertSQLHintWriteRouteOnly() {
AbstractSQLStatement statement = mock(AbstractSQLStatement.class);
@@ -49,18 +36,4 @@ public final class SQLHintExtractorTest {
assertTrue(new SQLHintExtractor(statement).isHintWriteRouteOnly());
}
- @Test
- public void assertFindHintDataSourceNameNotExist() {
- AbstractSQLStatement statement = mock(AbstractSQLStatement.class);
- when(statement.getCommentSegments()).thenReturn(Collections.singletonList(new CommentSegment("/* no hint */", 0, 0)));
- Optional<String> dataSourceName = new SQLHintExtractor(statement).findHintDataSourceName();
- assertFalse(dataSourceName.isPresent());
- }
-
- @Test
- public void assertFindHintDataSourceNameNotExistWithoutComment() {
- AbstractSQLStatement statement = mock(AbstractSQLStatement.class);
- Optional<String> dataSourceName = new SQLHintExtractor(statement).findHintDataSourceName();
- assertFalse(dataSourceName.isPresent());
- }
}