Skip to content
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

[feature request] proto3 optional #75

Closed
elvizlai opened this issue May 8, 2020 · 5 comments · Fixed by #85
Closed

[feature request] proto3 optional #75

elvizlai opened this issue May 8, 2020 · 5 comments · Fixed by #85

Comments

@elvizlai
Copy link

elvizlai commented May 8, 2020

any plan to support proto3 optional?

ref:
proto3 field presence
proto3 optional impl

Need modify persister.go's Persist method adding or reading --experimental_allow_proto3_optional flag from command-line?:

resp.SupportedFeatures = proto.Uint64(uint64(plugin_go.CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL))
glerchundi added a commit to glerchundi/protoc-gen-star that referenced this issue Nov 28, 2020
This changes adds the optional support to the code generation response.
It unconditionally adds this flag as the support should come in the
generator using this library. This is done to avoid generators fail when
someone is making a call to `protoc` with the experimental flag.

Closes lyft#75
glerchundi added a commit to glerchundi/protoc-gen-star that referenced this issue Feb 21, 2021
This changes adds the optional support to the code generation response.
It unconditionally adds this flag as the support should come in the
generator using this library.

Closes lyft#75
@longxia0324
Copy link

please merge commits

glerchundi added a commit to glerchundi/protoc-gen-star that referenced this issue Apr 29, 2021
This changes adds the optional support to the code generation response.
It unconditionally adds this flag as the support should come in the
generator using this library.

Closes lyft#75
@snqk
Copy link
Contributor

snqk commented May 6, 2021

I think #85 potentially missed out on re-defining how an optional field is detected according to the new definitions:

The following explanation is no longer entirely accurate in proto.go:

	// Proto3 syntax only allows for optional fields, but defaults to the zero
	// value of that particular type. Most of the field types in the generated go
	// structs are value types.
	// See: https://developers.google.com/protocol-buffers/docs/proto3
	Proto3 Syntax = "proto3"

Hence shouldn't the following snippet in field_type.go

func (s *scalarT) IsOptional() bool {
	return !s.fld.Syntax().SupportsRequiredPrefix() || s.ProtoLabel() == Optional
}

be updated to just:

func (s *scalarT) IsOptional() bool {
	return s.ProtoLabel() == Optional
}

\cc @dkunitsk @glerchundi @akonradi

@glerchundi
Copy link
Contributor

glerchundi commented May 6, 2021

Good catch @sarthak40, I think so. I also think that the check is a little bit convoluted...checking if optional is supported by testing if required is not supported before? 🤔

Anyway, yeah I think that it should be removed but we need to careful notifying as people relying on this boolean test would now suddenly see processes launching that weren't triggering before.

WDYT @dkunitsk @akonradi?

@snqk
Copy link
Contributor

snqk commented May 6, 2021

Anyway, yeah I think that it should be removed but we need to careful notifying as people relying on this boolean test would now suddenly see processes launching that weren't triggering before.

I guess its a good thing that we advertise this as an unstable api spec in the readme then 😄

@snqk
Copy link
Contributor

snqk commented May 7, 2021

@dkunitsk @akonradi if you're okay with the proposal above, I can prepare a new PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants