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/07/11 09:58:29 UTC
[GitHub] [shardingsphere] huangdx0726 opened a new pull request, #19027: Fix18970
huangdx0726 opened a new pull request, #19027:
URL: https://github.com/apache/shardingsphere/pull/19027
Fixes #18970 .
Changes proposed in this pull request:
-
add more tests
-
--
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] huangdx0726 commented on a diff in pull request #19027: Fix18970
Posted by GitBox <gi...@apache.org>.
huangdx0726 commented on code in PR #19027:
URL: https://github.com/apache/shardingsphere/pull/19027#discussion_r918474275
##########
shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/AssistQueryAndPlainInsertColumnsTokenGeneratorTest.java:
##########
@@ -67,7 +68,30 @@ public void assertGenerateSQLTokens() {
tokenGenerator.setEncryptRule(mockEncryptRule());
Collection<InsertColumnsToken> actual = tokenGenerator.generateSQLTokens(mockInsertStatementContext());
assertThat(actual.size(), is(1));
- // TODO add more assertions for actual value
+
+ Iterator<InsertColumnsToken> iterator = actual.iterator();
+ InsertColumnsToken insertColumnsToken = iterator.next();
+ assertThat(insertColumnsToken.getStartIndex(), is(1));
+
+ InsertStatementContext insertStatementContext = mockInsertStatementContext();
+ ColumnSegment columnSegment = mock(ColumnSegment.class, RETURNS_DEEP_STUBS);
+ when(columnSegment.getIdentifier().getValue()).thenReturn("foo_col");
+ when(columnSegment.getStopIndex()).thenReturn(1);
+ when(insertStatementContext.getSqlStatement().getColumns()).thenReturn(Collections.singleton(columnSegment));
+ Collection<InsertColumnsToken> insertColumnsTokens = tokenGenerator.generateSQLTokens(insertStatementContext);
+ InsertColumnsToken compareInsertColumnsToken = insertColumnsTokens.iterator().next();
+ assertTrue(insertColumnsToken.compareTo(compareInsertColumnsToken) < 0);
+
+ insertStatementContext = mock(InsertStatementContext.class, RETURNS_DEEP_STUBS);
+ when(insertStatementContext.getSqlStatement().getTable().getTableName().getIdentifier().getValue()).thenReturn("foo_tbl");
+ actual = tokenGenerator.generateSQLTokens(insertStatementContext);
+ assertThat(actual.size(), is(0));
+
+ columnSegment = mock(ColumnSegment.class, RETURNS_DEEP_STUBS);
+ when(columnSegment.getIdentifier().getValue()).thenReturn("bar_col");
+ when(insertStatementContext.getSqlStatement().getColumns()).thenReturn(Collections.singleton(columnSegment));
+ actual = tokenGenerator.generateSQLTokens(insertStatementContext);
+ assertThat(actual.size(), is(0));
Review Comment:
I will fix it
--
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] terrymanu commented on pull request #19027: Fix18970
Posted by GitBox <gi...@apache.org>.
terrymanu commented on PR #19027:
URL: https://github.com/apache/shardingsphere/pull/19027#issuecomment-1189778788
@huangdx0726 Hi, any update?
--
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] terrymanu commented on pull request #19027: Fix18970
Posted by GitBox <gi...@apache.org>.
terrymanu commented on PR #19027:
URL: https://github.com/apache/shardingsphere/pull/19027#issuecomment-1190400637
There are still 3 generateSQLTokens.generateSQLTokens() in same test case, please spilt them into 3 test cases
--
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] terrymanu commented on a diff in pull request #19027: Fix18970
Posted by GitBox <gi...@apache.org>.
terrymanu commented on code in PR #19027:
URL: https://github.com/apache/shardingsphere/pull/19027#discussion_r918117022
##########
shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/AssistQueryAndPlainInsertColumnsTokenGeneratorTest.java:
##########
@@ -67,7 +68,30 @@ public void assertGenerateSQLTokens() {
tokenGenerator.setEncryptRule(mockEncryptRule());
Collection<InsertColumnsToken> actual = tokenGenerator.generateSQLTokens(mockInsertStatementContext());
assertThat(actual.size(), is(1));
- // TODO add more assertions for actual value
+
+ Iterator<InsertColumnsToken> iterator = actual.iterator();
+ InsertColumnsToken insertColumnsToken = iterator.next();
+ assertThat(insertColumnsToken.getStartIndex(), is(1));
+
+ InsertStatementContext insertStatementContext = mockInsertStatementContext();
+ ColumnSegment columnSegment = mock(ColumnSegment.class, RETURNS_DEEP_STUBS);
+ when(columnSegment.getIdentifier().getValue()).thenReturn("foo_col");
+ when(columnSegment.getStopIndex()).thenReturn(1);
+ when(insertStatementContext.getSqlStatement().getColumns()).thenReturn(Collections.singleton(columnSegment));
+ Collection<InsertColumnsToken> insertColumnsTokens = tokenGenerator.generateSQLTokens(insertStatementContext);
+ InsertColumnsToken compareInsertColumnsToken = insertColumnsTokens.iterator().next();
+ assertTrue(insertColumnsToken.compareTo(compareInsertColumnsToken) < 0);
+
+ insertStatementContext = mock(InsertStatementContext.class, RETURNS_DEEP_STUBS);
+ when(insertStatementContext.getSqlStatement().getTable().getTableName().getIdentifier().getValue()).thenReturn("foo_tbl");
+ actual = tokenGenerator.generateSQLTokens(insertStatementContext);
+ assertThat(actual.size(), is(0));
+
Review Comment:
Please remove unnecessary blank line
##########
shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/AssistQueryAndPlainInsertColumnsTokenGeneratorTest.java:
##########
@@ -67,7 +68,30 @@ public void assertGenerateSQLTokens() {
tokenGenerator.setEncryptRule(mockEncryptRule());
Collection<InsertColumnsToken> actual = tokenGenerator.generateSQLTokens(mockInsertStatementContext());
assertThat(actual.size(), is(1));
- // TODO add more assertions for actual value
+
+ Iterator<InsertColumnsToken> iterator = actual.iterator();
+ InsertColumnsToken insertColumnsToken = iterator.next();
+ assertThat(insertColumnsToken.getStartIndex(), is(1));
+
+ InsertStatementContext insertStatementContext = mockInsertStatementContext();
+ ColumnSegment columnSegment = mock(ColumnSegment.class, RETURNS_DEEP_STUBS);
+ when(columnSegment.getIdentifier().getValue()).thenReturn("foo_col");
+ when(columnSegment.getStopIndex()).thenReturn(1);
+ when(insertStatementContext.getSqlStatement().getColumns()).thenReturn(Collections.singleton(columnSegment));
+ Collection<InsertColumnsToken> insertColumnsTokens = tokenGenerator.generateSQLTokens(insertStatementContext);
+ InsertColumnsToken compareInsertColumnsToken = insertColumnsTokens.iterator().next();
+ assertTrue(insertColumnsToken.compareTo(compareInsertColumnsToken) < 0);
+
Review Comment:
Please remove unnecessary blank line
##########
shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/AssistQueryAndPlainInsertColumnsTokenGeneratorTest.java:
##########
@@ -67,7 +68,30 @@ public void assertGenerateSQLTokens() {
tokenGenerator.setEncryptRule(mockEncryptRule());
Collection<InsertColumnsToken> actual = tokenGenerator.generateSQLTokens(mockInsertStatementContext());
assertThat(actual.size(), is(1));
- // TODO add more assertions for actual value
+
Review Comment:
Please remove unnecessary blank line
##########
shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/AssistQueryAndPlainInsertColumnsTokenGeneratorTest.java:
##########
@@ -67,7 +68,30 @@ public void assertGenerateSQLTokens() {
tokenGenerator.setEncryptRule(mockEncryptRule());
Collection<InsertColumnsToken> actual = tokenGenerator.generateSQLTokens(mockInsertStatementContext());
assertThat(actual.size(), is(1));
- // TODO add more assertions for actual value
+
+ Iterator<InsertColumnsToken> iterator = actual.iterator();
+ InsertColumnsToken insertColumnsToken = iterator.next();
+ assertThat(insertColumnsToken.getStartIndex(), is(1));
+
Review Comment:
Please remove unnecessary blank line
##########
shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/AssistQueryAndPlainInsertColumnsTokenGeneratorTest.java:
##########
@@ -67,7 +68,30 @@ public void assertGenerateSQLTokens() {
tokenGenerator.setEncryptRule(mockEncryptRule());
Collection<InsertColumnsToken> actual = tokenGenerator.generateSQLTokens(mockInsertStatementContext());
assertThat(actual.size(), is(1));
- // TODO add more assertions for actual value
+
+ Iterator<InsertColumnsToken> iterator = actual.iterator();
+ InsertColumnsToken insertColumnsToken = iterator.next();
+ assertThat(insertColumnsToken.getStartIndex(), is(1));
+
+ InsertStatementContext insertStatementContext = mockInsertStatementContext();
+ ColumnSegment columnSegment = mock(ColumnSegment.class, RETURNS_DEEP_STUBS);
+ when(columnSegment.getIdentifier().getValue()).thenReturn("foo_col");
+ when(columnSegment.getStopIndex()).thenReturn(1);
+ when(insertStatementContext.getSqlStatement().getColumns()).thenReturn(Collections.singleton(columnSegment));
+ Collection<InsertColumnsToken> insertColumnsTokens = tokenGenerator.generateSQLTokens(insertStatementContext);
Review Comment:
Why call generateSQLTokens twice in one assertion? How about split to 2 different asserion?
##########
shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/AssistQueryAndPlainInsertColumnsTokenGeneratorTest.java:
##########
@@ -67,7 +68,30 @@ public void assertGenerateSQLTokens() {
tokenGenerator.setEncryptRule(mockEncryptRule());
Collection<InsertColumnsToken> actual = tokenGenerator.generateSQLTokens(mockInsertStatementContext());
assertThat(actual.size(), is(1));
- // TODO add more assertions for actual value
+
+ Iterator<InsertColumnsToken> iterator = actual.iterator();
+ InsertColumnsToken insertColumnsToken = iterator.next();
+ assertThat(insertColumnsToken.getStartIndex(), is(1));
+
+ InsertStatementContext insertStatementContext = mockInsertStatementContext();
+ ColumnSegment columnSegment = mock(ColumnSegment.class, RETURNS_DEEP_STUBS);
+ when(columnSegment.getIdentifier().getValue()).thenReturn("foo_col");
+ when(columnSegment.getStopIndex()).thenReturn(1);
+ when(insertStatementContext.getSqlStatement().getColumns()).thenReturn(Collections.singleton(columnSegment));
+ Collection<InsertColumnsToken> insertColumnsTokens = tokenGenerator.generateSQLTokens(insertStatementContext);
+ InsertColumnsToken compareInsertColumnsToken = insertColumnsTokens.iterator().next();
+ assertTrue(insertColumnsToken.compareTo(compareInsertColumnsToken) < 0);
+
+ insertStatementContext = mock(InsertStatementContext.class, RETURNS_DEEP_STUBS);
+ when(insertStatementContext.getSqlStatement().getTable().getTableName().getIdentifier().getValue()).thenReturn("foo_tbl");
+ actual = tokenGenerator.generateSQLTokens(insertStatementContext);
+ assertThat(actual.size(), is(0));
+
+ columnSegment = mock(ColumnSegment.class, RETURNS_DEEP_STUBS);
+ when(columnSegment.getIdentifier().getValue()).thenReturn("bar_col");
+ when(insertStatementContext.getSqlStatement().getColumns()).thenReturn(Collections.singleton(columnSegment));
+ actual = tokenGenerator.generateSQLTokens(insertStatementContext);
+ assertThat(actual.size(), is(0));
Review Comment:
how about instead of actual.isEmpty? Unary assertion is better than binary assertion.
--
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] huangdx0726 commented on pull request #19027: Fix18970
Posted by GitBox <gi...@apache.org>.
huangdx0726 commented on PR #19027:
URL: https://github.com/apache/shardingsphere/pull/19027#issuecomment-1189844780
fixed by comment
---Original---
From: "Liang ***@***.***>
Date: Wed, Jul 20, 2022 11:34 AM
To: ***@***.***>;
Cc: "Da Xiang ***@***.******@***.***>;
Subject: Re: [apache/shardingsphere] Fix18970 (PR #19027)
@huangdx0726 Hi, any update?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
--
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] terrymanu merged pull request #19027: Fix18970
Posted by GitBox <gi...@apache.org>.
terrymanu merged PR #19027:
URL: https://github.com/apache/shardingsphere/pull/19027
--
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 #19027: Fix18970
Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #19027:
URL: https://github.com/apache/shardingsphere/pull/19027#issuecomment-1180243009
# [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/19027?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 [#19027](https://codecov.io/gh/apache/shardingsphere/pull/19027?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (dfd26f8) into [master](https://codecov.io/gh/apache/shardingsphere/commit/2cf1efa575c8a24007d41db98f79ee614928ab41?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (2cf1efa) will **increase** coverage by `0.00%`.
> The diff coverage is `n/a`.
> :exclamation: Current head dfd26f8 differs from pull request most recent head f04ef19. Consider uploading reports for the commit f04ef19 to get more accurate results
```diff
@@ Coverage Diff @@
## master #19027 +/- ##
=========================================
Coverage 59.43% 59.44%
Complexity 2319 2319
=========================================
Files 3803 3803
Lines 54669 54669
Branches 9239 9239
=========================================
+ Hits 32494 32498 +4
+ Misses 19445 19442 -3
+ Partials 2730 2729 -1
```
| [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/19027?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...ssistQueryAndPlainInsertColumnsTokenGenerator.java](https://codecov.io/gh/apache/shardingsphere/pull/19027/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-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtZW5jcnlwdC9zaGFyZGluZ3NwaGVyZS1lbmNyeXB0LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2VuY3J5cHQvcmV3cml0ZS90b2tlbi9nZW5lcmF0b3IvQXNzaXN0UXVlcnlBbmRQbGFpbkluc2VydENvbHVtbnNUb2tlbkdlbmVyYXRvci5qYXZh) | `93.75% <0.00%> (+6.25%)` | :arrow_up: |
| [...d/text/distsql/ral/common/hint/HintSourceType.java](https://codecov.io/gh/apache/shardingsphere/pull/19027/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-c2hhcmRpbmdzcGhlcmUtcHJveHkvc2hhcmRpbmdzcGhlcmUtcHJveHktYmFja2VuZC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvYmFja2VuZC90ZXh0L2Rpc3RzcWwvcmFsL2NvbW1vbi9oaW50L0hpbnRTb3VyY2VUeXBlLmphdmE=) | `42.85% <0.00%> (+42.85%)` | :arrow_up: |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/shardingsphere/pull/19027?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/19027?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 [2bc51ec...f04ef19](https://codecov.io/gh/apache/shardingsphere/pull/19027?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