mirror of
https://github.com/protocolbuffers/protobuf-go.git
synced 2025-01-01 11:58:21 +00:00
encoding/textpb: fix marshaling repeated group field name
In https://golang.org/cl/157821, I attempted to fix handling of group field names but forgot about repeated group fields as I forgot to properly update the marshaling tests as well for it. Unmarshal logic for both repeated and non-repeated was already fixed in that CL. Change-Id: Icb4a00d8b169709ca12dfee272b2bd73e7585e6e Reviewed-on: https://go-review.googlesource.com/c/157857 Reviewed-by: Damien Neil <dneil@google.com>
This commit is contained in:
parent
66c365cf72
commit
de7313b557
@ -127,6 +127,11 @@ func (o MarshalOptions) marshalMessage(m pref.Message) (text.Value, error) {
|
||||
func (o MarshalOptions) appendField(msgFields [][2]text.Value, tname text.Value, pval pref.Value, fd pref.FieldDescriptor) ([][2]text.Value, error) {
|
||||
var nerr errors.NonFatal
|
||||
|
||||
// Use type name for group field name.
|
||||
if fd.Kind() == pref.GroupKind {
|
||||
tname = text.ValueOf(fd.MessageType().Name())
|
||||
}
|
||||
|
||||
if fd.Cardinality() == pref.Repeated {
|
||||
// Map or repeated fields.
|
||||
var items []text.Value
|
||||
@ -153,10 +158,6 @@ func (o MarshalOptions) appendField(msgFields [][2]text.Value, tname text.Value,
|
||||
if !nerr.Merge(err) {
|
||||
return msgFields, err
|
||||
}
|
||||
// Use type name for group field name.
|
||||
if fd.Kind() == pref.GroupKind {
|
||||
tname = text.ValueOf(fd.MessageType().Name())
|
||||
}
|
||||
msgFields = append(msgFields, [2]text.Value{tname, tval})
|
||||
}
|
||||
|
||||
|
@ -537,11 +537,11 @@ rpt_nested: {}
|
||||
{},
|
||||
},
|
||||
},
|
||||
want: `rptgroup: {
|
||||
want: `RptGroup: {
|
||||
rpt_bool: true
|
||||
rpt_bool: false
|
||||
}
|
||||
rptgroup: {}
|
||||
RptGroup: {}
|
||||
`,
|
||||
}, {
|
||||
desc: "map fields empty",
|
||||
|
Loading…
Reference in New Issue
Block a user