makeRows in gRPC hander now handles a bool result

This PR adds bool support to the makeRows function
in the gRPC handler.
This commit is contained in:
Travis 2019-11-12 16:13:52 -06:00
parent 1fea1ea375
commit 7fd5248d98
2 changed files with 22 additions and 0 deletions

View file

@ -535,6 +535,13 @@ func makeRows(resp pilosa.QueryResponse) chan *pb.RowResponse {
Columns: []*pb.ColumnResponse{
&pb.ColumnResponse{ColumnVal: &pb.ColumnResponse_Uint64Val{Uint64Val: uint64(r)}},
}}
case bool:
ci := []*pb.ColumnInfo{{Name: "changed", Datatype: "bool"}}
results <- &pb.RowResponse{
Headers: ci,
Columns: []*pb.ColumnResponse{
&pb.ColumnResponse{ColumnVal: &pb.ColumnResponse_BoolVal{BoolVal: r}},
}}
default:
log.Printf("unhandled %T\n", r)
breakLoop = true

View file

@ -204,6 +204,16 @@ func TestGRPC(t *testing.T) {
{uint64(123)},
},
},
// bool
{
true,
[]expHeader{
{"changed", "bool"},
},
[][]expColumn{
{true},
},
},
}
for ti, test := range tests {
@ -242,6 +252,11 @@ func TestGRPC(t *testing.T) {
if val != v {
t.Fatalf("test %d expected column val: %v, but got: %v", ti, v, val)
}
case bool:
val := column.GetBoolVal()
if val != v {
t.Fatalf("test %d expected column val: %v, but got: %v", ti, v, val)
}
default:
t.Fatalf("test %d has unhandled data type: %T", ti, v)
}