-
Notifications
You must be signed in to change notification settings - Fork 443
New issue
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
Fetching a oneof doesn't return the default value (when not set) #22
Comments
I think your comment only applies to proto3? In proto2, oneof fields are optionals, and we map proto2 optionals to Swift optionals, so the default value in that case is nil. Oh. I suppose proto2 optionals can have explicit default values? I don't think I've seen that case, but that would make sense as well. |
You can also have a message in the oneof, so returning the default there to dot into the default fields also is useful. |
Yes, good point. Are there examples of this in the |
The fields in a oneof are just fields. So fetching it should still return the default value even when the oneof was set to a different element.
This also allows proto authors to modify a proto by moving a field into a oneof in the future. From a wire format pov, nothing changes.
The text was updated successfully, but these errors were encountered: