You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/06/29 17:07:33 UTC
[GitHub] [shardingsphere] Bpazy opened a new pull request, #18713: Add more unit test for SelectStatementContext
Bpazy opened a new pull request, #18713:
URL: https://github.com/apache/shardingsphere/pull/18713
Fixes #14672.
Changes proposed in this pull request:
- Add unit test for SelectStatementContext#isContainsDollarParameterMarker
- Add unit test for SelectStatementContext#isContainsPartialDistinctAggregation
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] strongduanmu merged pull request #18713: Add more unit test for SelectStatementContext
Posted by GitBox <gi...@apache.org>.
strongduanmu merged PR #18713:
URL: https://github.com/apache/shardingsphere/pull/18713
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] codecov-commenter commented on pull request #18713: Add more unit test for SelectStatementContext
Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #18713:
URL: https://github.com/apache/shardingsphere/pull/18713#issuecomment-1170684898
# [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/18713?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#18713](https://codecov.io/gh/apache/shardingsphere/pull/18713?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (5997623) into [master](https://codecov.io/gh/apache/shardingsphere/commit/2e5427b066bb51fcf38ccbe457532f8f20494440?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (2e5427b) will **decrease** coverage by `0.00%`.
> The diff coverage is `n/a`.
```diff
@@ Coverage Diff @@
## master #18713 +/- ##
============================================
- Coverage 59.38% 59.37% -0.01%
- Complexity 2259 2262 +3
============================================
Files 3728 3743 +15
Lines 54789 54901 +112
Branches 9332 9343 +11
============================================
+ Hits 32534 32599 +65
- Misses 19513 19550 +37
- Partials 2742 2752 +10
```
| [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/18713?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...er/ReadwriteSplittingRuleBeanDefinitionParser.java](https://codecov.io/gh/apache/shardingsphere/pull/18713/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtcmVhZHdyaXRlLXNwbGl0dGluZy9zaGFyZGluZ3NwaGVyZS1yZWFkd3JpdGUtc3BsaXR0aW5nLXNwcmluZy9zaGFyZGluZ3NwaGVyZS1yZWFkd3JpdGUtc3BsaXR0aW5nLXNwcmluZy1uYW1lc3BhY2Uvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3JlYWR3cml0ZXNwbGl0dGluZy9zcHJpbmcvbmFtZXNwYWNlL3BhcnNlci9SZWFkd3JpdGVTcGxpdHRpbmdSdWxlQmVhbkRlZmluaXRpb25QYXJzZXIuamF2YQ==) | `77.41% <0.00%> (-17.32%)` | :arrow_down: |
| [...ng/strategy/ReadwriteSplittingStrategyFactory.java](https://codecov.io/gh/apache/shardingsphere/pull/18713/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtcmVhZHdyaXRlLXNwbGl0dGluZy9zaGFyZGluZ3NwaGVyZS1yZWFkd3JpdGUtc3BsaXR0aW5nLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3JlYWR3cml0ZXNwbGl0dGluZy9zdHJhdGVneS9SZWFkd3JpdGVTcGxpdHRpbmdTdHJhdGVneUZhY3RvcnkuamF2YQ==) | `80.00% <0.00%> (-11.67%)` | :arrow_down: |
| [.../context/parser/OptimizerParserContextFactory.java](https://codecov.io/gh/apache/shardingsphere/pull/18713/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtZmVkZXJhdGlvbi9zaGFyZGluZ3NwaGVyZS1pbmZyYS1mZWRlcmF0aW9uLW9wdGltaXplci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvaW5mcmEvZmVkZXJhdGlvbi9vcHRpbWl6ZXIvY29udGV4dC9wYXJzZXIvT3B0aW1pemVyUGFyc2VyQ29udGV4dEZhY3RvcnkuamF2YQ==) | `90.90% <0.00%> (-9.10%)` | :arrow_down: |
| [...RuleAlgorithmProviderConfigurationYamlSwapper.java](https://codecov.io/gh/apache/shardingsphere/pull/18713/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtcmVhZHdyaXRlLXNwbGl0dGluZy9zaGFyZGluZ3NwaGVyZS1yZWFkd3JpdGUtc3BsaXR0aW5nLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3JlYWR3cml0ZXNwbGl0dGluZy95YW1sL3N3YXBwZXIvUmVhZHdyaXRlU3BsaXR0aW5nUnVsZUFsZ29yaXRobVByb3ZpZGVyQ29uZmlndXJhdGlvbllhbWxTd2FwcGVyLmphdmE=) | `78.57% <0.00%> (-8.39%)` | :arrow_down: |
| [...actReadwriteSplittingRuleConfigurationChecker.java](https://codecov.io/gh/apache/shardingsphere/pull/18713/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtcmVhZHdyaXRlLXNwbGl0dGluZy9zaGFyZGluZ3NwaGVyZS1yZWFkd3JpdGUtc3BsaXR0aW5nLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3JlYWR3cml0ZXNwbGl0dGluZy9jaGVja2VyL0Fic3RyYWN0UmVhZHdyaXRlU3BsaXR0aW5nUnVsZUNvbmZpZ3VyYXRpb25DaGVja2VyLmphdmE=) | `80.00% <0.00%> (-7.50%)` | :arrow_down: |
| [...eadwriteSplittingRuleConfigurationYamlSwapper.java](https://codecov.io/gh/apache/shardingsphere/pull/18713/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtcmVhZHdyaXRlLXNwbGl0dGluZy9zaGFyZGluZ3NwaGVyZS1yZWFkd3JpdGUtc3BsaXR0aW5nLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3JlYWR3cml0ZXNwbGl0dGluZy95YW1sL3N3YXBwZXIvUmVhZHdyaXRlU3BsaXR0aW5nUnVsZUNvbmZpZ3VyYXRpb25ZYW1sU3dhcHBlci5qYXZh) | `76.66% <0.00%> (-7.34%)` | :arrow_down: |
| [...rter/ReadwriteSplittingRuleStatementConverter.java](https://codecov.io/gh/apache/shardingsphere/pull/18713/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtcmVhZHdyaXRlLXNwbGl0dGluZy9zaGFyZGluZ3NwaGVyZS1yZWFkd3JpdGUtc3BsaXR0aW5nLWRpc3RzcWwvc2hhcmRpbmdzcGhlcmUtcmVhZHdyaXRlLXNwbGl0dGluZy1kaXN0c3FsLWhhbmRsZXIvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3JlYWR3cml0ZXNwbGl0dGluZy9kaXN0c3FsL2hhbmRsZXIvY29udmVydGVyL1JlYWR3cml0ZVNwbGl0dGluZ1J1bGVTdGF0ZW1lbnRDb252ZXJ0ZXIuamF2YQ==) | `88.23% <0.00%> (-1.77%)` | :arrow_down: |
| [...tsql/rql/rule/RulesUsedResourceQueryResultSet.java](https://codecov.io/gh/apache/shardingsphere/pull/18713/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtcHJveHkvc2hhcmRpbmdzcGhlcmUtcHJveHktYmFja2VuZC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvYmFja2VuZC90ZXh0L2Rpc3RzcWwvcnFsL3J1bGUvUnVsZXNVc2VkUmVzb3VyY2VRdWVyeVJlc3VsdFNldC5qYXZh) | `89.83% <0.00%> (-1.55%)` | :arrow_down: |
| [...ingletable/datanode/SingleTableDataNodeLoader.java](https://codecov.io/gh/apache/shardingsphere/pull/18713/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUta2VybmVsL3NoYXJkaW5nc3BoZXJlLXNpbmdsZS10YWJsZS9zaGFyZGluZ3NwaGVyZS1zaW5nbGUtdGFibGUtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc2luZ2xldGFibGUvZGF0YW5vZGUvU2luZ2xlVGFibGVEYXRhTm9kZUxvYWRlci5qYXZh) | `92.85% <0.00%> (-1.43%)` | :arrow_down: |
| [...dwriteSplittingRuleConfigurationImportChecker.java](https://codecov.io/gh/apache/shardingsphere/pull/18713/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtcHJveHkvc2hhcmRpbmdzcGhlcmUtcHJveHktYmFja2VuZC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvYmFja2VuZC90ZXh0L2Rpc3RzcWwvcmFsL2NvbW1vbi9jaGVja2VyL1JlYWR3cml0ZVNwbGl0dGluZ1J1bGVDb25maWd1cmF0aW9uSW1wb3J0Q2hlY2tlci5qYXZh) | `3.33% <0.00%> (-0.12%)` | :arrow_down: |
| ... and [40 more](https://codecov.io/gh/apache/shardingsphere/pull/18713/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/shardingsphere/pull/18713?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/18713?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [2e5427b...5997623](https://codecov.io/gh/apache/shardingsphere/pull/18713?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] Bpazy commented on a diff in pull request #18713: Add more unit test for SelectStatementContext
Posted by GitBox <gi...@apache.org>.
Bpazy commented on code in PR #18713:
URL: https://github.com/apache/shardingsphere/pull/18713#discussion_r910626917
##########
shardingsphere-infra/shardingsphere-infra-binder/src/test/java/org/apache/shardingsphere/infra/binder/statement/impl/SelectStatementContextTest.java:
##########
@@ -484,7 +489,85 @@ private void assertContainsSubqueryWhereEmpty(final SelectStatement selectStatem
assertTrue(new SelectStatementContext(
Collections.singletonMap(DefaultDatabase.LOGIC_NAME, mock(ShardingSphereDatabase.class)), Collections.emptyList(), selectStatement, DefaultDatabase.LOGIC_NAME).isContainsSubquery());
}
+
+ @Test
+ public void assertContainsDollarParameterMarkerForMySQL() {
+ assertContainsDollarParameterMarker(new MySQLSelectStatement());
+ }
+
+ @Test
+ public void assertContainsDollarParameterMarkerForOracle() {
+ assertContainsDollarParameterMarker(new OracleSelectStatement());
+ }
+ @Test
+ public void assertContainsDollarParameterMarkerForPostgreSQL() {
+ assertContainsDollarParameterMarker(new PostgreSQLSelectStatement());
+ }
+
+ @Test
+ public void assertContainsDollarParameterMarkerForSQL92() {
+ assertContainsDollarParameterMarker(new SQL92SelectStatement());
+ }
+
+ @Test
+ public void assertContainsDollarParameterMarkerForSQLServer() {
+ assertContainsDollarParameterMarker(new SQLServerSelectStatement());
+ }
+
+ private void assertContainsDollarParameterMarker(final SelectStatement selectStatement) {
+ ProjectionsSegment projectionsSegment = mock(ProjectionsSegment.class);
+ when(projectionsSegment.getProjections()).thenReturn(Lists.newArrayList(new ParameterMarkerExpressionSegment(0, 0, 0, ParameterMarkerType.DOLLAR)));
+ selectStatement.setProjections(projectionsSegment);
+ SelectStatementContext selectStatementContext = new SelectStatementContext(Collections.singletonMap(DefaultDatabase.LOGIC_NAME, mock(ShardingSphereDatabase.class)), Collections.emptyList(),
+ selectStatement, DefaultDatabase.LOGIC_NAME);
+ 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(
+ Collections.singletonMap(DefaultDatabase.LOGIC_NAME, mock(ShardingSphereDatabase.class)), Collections.emptyList(), selectStatement, DefaultDatabase.LOGIC_NAME);
+ assertTrue(selectStatementContext.isContainsDollarParameterMarker());
+ }
+
+ @Test
+ public void assertContainsPartialDistinctAggregationForMySQL() {
+ assertContainsPartialDistinctAggregation(new MySQLSelectStatement());
+ }
+
+ @Test
+ public void assertContainsPartialDistinctAggregationForOracle() {
+ assertContainsPartialDistinctAggregation(new OracleSelectStatement());
+ }
+
+ @Test
+ public void assertContainsPartialDistinctAggregationForPostgreSQL() {
+ assertContainsPartialDistinctAggregation(new PostgreSQLSelectStatement());
+ }
+
+ @Test
+ public void assertContainsPartialDistinctAggregationForSQL92() {
+ assertContainsPartialDistinctAggregation(new SQL92SelectStatement());
+ }
+
+ @Test
+ public void assertContainsPartialDistinctAggregationForSQLServer() {
+ assertContainsPartialDistinctAggregation(new SQLServerSelectStatement());
+ }
+
+ private void assertContainsPartialDistinctAggregation(final SelectStatement selectStatement) {
+ ProjectionsSegment projectionsSegment = new ProjectionsSegment(0, 0);
+ projectionsSegment.getProjections().add(new AggregationProjectionSegment(0, 0, AggregationType.COUNT, "(*)"));
+ projectionsSegment.getProjections().add(new AggregationDistinctProjectionSegment(0, 10, AggregationType.COUNT, "(1)", "distinctExpression"));
+ selectStatement.setProjections(projectionsSegment);
+
Review Comment:
Done
##########
shardingsphere-infra/shardingsphere-infra-binder/src/test/java/org/apache/shardingsphere/infra/binder/statement/impl/SelectStatementContextTest.java:
##########
@@ -484,7 +489,85 @@ private void assertContainsSubqueryWhereEmpty(final SelectStatement selectStatem
assertTrue(new SelectStatementContext(
Collections.singletonMap(DefaultDatabase.LOGIC_NAME, mock(ShardingSphereDatabase.class)), Collections.emptyList(), selectStatement, DefaultDatabase.LOGIC_NAME).isContainsSubquery());
}
+
+ @Test
+ public void assertContainsDollarParameterMarkerForMySQL() {
+ assertContainsDollarParameterMarker(new MySQLSelectStatement());
+ }
+
+ @Test
+ public void assertContainsDollarParameterMarkerForOracle() {
+ assertContainsDollarParameterMarker(new OracleSelectStatement());
+ }
+ @Test
+ public void assertContainsDollarParameterMarkerForPostgreSQL() {
+ assertContainsDollarParameterMarker(new PostgreSQLSelectStatement());
+ }
+
+ @Test
+ public void assertContainsDollarParameterMarkerForSQL92() {
+ assertContainsDollarParameterMarker(new SQL92SelectStatement());
+ }
+
+ @Test
+ public void assertContainsDollarParameterMarkerForSQLServer() {
+ assertContainsDollarParameterMarker(new SQLServerSelectStatement());
+ }
+
+ private void assertContainsDollarParameterMarker(final SelectStatement selectStatement) {
+ ProjectionsSegment projectionsSegment = mock(ProjectionsSegment.class);
+ when(projectionsSegment.getProjections()).thenReturn(Lists.newArrayList(new ParameterMarkerExpressionSegment(0, 0, 0, ParameterMarkerType.DOLLAR)));
Review Comment:
Done
##########
shardingsphere-infra/shardingsphere-infra-binder/src/test/java/org/apache/shardingsphere/infra/binder/statement/impl/SelectStatementContextTest.java:
##########
@@ -484,7 +489,85 @@ private void assertContainsSubqueryWhereEmpty(final SelectStatement selectStatem
assertTrue(new SelectStatementContext(
Collections.singletonMap(DefaultDatabase.LOGIC_NAME, mock(ShardingSphereDatabase.class)), Collections.emptyList(), selectStatement, DefaultDatabase.LOGIC_NAME).isContainsSubquery());
}
+
+ @Test
+ public void assertContainsDollarParameterMarkerForMySQL() {
+ assertContainsDollarParameterMarker(new MySQLSelectStatement());
+ }
+
+ @Test
+ public void assertContainsDollarParameterMarkerForOracle() {
+ assertContainsDollarParameterMarker(new OracleSelectStatement());
+ }
+ @Test
+ public void assertContainsDollarParameterMarkerForPostgreSQL() {
+ assertContainsDollarParameterMarker(new PostgreSQLSelectStatement());
+ }
+
+ @Test
+ public void assertContainsDollarParameterMarkerForSQL92() {
+ assertContainsDollarParameterMarker(new SQL92SelectStatement());
+ }
+
+ @Test
+ public void assertContainsDollarParameterMarkerForSQLServer() {
+ assertContainsDollarParameterMarker(new SQLServerSelectStatement());
+ }
+
+ private void assertContainsDollarParameterMarker(final SelectStatement selectStatement) {
+ ProjectionsSegment projectionsSegment = mock(ProjectionsSegment.class);
+ when(projectionsSegment.getProjections()).thenReturn(Lists.newArrayList(new ParameterMarkerExpressionSegment(0, 0, 0, ParameterMarkerType.DOLLAR)));
+ selectStatement.setProjections(projectionsSegment);
+ SelectStatementContext selectStatementContext = new SelectStatementContext(Collections.singletonMap(DefaultDatabase.LOGIC_NAME, mock(ShardingSphereDatabase.class)), Collections.emptyList(),
+ selectStatement, DefaultDatabase.LOGIC_NAME);
+ assertTrue(selectStatementContext.isContainsDollarParameterMarker());
+
Review Comment:
Done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] strongduanmu commented on a diff in pull request #18713: Add more unit test for SelectStatementContext
Posted by GitBox <gi...@apache.org>.
strongduanmu commented on code in PR #18713:
URL: https://github.com/apache/shardingsphere/pull/18713#discussion_r910605969
##########
shardingsphere-infra/shardingsphere-infra-binder/src/test/java/org/apache/shardingsphere/infra/binder/statement/impl/SelectStatementContextTest.java:
##########
@@ -484,7 +489,85 @@ private void assertContainsSubqueryWhereEmpty(final SelectStatement selectStatem
assertTrue(new SelectStatementContext(
Collections.singletonMap(DefaultDatabase.LOGIC_NAME, mock(ShardingSphereDatabase.class)), Collections.emptyList(), selectStatement, DefaultDatabase.LOGIC_NAME).isContainsSubquery());
}
+
+ @Test
+ public void assertContainsDollarParameterMarkerForMySQL() {
+ assertContainsDollarParameterMarker(new MySQLSelectStatement());
+ }
+
+ @Test
+ public void assertContainsDollarParameterMarkerForOracle() {
+ assertContainsDollarParameterMarker(new OracleSelectStatement());
+ }
+ @Test
+ public void assertContainsDollarParameterMarkerForPostgreSQL() {
+ assertContainsDollarParameterMarker(new PostgreSQLSelectStatement());
+ }
+
+ @Test
+ public void assertContainsDollarParameterMarkerForSQL92() {
+ assertContainsDollarParameterMarker(new SQL92SelectStatement());
+ }
+
+ @Test
+ public void assertContainsDollarParameterMarkerForSQLServer() {
+ assertContainsDollarParameterMarker(new SQLServerSelectStatement());
+ }
+
+ private void assertContainsDollarParameterMarker(final SelectStatement selectStatement) {
+ ProjectionsSegment projectionsSegment = mock(ProjectionsSegment.class);
+ when(projectionsSegment.getProjections()).thenReturn(Lists.newArrayList(new ParameterMarkerExpressionSegment(0, 0, 0, ParameterMarkerType.DOLLAR)));
+ selectStatement.setProjections(projectionsSegment);
+ SelectStatementContext selectStatementContext = new SelectStatementContext(Collections.singletonMap(DefaultDatabase.LOGIC_NAME, mock(ShardingSphereDatabase.class)), Collections.emptyList(),
+ selectStatement, DefaultDatabase.LOGIC_NAME);
+ 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(
+ Collections.singletonMap(DefaultDatabase.LOGIC_NAME, mock(ShardingSphereDatabase.class)), Collections.emptyList(), selectStatement, DefaultDatabase.LOGIC_NAME);
+ assertTrue(selectStatementContext.isContainsDollarParameterMarker());
+ }
+
+ @Test
+ public void assertContainsPartialDistinctAggregationForMySQL() {
+ assertContainsPartialDistinctAggregation(new MySQLSelectStatement());
+ }
+
+ @Test
+ public void assertContainsPartialDistinctAggregationForOracle() {
+ assertContainsPartialDistinctAggregation(new OracleSelectStatement());
+ }
+
+ @Test
+ public void assertContainsPartialDistinctAggregationForPostgreSQL() {
+ assertContainsPartialDistinctAggregation(new PostgreSQLSelectStatement());
+ }
+
+ @Test
+ public void assertContainsPartialDistinctAggregationForSQL92() {
+ assertContainsPartialDistinctAggregation(new SQL92SelectStatement());
+ }
+
+ @Test
+ public void assertContainsPartialDistinctAggregationForSQLServer() {
+ assertContainsPartialDistinctAggregation(new SQLServerSelectStatement());
+ }
+
+ private void assertContainsPartialDistinctAggregation(final SelectStatement selectStatement) {
+ ProjectionsSegment projectionsSegment = new ProjectionsSegment(0, 0);
+ projectionsSegment.getProjections().add(new AggregationProjectionSegment(0, 0, AggregationType.COUNT, "(*)"));
+ projectionsSegment.getProjections().add(new AggregationDistinctProjectionSegment(0, 10, AggregationType.COUNT, "(1)", "distinctExpression"));
+ selectStatement.setProjections(projectionsSegment);
+
Review Comment:
Please remove this useless blank line.
##########
shardingsphere-infra/shardingsphere-infra-binder/src/test/java/org/apache/shardingsphere/infra/binder/statement/impl/SelectStatementContextTest.java:
##########
@@ -484,7 +489,85 @@ private void assertContainsSubqueryWhereEmpty(final SelectStatement selectStatem
assertTrue(new SelectStatementContext(
Collections.singletonMap(DefaultDatabase.LOGIC_NAME, mock(ShardingSphereDatabase.class)), Collections.emptyList(), selectStatement, DefaultDatabase.LOGIC_NAME).isContainsSubquery());
}
+
+ @Test
+ public void assertContainsDollarParameterMarkerForMySQL() {
+ assertContainsDollarParameterMarker(new MySQLSelectStatement());
+ }
+
+ @Test
+ public void assertContainsDollarParameterMarkerForOracle() {
+ assertContainsDollarParameterMarker(new OracleSelectStatement());
+ }
+ @Test
+ public void assertContainsDollarParameterMarkerForPostgreSQL() {
+ assertContainsDollarParameterMarker(new PostgreSQLSelectStatement());
+ }
+
+ @Test
+ public void assertContainsDollarParameterMarkerForSQL92() {
+ assertContainsDollarParameterMarker(new SQL92SelectStatement());
+ }
+
+ @Test
+ public void assertContainsDollarParameterMarkerForSQLServer() {
+ assertContainsDollarParameterMarker(new SQLServerSelectStatement());
+ }
+
+ private void assertContainsDollarParameterMarker(final SelectStatement selectStatement) {
+ ProjectionsSegment projectionsSegment = mock(ProjectionsSegment.class);
+ when(projectionsSegment.getProjections()).thenReturn(Lists.newArrayList(new ParameterMarkerExpressionSegment(0, 0, 0, ParameterMarkerType.DOLLAR)));
Review Comment:
Please do not use guava Lists.
##########
shardingsphere-infra/shardingsphere-infra-binder/src/test/java/org/apache/shardingsphere/infra/binder/statement/impl/SelectStatementContextTest.java:
##########
@@ -484,7 +489,85 @@ private void assertContainsSubqueryWhereEmpty(final SelectStatement selectStatem
assertTrue(new SelectStatementContext(
Collections.singletonMap(DefaultDatabase.LOGIC_NAME, mock(ShardingSphereDatabase.class)), Collections.emptyList(), selectStatement, DefaultDatabase.LOGIC_NAME).isContainsSubquery());
}
+
+ @Test
+ public void assertContainsDollarParameterMarkerForMySQL() {
+ assertContainsDollarParameterMarker(new MySQLSelectStatement());
+ }
+
+ @Test
+ public void assertContainsDollarParameterMarkerForOracle() {
+ assertContainsDollarParameterMarker(new OracleSelectStatement());
+ }
+ @Test
+ public void assertContainsDollarParameterMarkerForPostgreSQL() {
+ assertContainsDollarParameterMarker(new PostgreSQLSelectStatement());
+ }
+
+ @Test
+ public void assertContainsDollarParameterMarkerForSQL92() {
+ assertContainsDollarParameterMarker(new SQL92SelectStatement());
+ }
+
+ @Test
+ public void assertContainsDollarParameterMarkerForSQLServer() {
+ assertContainsDollarParameterMarker(new SQLServerSelectStatement());
+ }
+
+ private void assertContainsDollarParameterMarker(final SelectStatement selectStatement) {
+ ProjectionsSegment projectionsSegment = mock(ProjectionsSegment.class);
+ when(projectionsSegment.getProjections()).thenReturn(Lists.newArrayList(new ParameterMarkerExpressionSegment(0, 0, 0, ParameterMarkerType.DOLLAR)));
+ selectStatement.setProjections(projectionsSegment);
+ SelectStatementContext selectStatementContext = new SelectStatementContext(Collections.singletonMap(DefaultDatabase.LOGIC_NAME, mock(ShardingSphereDatabase.class)), Collections.emptyList(),
+ selectStatement, DefaultDatabase.LOGIC_NAME);
+ assertTrue(selectStatementContext.isContainsDollarParameterMarker());
+
Review Comment:
Please remove this useless blank line.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org