Commit 1f050ea
fix(datastore): PKG:datastore TYPE:datastoreClient FUNC:RunAggregationQuery (#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>1 parent 93d6a1a commit 1f050ea
2 files changed
Lines changed: 37 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
76 | 87 | | |
77 | 88 | | |
78 | 89 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
796 | 796 | | |
797 | 797 | | |
798 | 798 | | |
799 | | - | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
800 | 825 | | |
801 | 826 | | |
802 | 827 | | |
| |||
0 commit comments