Merging maps do not merge map values
- Dominant language
- Dart
- Stars
- 572
- Forks
- 196
- Avg merge
- 1h 59m
- Merged PRs (30d)
- 2
Description
When merging an encoded message, for a repeated field, we extend the existing list with the new elements in the new message: https://github.com/google/protobuf.dart/blob/9da84aef9d8126ac3da665f3c163e3cb4af31b6d/protobuf/lib/src/protobuf/proto3_json.dart#L382-L388
However, when merging a map field, if both old and new messages have the same key, we overwrite the old value with the new value, instead of merging old and new values of the key: https://github.com/google/protobuf.dart/blob/9da84aef9d8126ac3da665f3c163e3cb4af31b6d/protobuf/lib/src/protobuf/proto3_json.dart#L369-L371
So if I have `a: [1]` in the old message and `a: [2]` in the new, after merging with `_mergeFromProto3Json`, the final message field will be `a: [2]` instead of `a: [1, 2]`.
As far as I understand "merging" is not part of the proto3 spec, but from a user's point of view this is inconsistent.
Note: same bug exists in all encodings (custom JSON, proto3 JSON, binary).
Contributor guide
Assessment
This issue has not been assessed yet.