-
Notifications
You must be signed in to change notification settings - Fork 15.6k
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
For Ruby oneof fields, generate hazzers for members #11655
For Ruby oneof fields, generate hazzers for members #11655
Conversation
Thanks for your contribution, @shaldengeki. Can you update this PR to include the changes to the JRuby implementation as well? |
if (fieldDescriptor != null | ||
&& (!proto3 | ||
|| fieldDescriptor.getContainingOneof() == null | ||
|| fieldDescriptor.getContainingOneof().isSynthetic()) | ||
&& fieldDescriptor.hasPresence()) { | ||
if (fieldDescriptor != null && fieldDescriptor.hasPresence()) { |
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.
@JasonLunn Can you take a look and let me know if I'm on the right track here? I think I've replicated the same logic, but:
- I'm not totally sure if this is the right place to be modifying,
- I could use a sanity-check on the logic here.
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.
Looks about right to me on its surface. Rerunning tests now to confirm.
Hmm. Looks like the kokoro JRuby builds failed. I don't appear to have access to the test logs, either. Let me know if there's something I should fix here -- I looked at |
I think the issue is that the JRuby change you made is only in the context of the implementation of |
Ooh. Looks like we have one remaining failing build. I poked more at running the kokoro builds locally, but this one's a MacOS build and I unfortunately don't have a device I can test on. @JasonLunn Thanks for your help so far; when you have some time, take a look & let me know what's breaking. |
LGTM, @haberman - WDYT? |
LGTM, thanks for your contribution. This has been on our TODO list for a while. |
When generating Ruby clients for proto3 messages that have a oneof, we generate a hazzer for members of the oneof, not just a hazzer for the oneof itself. In other words, for a proto like this: ``` syntax = "proto3"; message Foo { oneof bar { string baz = 1; } } ``` The generated `Foo` will now have a method called `has_baz?`, in addition to the (pre-existing) method `has_bar?`. I updated the unit tests, and verified that all the tests under `//ruby/...` pass. Fixes #9561. Closes #11655 COPYBARA_INTEGRATE_REVIEW=#11655 from shaldengeki:test-ruby-oneof-hazzer a15e474 FUTURE_COPYBARA_INTEGRATE_REVIEW=#11655 from shaldengeki:test-ruby-oneof-hazzer a15e474 PiperOrigin-RevId: 506032769
When generating Ruby clients for proto3 messages that have a oneof, we generate a hazzer for members of the oneof, not just a hazzer for the oneof itself. In other words, for a proto like this: ``` syntax = "proto3"; message Foo { oneof bar { string baz = 1; } } ``` The generated `Foo` will now have a method called `has_baz?`, in addition to the (pre-existing) method `has_bar?`. I updated the unit tests, and verified that all the tests under `//ruby/...` pass. Fixes #9561. Closes #11655 COPYBARA_INTEGRATE_REVIEW=#11655 from shaldengeki:test-ruby-oneof-hazzer a15e474 FUTURE_COPYBARA_INTEGRATE_REVIEW=#11655 from shaldengeki:test-ruby-oneof-hazzer a15e474 PiperOrigin-RevId: 506032769
When generating Ruby clients for proto3 messages that have a oneof, we generate a hazzer for members of the oneof, not just a hazzer for the oneof itself. In other words, for a proto like this: ``` syntax = "proto3"; message Foo { oneof bar { string baz = 1; } } ``` The generated `Foo` will now have a method called `has_baz?`, in addition to the (pre-existing) method `has_bar?`. I updated the unit tests, and verified that all the tests under `//ruby/...` pass. Fixes #9561. Closes #11655 COPYBARA_INTEGRATE_REVIEW=#11655 from shaldengeki:test-ruby-oneof-hazzer a15e474 FUTURE_COPYBARA_INTEGRATE_REVIEW=#11655 from shaldengeki:test-ruby-oneof-hazzer a15e474 PiperOrigin-RevId: 506032769
woot - thank y'all for the help here! 🎉 |
When generating Ruby clients for proto3 messages that have a oneof, we generate a hazzer for members of the oneof, not just a hazzer for the oneof itself.
In other words, for a proto like this:
The generated
Foo
will now have a method calledhas_baz?
, in addition to the (pre-existing) methodhas_bar?
.I updated the unit tests, and verified that all the tests under
//ruby/...
pass.Fixes #9561.