-
Notifications
You must be signed in to change notification settings - Fork 15
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
Removes the optionality in Coproducts #119
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @rafaparadela, are we transforming from TOption
to TRequired
for all the cases? If that's so, why don't we remove TOption
from the Protobuf tree? If it is posible, we can avoid this transformation, can't
we?
Not really. We are just removing the optionality in coproducts, but we might want to remain the options in the rest of the cases. |
Thanks for the PR. Always related to https://github.com/julien-lafont/protoless and its motivation - "protobuf is not your domain model" - and always feel the need to control the mapping to the more rich domain model. (relates to #91) |
I totally agree with your statement "always feel the need to control the mapping to the more rich domain model", but I believe that the original purpose of this library was providing the mechanisms to transform protocols into a canonical IDL without losing information and tending to preserve the nature of the original schema. It's great to have this debate, and thanks for bringing it up. I think that Skeuomorph should keep being accurate when interpreting the schemas (whatever IDL). If there are not required fields in Proto 3, that is to say, all fields are "optional", then the transformation from Proto 3 to Scala must be sensitive to this circumstance, by using the scala On the other hand, there are strategies that users can follow to express the nullability of a field, to differentiate when a field is missing to preserve backward compatibility or when explicitly a field must be null to express lack to value. Proto2 message Foo {
optional int32 bar = 1;
} Here, behind the field Proto3 message Foo {
int32 bar = 1;
} Here, But we can express this nullability semantic by: message Foo {
oneof bar {
bool bar_null = 1;
int32 bar_value = 2;
}
} In my last PR, we are omitting the redundant optionality within coproducts because just adds complexity, nothing else. Actually, we used to have some optimization in these cases, where Skeuomorph was able to detect when the user is attempting to express this nullability, and the coproduct was transformed into In summary, I'm inclined to keep interpreting the Protobuf fields as properties within the scala-option. |
Thank you. Agreed with this thought process as well.
Quite interested to learn about how to express those as user of At this point am using Made some comments about marshalling in the latter part of #91 (comment). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This PR fixes #113
It converts the
TOption
values withinTCoproduct
intoTRequired
.