Skip to content

Commit

Permalink
Merge pull request #21 from shurcooL/support-non-nullable-nested
Browse files Browse the repository at this point in the history
Add support for non-nullable nested messages.
  • Loading branch information
yugui committed Jun 19, 2015
2 parents 2d3c800 + 5797a5c commit 8ac6df9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions runtime/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ func populateQueryParameter(msg proto.Message, fieldPath []string, values []stri
}
m = f.Elem()
continue
case reflect.Struct:
m = f
continue
default:
return fmt.Errorf("unexpected type %s in %T", f.Type(), msg)
}
Expand Down
5 changes: 5 additions & 0 deletions runtime/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func TestPopulateParameters(t *testing.T) {
"nested.nested.nested.string_value": {"s"},
"nested.nested.string_value": {"t"},
"nested.string_value": {"u"},
"nested_non_null.string_value": {"v"},
},
filter: internal.NewDoubleArray(nil),
want: &proto3Message{
Expand All @@ -84,6 +85,9 @@ func TestPopulateParameters(t *testing.T) {
},
StringValue: proto.String("u"),
},
NestedNonNull: proto2Message{
StringValue: proto.String("v"),
},
},
},
{
Expand Down Expand Up @@ -195,6 +199,7 @@ func TestPopulateParametersWithFilters(t *testing.T) {

type proto3Message struct {
Nested *proto2Message `protobuf:"bytes,1,opt,name=nested" json:"nested,omitempty"`
NestedNonNull proto2Message `protobuf:"bytes,11,opt,name=nested_non_null" json:"nested_non_null,omitempty"`
FloatValue float32 `protobuf:"fixed32,2,opt,name=float_value" json:"float_value,omitempty"`
DoubleValue float64 `protobuf:"fixed64,3,opt,name=double_value" json:"double_value,omitempty"`
Int64Value int64 `protobuf:"varint,4,opt,name=int64_value" json:"int64_value,omitempty"`
Expand Down

0 comments on commit 8ac6df9

Please sign in to comment.