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/13 14:51:35 UTC

[GitHub] [shardingsphere] terrymanu commented on a diff in pull request #19110: make CONNECTION_ID() support alias

terrymanu commented on code in PR #19110:
URL: https://github.com/apache/shardingsphere/pull/19110#discussion_r920176180


##########
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowConnectionIdExecutorTest.java:
##########
@@ -47,4 +72,28 @@ private ConnectionSession mockConnectionSession() {
         when(result.getConnectionId()).thenReturn(109);
         return result;
     }
+    
+    private SelectStatement mockSelectStatement() {
+
+        Collection<ProjectionSegment> projections = new LinkedList<>();
+        ProjectionsSegment segment = mock(ProjectionsSegment.class);
+        when(segment.getProjections()).thenReturn(projections);
+

Review Comment:
   Please remove useless blank line



##########
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowConnectionIdExecutorTest.java:
##########
@@ -47,4 +72,28 @@ private ConnectionSession mockConnectionSession() {
         when(result.getConnectionId()).thenReturn(109);
         return result;
     }
+    
+    private SelectStatement mockSelectStatement() {
+

Review Comment:
   Please remove useless blank line



##########
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowConnectionIdExecutorTest.java:
##########
@@ -47,4 +72,28 @@ private ConnectionSession mockConnectionSession() {
         when(result.getConnectionId()).thenReturn(109);
         return result;
     }
+    
+    private SelectStatement mockSelectStatement() {
+
+        Collection<ProjectionSegment> projections = new LinkedList<>();
+        ProjectionsSegment segment = mock(ProjectionsSegment.class);
+        when(segment.getProjections()).thenReturn(projections);
+
+        SelectStatement statement = mock(SelectStatement.class);
+        when(statement.getProjections()).thenReturn(segment);
+        return statement;
+    }
+    
+    private SelectStatement mockSelectStatementWithAlias() {
+        Collection<ProjectionSegment> projections = new LinkedList<>();
+        ExpressionProjectionSegment projectionSegment = new ExpressionProjectionSegment(0, 0, "connection_id()");
+        projectionSegment.setAlias(new AliasSegment(0, 0, new IdentifierValue("test_alias")));
+        projections.add(projectionSegment);
+        ProjectionsSegment segment = mock(ProjectionsSegment.class);
+        when(segment.getProjections()).thenReturn(projections);
+
+        SelectStatement statement = mock(SelectStatement.class);
+        when(statement.getProjections()).thenReturn(segment);
+        return statement;

Review Comment:
   return value should name as `result`



##########
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowConnectionIdExecutorTest.java:
##########
@@ -47,4 +72,28 @@ private ConnectionSession mockConnectionSession() {
         when(result.getConnectionId()).thenReturn(109);
         return result;
     }
+    
+    private SelectStatement mockSelectStatement() {
+
+        Collection<ProjectionSegment> projections = new LinkedList<>();
+        ProjectionsSegment segment = mock(ProjectionsSegment.class);
+        when(segment.getProjections()).thenReturn(projections);
+
+        SelectStatement statement = mock(SelectStatement.class);
+        when(statement.getProjections()).thenReturn(segment);
+        return statement;
+    }
+    
+    private SelectStatement mockSelectStatementWithAlias() {
+        Collection<ProjectionSegment> projections = new LinkedList<>();
+        ExpressionProjectionSegment projectionSegment = new ExpressionProjectionSegment(0, 0, "connection_id()");
+        projectionSegment.setAlias(new AliasSegment(0, 0, new IdentifierValue("test_alias")));
+        projections.add(projectionSegment);
+        ProjectionsSegment segment = mock(ProjectionsSegment.class);
+        when(segment.getProjections()).thenReturn(projections);
+

Review Comment:
   Please remove useless blank line



##########
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowConnectionIdExecutorTest.java:
##########
@@ -47,4 +72,28 @@ private ConnectionSession mockConnectionSession() {
         when(result.getConnectionId()).thenReturn(109);
         return result;
     }
+    
+    private SelectStatement mockSelectStatement() {
+
+        Collection<ProjectionSegment> projections = new LinkedList<>();
+        ProjectionsSegment segment = mock(ProjectionsSegment.class);
+        when(segment.getProjections()).thenReturn(projections);
+
+        SelectStatement statement = mock(SelectStatement.class);
+        when(statement.getProjections()).thenReturn(segment);
+        return statement;

Review Comment:
   return value should name as `result`



-- 
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