Open nsweeting opened 9 months ago
What happens if you use a struct instead of an empty map?
%Foo{value: {:baz, %Foo.Baz{}}}
The library should probably not accept maps in place of structs but it is possible that it sees the empty map as a default value which are not encoded and since it's not encoded no oneof field was selected.
There's two issues here:
Foo.encode(%Foo{value: {:bar, %{value: "bar"}}})
because {:bar, _}
should only work with a Foo.Bar
struct.
%Foo{value: {:baz, %Foo.Baz{}}}
should not empty the field because :baz
is not the default value.We're investigating this!
cc @savhappy
Also, 1. above might be related to https://github.com/elixir-protobuf/protobuf/issues/365.
Hi there,
We're seeing (what feels like) inconsistent behaviour when encoding oneof values.
Given the following protobuf:
Which compiles to the following elixir code:
When encoding/decoding a message that contains a map for
Foo.Bar
(not the struct) and it contains a value - things work as expected:But when encoding/decoding an empty map - it simply gets dropped entirely - even though we are passing the proper tuple for the oneof:
Since we've noted which oneof it is - it seems like it should be included.
Thanks