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

bc: entproto: convert field.Int into int64 proto fields #254

Merged
merged 2 commits into from
Mar 8, 2022

Conversation

maorlipchuk
Copy link
Contributor

@maorlipchuk maorlipchuk commented Mar 7, 2022

Following the discussion in ent/ent#2377:

  • Originally, field.Int (which is the default type for ID fields) in Ent were mapped to int32in Protobuf, even though in Ent they are int in Go structs (which is 64-bit on 64-bit systems) and bigint in MySQL and PostgreSQL.
  • This means that numbers larger than math.Int32 could not be sent over the wire even though Ent and the database support them.
  • This PR changes this mapping to int64.

This is a semi-breaking change. It may require servers to change some code (tests for example) to use the new field types. Old clients can keep working against the newly generated servers due to the way Protobuf encodes int32 and int64 scalars. See discussion and example on the issue.

@maorlipchuk maorlipchuk changed the title WIP: convert id field's type to int64 (#2377) WIP: convert default id field's type from int32 to int64 Mar 7, 2022
To avoid the following exception (see [1]), added int64 as an alternative for supported fields for list method.

[1] entproto: failed generating protos: entproto:
            failed parsing ent graph: entproto: list method does not support schema "Billing" id type "int64"
@maorlipchuk maorlipchuk changed the title WIP: convert default id field's type from int32 to int64 convert default id field's type from int32 to int64 Mar 8, 2022
@maorlipchuk maorlipchuk changed the title convert default id field's type from int32 to int64 WIP: convert default id field's type from int32 to int64 Mar 8, 2022
@maorlipchuk maorlipchuk changed the title WIP: convert default id field's type from int32 to int64 convert default id field's type from int32 to int64 Mar 8, 2022
@maorlipchuk maorlipchuk changed the title convert default id field's type from int32 to int64 WIP: convert default id field's type from int32 to int64 Mar 8, 2022
@rotemtam rotemtam self-requested a review March 8, 2022 16:42
@rotemtam rotemtam changed the title WIP: convert default id field's type from int32 to int64 bc: entproto: convert field.Int into int64 proto fields Mar 8, 2022
Copy link
Collaborator

@rotemtam rotemtam left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for your contribution @maorlipchuk!

@rotemtam rotemtam merged commit 45a28d7 into ent:master Mar 8, 2022
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