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

Does ent grpc now support UUID primary keys? #1402

Closed
godcong opened this issue Mar 29, 2021 · 2 comments · Fixed by ent/contrib#55
Closed

Does ent grpc now support UUID primary keys? #1402

godcong opened this issue Mar 29, 2021 · 2 comments · Fixed by ent/contrib#55

Comments

@godcong
Copy link
Contributor

godcong commented Mar 29, 2021

When i run generate entproto -path ./ent/schema
The command line returned me an error message:

entproto: failed generating protos: entproto: failed parsing some schemas: unsupported field type "TypeUUID"

my schema:

// Fields of the InformationV1.
func (InformationV1) Fields() []ent.Field {
	return []ent.Field{
		field.UUID("id", uuid.UUID{}).
			Default(uuid.New).Annotations(
			entproto.Field(1),
		),
		field.String("root"),
	        ...
	}
}

func (InformationV1) Annotations() []schema.Annotation {
	return []schema.Annotation{
		entproto.Message(),
	}
}
@rotemtam
Copy link
Collaborator

Hey @godcong , thanks for your query.
As you can see in the README for entproto, currently TypeUUID isn't supported.

I want to add support for it and wanted to ask, how would you expect this field translation to work?

  • What would be the proto field type? repeated bytes, string, a new custom message type with two int64 fields for most sig/least sig bytes as discussed in this thread?

@godcong
Copy link
Contributor Author

godcong commented Mar 30, 2021

RFC 4122 seems to have the best performance.
It allows UUID to be encoded in binary (as opposed to text)
The String() method can completely solve the string display problem
So I think bytes should be a better choice

rotemtam added a commit to ent/contrib that referenced this issue Apr 4, 2021
entproto/cmd/protoc-gen-entgrpc: adding infra for validation on the gRPC layer, UUID field support (normal field, edge id, id)

Fixes ent/ent#1402
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.

2 participants