protobuf icon indicating copy to clipboard operation
protobuf copied to clipboard

Ruby oneof fields should have `has_foo?`, even for proto3 files

Open haberman opened this issue 3 years ago • 1 comments

Currently Ruby suppresses has_foo? methods for proto3: https://github.com/protocolbuffers/protobuf/blob/c578f59fc8db97e2482208e02743ab1306ccd09e/ruby/ext/google/protobuf_c/message.c#L246-L254

As of 2020-09-15, it was decided that all oneof fields should have hazzers, even for proto3.

We should update Ruby to support has_foo? for oneof fields in Ruby.

(Note: in this case foo is the name of a field in a oneof, foo is not a oneof itself).

haberman avatar Mar 01 '22 00:03 haberman

All we need to do is remove this if statement, and add a unit test to verify: https://github.com/protocolbuffers/protobuf/blob/7309e8882cb81a92cee4b0be708a61c8f4707224/ruby/ext/google/protobuf_c/message.c#L245-L253

haberman avatar Sep 01 '22 18:09 haberman