We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
An empty message used in a oneof is not marshaled the same as proto.Marshal().
Steps to reproduce:
syntax = "proto3"; package repro; message Repro { message Empty {} oneof str_or_empty { string str = 1; Empty empty = 2; } }
func TestEmptyOneOf(t *testing.T) { m := &pb.Repro{StrOrEmpty: &pb.Repro_Empty_{}} protobuf, err := proto.Marshal(m) if err != nil { t.Fatal(err) } vtprotobuf, err := m.MarshalVT() if err != nil { t.Fatal(err) } fmt.Printf("protobuf: %#v\n", protobuf) fmt.Printf("vtprotobuf: %#v\n", vtprotobuf) require.True(t, bytes.Equal(protobuf, vtprotobuf)) }
Output:
protobuf: []byte{0x12, 0x0} vtprotobuf: []byte{} --- FAIL: TestEmptyOneOf (0.00s) main_test.go:129: Error Trace: main_test.go:129 Error: Should be true Test: TestEmptyOneOf FAIL exit status 1
The text was updated successfully, but these errors were encountered:
Fix marshalling of empty oneOf messages
c69309d
Fixes planetscale#61
c067ecd
d579c53
Successfully merging a pull request may close this issue.
An empty message used in a oneof is not marshaled the same as proto.Marshal().
Steps to reproduce:
Output:
The text was updated successfully, but these errors were encountered: