Skip to content

Commit

Permalink
bc: entproto: convert field.Int into int64 proto fields (#254)
Browse files Browse the repository at this point in the history
  • Loading branch information
maorlipchuk authored Mar 8, 2022
1 parent 7dbb7a6 commit 45a28d7
Show file tree
Hide file tree
Showing 13 changed files with 97 additions and 97 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ func TestAttachmentService_MultiEdge(t *testing.T) {
}
att, err := svc.Create(ctx, &CreateAttachmentRequest{Attachment: &Attachment{
User: &User{
Id: int32(users[0].ID),
Id: int64(users[0].ID),
},
Recipients: []*User{
{Id: int32(users[1].ID)},
{Id: int32(users[2].ID)},
{Id: int32(users[3].ID)},
{Id: int32(users[4].ID)},
{Id: int64(users[1].ID)},
{Id: int64(users[2].ID)},
{Id: int64(users[3].ID)},
{Id: int64(users[4].ID)},
},
}})
all := client.Attachment.Query().WithRecipients(func(query *ent.UserQuery) {
Expand Down
108 changes: 54 additions & 54 deletions entproto/internal/todo/ent/proto/entpb/entpb.pb.go

Large diffs are not rendered by default.

34 changes: 17 additions & 17 deletions entproto/internal/todo/ent/proto/entpb/entpb.proto
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ message ListAttachmentResponse {
}

message Group {
int32 id = 1;
int64 id = 1;

string name = 2;

repeated User users = 3;
}

message MultiWordSchema {
int32 id = 1;
int64 id = 1;

Unit unit = 2;

Expand All @@ -92,7 +92,7 @@ message CreateMultiWordSchemaRequest {
}

message GetMultiWordSchemaRequest {
int32 id = 1;
int64 id = 1;

View view = 2;

Expand All @@ -110,7 +110,7 @@ message UpdateMultiWordSchemaRequest {
}

message DeleteMultiWordSchemaRequest {
int32 id = 1;
int64 id = 1;
}

message ListMultiWordSchemaRequest {
Expand All @@ -136,7 +136,7 @@ message ListMultiWordSchemaResponse {
}

message NilExample {
int32 id = 1;
int64 id = 1;

google.protobuf.StringValue str_nil = 2;

Expand All @@ -148,7 +148,7 @@ message CreateNilExampleRequest {
}

message GetNilExampleRequest {
int32 id = 1;
int64 id = 1;

View view = 2;

Expand All @@ -166,7 +166,7 @@ message UpdateNilExampleRequest {
}

message DeleteNilExampleRequest {
int32 id = 1;
int64 id = 1;
}

message ListNilExampleRequest {
Expand All @@ -192,7 +192,7 @@ message ListNilExampleResponse {
}

message Pet {
int32 id = 1;
int64 id = 1;

User owner = 2;
}
Expand All @@ -202,7 +202,7 @@ message CreatePetRequest {
}

message GetPetRequest {
int32 id = 1;
int64 id = 1;

View view = 2;

Expand All @@ -220,7 +220,7 @@ message UpdatePetRequest {
}

message DeletePetRequest {
int32 id = 1;
int64 id = 1;
}

message ListPetRequest {
Expand All @@ -246,7 +246,7 @@ message ListPetResponse {
}

message Todo {
int32 id = 1;
int64 id = 1;

string task = 2;

Expand All @@ -264,7 +264,7 @@ message Todo {
}

message User {
int32 id = 1;
int64 id = 1;

string user_name = 2;

Expand All @@ -276,23 +276,23 @@ message User {

Status status = 6;

int32 external_id = 8;
int64 external_id = 8;

bytes crm_id = 9;

bool banned = 10;

uint64 custom_pb = 12;

google.protobuf.Int32Value opt_num = 13;
google.protobuf.Int64Value opt_num = 13;

google.protobuf.StringValue opt_str = 14;

google.protobuf.BoolValue opt_bool = 15;

google.protobuf.StringValue big_int = 17;

google.protobuf.Int32Value b_user_1 = 18;
google.protobuf.Int64Value b_user_1 = 18;

float height_in_cm = 19;

Expand Down Expand Up @@ -320,7 +320,7 @@ message CreateUserRequest {
}

message GetUserRequest {
int32 id = 1;
int64 id = 1;

View view = 2;

Expand All @@ -338,7 +338,7 @@ message UpdateUserRequest {
}

message DeleteUserRequest {
int32 id = 1;
int64 id = 1;
}

message ListUserRequest {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions entproto/internal/todo/ent/proto/entpb/entpb_pet_service.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions entproto/internal/todo/ent/proto/entpb/entpb_user_service.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestMultiWordSchemaService_Get(t *testing.T) {
entry := client.MultiWordSchema.Create().
SetUnit(multiwordschema.UnitFt).
SaveX(ctx)
get, err := svc.Get(ctx, &GetMultiWordSchemaRequest{Id: int32(entry.ID)})
get, err := svc.Get(ctx, &GetMultiWordSchemaRequest{Id: int64(entry.ID)})
require.NoError(t, err)
require.EqualValues(t, MultiWordSchema_FT, get.GetUnit())
}
2 changes: 1 addition & 1 deletion entproto/internal/todo/ent/proto/entpb/nil_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestNilExampleService_Get(t *testing.T) {
SetStrNil("str").
SetTimeNil(time.Now()).
SaveX(ctx)
get, err := svc.Get(ctx, &GetNilExampleRequest{Id: int32(nex.ID)})
get, err := svc.Get(ctx, &GetNilExampleRequest{Id: int64(nex.ID)})
require.NoError(t, err)
require.EqualValues(t, nex.TimeNil.Unix(), get.GetTimeNil().AsTime().Unix())
require.EqualValues(t, *nex.StrNil, get.GetStrNil().GetValue())
Expand Down
10 changes: 5 additions & 5 deletions entproto/internal/todo/ent/proto/entpb/user_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func TestUserService_Create(t *testing.T) {
Status: User_ACTIVE,
ExternalId: 1,
Group: &Group{
Id: int32(group.ID),
Id: int64(group.ID),
},
CrmId: crmID,
Attachment: &Attachment{Id: attachmentID},
Expand Down Expand Up @@ -104,7 +104,7 @@ func TestUserService_Get(t *testing.T) {
SetAccountBalance(2000.50).
SaveX(ctx)
get, err := svc.Get(ctx, &GetUserRequest{
Id: int32(created.ID),
Id: int64(created.ID),
})
require.NoError(t, err)
require.EqualValues(t, created.UserName, get.UserName)
Expand Down Expand Up @@ -138,7 +138,7 @@ func TestUserService_Delete(t *testing.T) {
SetCustomPb(1).
SaveX(ctx)
d, err := svc.Delete(ctx, &DeleteUserRequest{
Id: int32(created.ID),
Id: int64(created.ID),
})
require.NoError(t, err)
require.NotNil(t, d)
Expand Down Expand Up @@ -180,15 +180,15 @@ func TestUserService_Update(t *testing.T) {
require.NoError(t, err, "Converting UUID to Bytes: %v", crmID)

inputUser := &User{
Id: int32(created.ID),
Id: int64(created.ID),
UserName: "rotemtam",
Joined: timestamppb.Now(),
Exp: 999,
Points: 999,
ExternalId: 1,
Status: User_ACTIVE,
Group: &Group{
Id: int32(group.ID),
Id: int64(group.ID),
},
Attachment: &Attachment{
Id: attachmentID,
Expand Down
2 changes: 1 addition & 1 deletion entproto/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func (a *Adapter) genMethodProtos(genType *gen.Type, m Method) (methodResources,
outputName = "google.protobuf.Empty"
messages = append(messages, input)
case MethodList:
if !(genType.ID.IsInt() || genType.ID.IsUUID() || genType.ID.IsString()) {
if !(genType.ID.IsInt() || genType.ID.IsInt64() || genType.ID.IsUUID() || genType.ID.IsString()) {
return methodResources{}, fmt.Errorf("entproto: list method does not support schema %q id type %q",
genType.Name, genType.ID.Type.String())
}
Expand Down
2 changes: 1 addition & 1 deletion entproto/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var typeMap = map[field.Type]typeConfig{
return pascal(fld.Name)
}},
field.TypeString: {pbType: descriptorpb.FieldDescriptorProto_TYPE_STRING, optionalType: "google.protobuf.StringValue"},
field.TypeInt: {pbType: descriptorpb.FieldDescriptorProto_TYPE_INT32, optionalType: "google.protobuf.Int32Value"},
field.TypeInt: {pbType: descriptorpb.FieldDescriptorProto_TYPE_INT64, optionalType: "google.protobuf.Int64Value"},
field.TypeInt8: {pbType: descriptorpb.FieldDescriptorProto_TYPE_INT32, optionalType: "google.protobuf.Int32Value"},
field.TypeInt16: {pbType: descriptorpb.FieldDescriptorProto_TYPE_INT32, optionalType: "google.protobuf.Int32Value"},
field.TypeInt32: {pbType: descriptorpb.FieldDescriptorProto_TYPE_INT32, optionalType: "google.protobuf.Int32Value"},
Expand Down

0 comments on commit 45a28d7

Please sign in to comment.