Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(datastore): PKG:datastore TYPE:datastoreClient FUNC:RunAggregatio…
…nQuery (#7803) Bug: #7800 Calling `func (c *datastore.Client) RunAggregationQuery` panics at line `789` when calling `c.client.RunAggregationQuery`. `c.client` is defined `type pb.DatastoreClient interface` and it should have `RunAggregationQuery(ctx context.Context, in *RunAggregationQueryRequest, opts ...grpc.CallOption) (*RunAggregationQueryResponse, error)` but, `c.client` is implemented as a `type datastoreClient struct` and is missing `func (dc *datastoreClient) RunAggregationQuery(ctx context.Context, in *pb.RunAggregationQueryRequest, opts ...grpc.CallOption) (res *pb.RunAggregationQueryResponse, err error)`. This bug was covered by the fact that `datastoreClient` complies to `type pb.DatastoreClient interface` because the interface is part of it struct declaration: ```go // From /datastore/client.go, line 36 ... type datastoreClient struct { // Embed so we still implement the DatastoreClient interface, // if the interface adds more methods. pb.DatastoreClient ... ``` Also(Bonus): `func (c *datastore.Client) RunAggregationQuery(ctx context.Context, aq *AggregationQuery) (AggregationResult, error)` returning an `type AggregationResult map[string]interface{}` but the content of type `interface{}` are `*datastore.Value` from `google.golang.org/genproto/googleapis/datastore/v1/entity.pb.go`. Not very useful. Solution: Add `func (dc *datastoreClient) RunAggregationQuery(ctx context.Context, in *pb.RunAggregationQueryRequest, opts ...grpc.CallOption) (res *pb.RunAggregationQueryResponse, err error)` Add a `switch` statement to use concrete values from the `GetXXXValue() YYY` of `google.golang.org/genproto/googleapis/datastore/v1 :: datastore.Value` Co-authored-by: Mario Gravel <info@MarioGravel.dev> Co-authored-by: meredithslota <meredithslota@google.com>
- Loading branch information