github.com/vedadiyan/sqlparser@v1.0.0/pkg/sqltypes/query_response.go (about)

     1  /*
     2  Copyright 2019 The Vitess Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package sqltypes
    18  
    19  import (
    20  	"github.com/vedadiyan/sqlparser/pkg/vterrors"
    21  )
    22  
    23  // QueryResponse represents a query response for ExecuteBatch.
    24  type QueryResponse struct {
    25  	QueryResult *Result
    26  	QueryError  error
    27  }
    28  
    29  // QueryResponsesEqual compares two arrays of QueryResponse.
    30  // They contain protos, so we cannot use reflect.DeepEqual.
    31  func QueryResponsesEqual(r1, r2 []QueryResponse) bool {
    32  	if len(r1) != len(r2) {
    33  		return false
    34  	}
    35  	for i, r := range r1 {
    36  		if !r.QueryResult.Equal(r2[i].QueryResult) {
    37  			return false
    38  		}
    39  		if !vterrors.Equals(r.QueryError, r2[i].QueryError) {
    40  			return false
    41  		}
    42  	}
    43  	return true
    44  }