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

Feat/proto custom type #58

Merged
merged 6 commits into from
Apr 11, 2021
Merged

Feat/proto custom type #58

merged 6 commits into from
Apr 11, 2021

Conversation

rotemtam
Copy link
Collaborator

@rotemtam rotemtam commented Apr 11, 2021

In prep for ent/ent#1350, adding some flexibilty for users to modify the type mapping between ent and pb.

@rotemtam rotemtam requested a review from a8m April 11, 2021 08:15
Comment on lines 49 to 60
func OverrideType(typ descriptorpb.FieldDescriptorProto_Type) FieldOption {
return func(p *pbfield) {
p.OverrideType = typ
}
}

// OverrideTypeName sets the pb descriptors type name, needed if the OverrideType attribute is TYPE_ENUM or TYPE_MESSAGE.
func OverrideTypeName(n string) FieldOption {
return func(p *pbfield) {
p.OverrideTypeName = n
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but remove the Override string from this function.

Also, consider adding a usage example in the godoc. I use it a lot.

Suggested change
func OverrideType(typ descriptorpb.FieldDescriptorProto_Type) FieldOption {
return func(p *pbfield) {
p.OverrideType = typ
}
}
// OverrideTypeName sets the pb descriptors type name, needed if the OverrideType attribute is TYPE_ENUM or TYPE_MESSAGE.
func OverrideTypeName(n string) FieldOption {
return func(p *pbfield) {
p.OverrideTypeName = n
}
}
func Type(typ descriptorpb.FieldDescriptorProto_Type) FieldOption {
return func(p *pbfield) {
p.Type = typ
}
}
// TypeName sets the pb descriptors type name, needed if the OverrideType attribute is TYPE_ENUM or TYPE_MESSAGE.
func TypeName(n string) FieldOption {
return func(p *pbfield) {
p.TypeName = n
}
}

@rotemtam rotemtam merged commit 8afe5dc into master Apr 11, 2021
@rotemtam rotemtam deleted the feat/proto-custom-type branch April 11, 2021 09:36
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 this pull request may close these issues.

2 participants