From d3024d4fa7c9ce9d62e2f2cc0b42faf679211846 Mon Sep 17 00:00:00 2001 From: Chinmaya Bharadwaj Date: Wed, 22 Nov 2023 11:54:59 +0530 Subject: [PATCH] feat: add bytes support (#254) --- example/feature_demo/demo_types.pb.go | 156 +++++++++++---------- example/feature_demo/demo_types.pb.gorm.go | 7 + example/feature_demo/demo_types.proto | 1 + plugin/plugin.go | 4 +- 4 files changed, 94 insertions(+), 74 deletions(-) diff --git a/example/feature_demo/demo_types.pb.go b/example/feature_demo/demo_types.pb.go index 0811da32..f401998a 100644 --- a/example/feature_demo/demo_types.pb.go +++ b/example/feature_demo/demo_types.pb.go @@ -286,6 +286,7 @@ type TypeWithID struct { // Limited support for DB type 'time', implemented via strings (string -> DB && DB -> string) TimeOnly *types.TimeOnly `protobuf:"bytes,14,opt,name=time_only,json=timeOnly,proto3" json:"time_only,omitempty"` DeletedAt *timestamppb.Timestamp `protobuf:"bytes,15,opt,name=deleted_at,json=deletedAt,proto3" json:"deleted_at,omitempty"` + Metadata []byte `protobuf:"bytes,16,opt,name=metadata,proto3" json:"metadata,omitempty"` } func (x *TypeWithID) Reset() { @@ -425,6 +426,13 @@ func (x *TypeWithID) GetDeletedAt() *timestamppb.Timestamp { return nil } +func (x *TypeWithID) GetMetadata() []byte { + if x != nil { + return x.Metadata + } + return nil +} + // MultiaccountTypeWithID demonstrates the generated multi-account support type MultiaccountTypeWithID struct { state protoimpl.MessageState @@ -1138,7 +1146,7 @@ var file_feature_demo_demo_types_proto_rawDesc = []byte{ 0x6e, 0x67, 0x41, 0x72, 0x72, 0x61, 0x79, 0x12, 0x06, 0x61, 0x72, 0x72, 0x61, 0x79, 0x32, 0x22, 0x11, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6c, 0x69, 0x62, 0x2f, 0x70, 0x71, 0x1a, 0x0b, 0x73, 0x6d, 0x6f, 0x72, 0x67, 0x61, 0x73, 0x62, 0x6f, 0x72, 0x64, 0x22, - 0xc8, 0x06, 0x0a, 0x0a, 0x54, 0x79, 0x70, 0x65, 0x57, 0x69, 0x74, 0x68, 0x49, 0x44, 0x12, 0x0e, + 0xe4, 0x06, 0x0a, 0x0a, 0x54, 0x79, 0x70, 0x65, 0x57, 0x69, 0x74, 0x68, 0x49, 0x44, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1f, 0x0a, 0x02, 0x69, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0f, 0xba, 0xb9, 0x19, 0x0b, 0x0a, 0x09, 0x0a, 0x07, 0x69, 0x70, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x52, 0x02, 0x69, 0x70, 0x12, @@ -1185,89 +1193,91 @@ var file_feature_demo_demo_types_proto_rawDesc = []byte{ 0x65, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x64, 0x65, 0x6c, 0x65, 0x74, - 0x65, 0x64, 0x41, 0x74, 0x3a, 0x54, 0xba, 0xb9, 0x19, 0x50, 0x08, 0x01, 0x12, 0x17, 0x0a, 0x05, - 0x69, 0x6e, 0x74, 0x33, 0x32, 0x12, 0x0a, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x5f, 0x69, 0x6e, - 0x74, 0x1a, 0x02, 0x70, 0x01, 0x12, 0x33, 0x0a, 0x0c, 0x5b, 0x5d, 0x2a, 0x4a, 0x6f, 0x69, 0x6e, - 0x54, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x13, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x5f, 0x61, 0x63, 0x63, - 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x1a, 0x0e, 0x7a, 0x0c, 0x54, 0x79, - 0x70, 0x65, 0x57, 0x69, 0x74, 0x68, 0x49, 0x44, 0x49, 0x44, 0x22, 0x51, 0x0a, 0x16, 0x4d, 0x75, - 0x6c, 0x74, 0x69, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x57, 0x69, - 0x74, 0x68, 0x49, 0x44, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, - 0x52, 0x02, 0x69, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x6f, 0x6d, 0x65, 0x5f, 0x66, 0x69, 0x65, - 0x6c, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x6f, 0x6d, 0x65, 0x46, 0x69, - 0x65, 0x6c, 0x64, 0x3a, 0x08, 0xba, 0xb9, 0x19, 0x04, 0x08, 0x01, 0x20, 0x01, 0x22, 0x44, 0x0a, - 0x19, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x54, 0x79, 0x70, - 0x65, 0x57, 0x69, 0x74, 0x68, 0x6f, 0x75, 0x74, 0x49, 0x44, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x6f, - 0x6d, 0x65, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, - 0x73, 0x6f, 0x6d, 0x65, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x3a, 0x08, 0xba, 0xb9, 0x19, 0x04, 0x08, - 0x01, 0x20, 0x01, 0x22, 0x29, 0x0a, 0x0b, 0x41, 0x50, 0x49, 0x4f, 0x6e, 0x6c, 0x79, 0x54, 0x79, - 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x22, 0x6e, - 0x0a, 0x0f, 0x50, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x55, 0x55, 0x49, 0x44, 0x54, 0x79, 0x70, - 0x65, 0x12, 0x25, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, - 0x67, 0x6f, 0x72, 0x6d, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x55, 0x55, 0x49, 0x44, 0x56, - 0x61, 0x6c, 0x75, 0x65, 0x52, 0x02, 0x69, 0x64, 0x12, 0x2c, 0x0a, 0x05, 0x63, 0x68, 0x69, 0x6c, - 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, - 0x65, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x43, 0x68, 0x69, 0x6c, 0x64, 0x52, - 0x05, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x3a, 0x06, 0xba, 0xb9, 0x19, 0x02, 0x08, 0x01, 0x22, 0x59, - 0x0a, 0x11, 0x50, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x54, - 0x79, 0x70, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x02, 0x69, 0x64, 0x12, 0x2c, 0x0a, 0x05, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x45, 0x78, 0x74, - 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x43, 0x68, 0x69, 0x6c, 0x64, 0x52, 0x05, 0x63, 0x68, 0x69, 0x6c, - 0x64, 0x3a, 0x06, 0xba, 0xb9, 0x19, 0x02, 0x08, 0x01, 0x22, 0x6a, 0x0a, 0x07, 0x54, 0x65, 0x73, - 0x74, 0x54, 0x61, 0x67, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x02, 0x69, 0x64, 0x12, 0x47, 0x0a, 0x0c, 0x74, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, - 0x73, 0x73, 0x6f, 0x63, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x65, 0x78, 0x61, - 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, - 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x06, 0xba, 0xb9, 0x19, 0x02, 0x1a, 0x00, 0x52, - 0x0c, 0x74, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x3a, 0x06, 0xba, - 0xb9, 0x19, 0x02, 0x08, 0x01, 0x22, 0x7a, 0x0a, 0x17, 0x54, 0x65, 0x73, 0x74, 0x41, 0x73, 0x73, - 0x6f, 0x63, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, + 0x65, 0x64, 0x41, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, + 0x18, 0x10, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, + 0x3a, 0x54, 0xba, 0xb9, 0x19, 0x50, 0x08, 0x01, 0x12, 0x17, 0x0a, 0x05, 0x69, 0x6e, 0x74, 0x33, + 0x32, 0x12, 0x0a, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x5f, 0x69, 0x6e, 0x74, 0x1a, 0x02, 0x70, + 0x01, 0x12, 0x33, 0x0a, 0x0c, 0x5b, 0x5d, 0x2a, 0x4a, 0x6f, 0x69, 0x6e, 0x54, 0x61, 0x62, 0x6c, + 0x65, 0x12, 0x13, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x5f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x1a, 0x0e, 0x7a, 0x0c, 0x54, 0x79, 0x70, 0x65, 0x57, 0x69, + 0x74, 0x68, 0x49, 0x44, 0x49, 0x44, 0x22, 0x51, 0x0a, 0x16, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x61, + 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x57, 0x69, 0x74, 0x68, 0x49, 0x44, + 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x02, 0x69, 0x64, + 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x6f, 0x6d, 0x65, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x6f, 0x6d, 0x65, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x3a, + 0x08, 0xba, 0xb9, 0x19, 0x04, 0x08, 0x01, 0x20, 0x01, 0x22, 0x44, 0x0a, 0x19, 0x4d, 0x75, 0x6c, + 0x74, 0x69, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x57, 0x69, 0x74, + 0x68, 0x6f, 0x75, 0x74, 0x49, 0x44, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x6f, 0x6d, 0x65, 0x5f, 0x66, + 0x69, 0x65, 0x6c, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x6f, 0x6d, 0x65, + 0x46, 0x69, 0x65, 0x6c, 0x64, 0x3a, 0x08, 0xba, 0xb9, 0x19, 0x04, 0x08, 0x01, 0x20, 0x01, 0x22, + 0x29, 0x0a, 0x0b, 0x41, 0x50, 0x49, 0x4f, 0x6e, 0x6c, 0x79, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1a, + 0x0a, 0x08, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x08, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x22, 0x6e, 0x0a, 0x0f, 0x50, 0x72, + 0x69, 0x6d, 0x61, 0x72, 0x79, 0x55, 0x55, 0x49, 0x44, 0x54, 0x79, 0x70, 0x65, 0x12, 0x25, 0x0a, + 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x67, 0x6f, 0x72, 0x6d, + 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x55, 0x55, 0x49, 0x44, 0x56, 0x61, 0x6c, 0x75, 0x65, + 0x52, 0x02, 0x69, 0x64, 0x12, 0x2c, 0x0a, 0x05, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x45, 0x78, + 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x43, 0x68, 0x69, 0x6c, 0x64, 0x52, 0x05, 0x63, 0x68, 0x69, + 0x6c, 0x64, 0x3a, 0x06, 0xba, 0xb9, 0x19, 0x02, 0x08, 0x01, 0x22, 0x59, 0x0a, 0x11, 0x50, 0x72, + 0x69, 0x6d, 0x61, 0x72, 0x79, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x54, 0x79, 0x70, 0x65, 0x12, + 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, + 0x2c, 0x0a, 0x05, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, + 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, + 0x6c, 0x43, 0x68, 0x69, 0x6c, 0x64, 0x52, 0x05, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x3a, 0x06, 0xba, + 0xb9, 0x19, 0x02, 0x08, 0x01, 0x22, 0x6a, 0x0a, 0x07, 0x54, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x47, 0x0a, 0x0c, 0x74, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, - 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x42, 0x06, 0xba, 0xb9, 0x19, 0x02, 0x2a, 0x00, 0x52, 0x0c, 0x74, 0x65, 0x73, + 0x69, 0x6f, 0x6e, 0x42, 0x06, 0xba, 0xb9, 0x19, 0x02, 0x1a, 0x00, 0x52, 0x0c, 0x74, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x3a, 0x06, 0xba, 0xb9, 0x19, 0x02, 0x08, - 0x01, 0x22, 0x7c, 0x0a, 0x17, 0x54, 0x65, 0x73, 0x74, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x48, 0x61, - 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x52, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x12, 0x0e, 0x0a, 0x02, - 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x49, 0x0a, 0x0c, + 0x01, 0x22, 0x7a, 0x0a, 0x17, 0x54, 0x65, 0x73, 0x74, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x48, 0x61, + 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x12, 0x0e, 0x0a, 0x02, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x47, 0x0a, 0x0c, 0x74, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, - 0x08, 0xba, 0xb9, 0x19, 0x04, 0x2a, 0x02, 0x50, 0x01, 0x52, 0x0c, 0x74, 0x65, 0x73, 0x74, 0x54, - 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x3a, 0x06, 0xba, 0xb9, 0x19, 0x02, 0x08, 0x01, 0x22, - 0x7a, 0x0a, 0x15, 0x54, 0x65, 0x73, 0x74, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x48, 0x61, 0x6e, 0x64, - 0x6c, 0x65, 0x72, 0x43, 0x6c, 0x65, 0x61, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, + 0x06, 0xba, 0xb9, 0x19, 0x02, 0x2a, 0x00, 0x52, 0x0c, 0x74, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, + 0x41, 0x73, 0x73, 0x6f, 0x63, 0x3a, 0x06, 0xba, 0xb9, 0x19, 0x02, 0x08, 0x01, 0x22, 0x7c, 0x0a, + 0x17, 0x54, 0x65, 0x73, 0x74, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, + 0x72, 0x52, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x49, 0x0a, 0x0c, 0x74, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x08, 0xba, 0xb9, 0x19, - 0x04, 0x2a, 0x02, 0x60, 0x01, 0x52, 0x0c, 0x74, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, - 0x73, 0x6f, 0x63, 0x3a, 0x06, 0xba, 0xb9, 0x19, 0x02, 0x08, 0x01, 0x22, 0x7b, 0x0a, 0x16, 0x54, - 0x65, 0x73, 0x74, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x41, - 0x70, 0x70, 0x65, 0x6e, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x49, 0x0a, 0x0c, 0x74, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, - 0x41, 0x73, 0x73, 0x6f, 0x63, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x65, 0x78, - 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, - 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x08, 0xba, 0xb9, 0x19, 0x04, 0x2a, 0x02, - 0x58, 0x01, 0x52, 0x0c, 0x74, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, - 0x3a, 0x06, 0xba, 0xb9, 0x19, 0x02, 0x08, 0x01, 0x22, 0x3b, 0x0a, 0x12, 0x54, 0x65, 0x73, 0x74, - 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1d, - 0x0a, 0x0a, 0x73, 0x6f, 0x6d, 0x65, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x09, 0x73, 0x6f, 0x6d, 0x65, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x3a, 0x06, 0xba, - 0xb9, 0x19, 0x02, 0x08, 0x01, 0x22, 0x53, 0x0a, 0x0f, 0x50, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, - 0x49, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x64, 0x12, 0x2c, 0x0a, 0x05, 0x63, 0x68, 0x69, 0x6c, - 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, - 0x65, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x43, 0x68, 0x69, 0x6c, 0x64, 0x52, - 0x05, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x3a, 0x12, 0xba, 0xb9, 0x19, 0x0e, 0x08, 0x01, 0x12, 0x0a, - 0x0a, 0x04, 0x55, 0x55, 0x49, 0x44, 0x12, 0x02, 0x69, 0x64, 0x42, 0x46, 0x5a, 0x44, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x6e, 0x66, 0x6f, 0x62, 0x6c, 0x6f, - 0x78, 0x6f, 0x70, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, - 0x2d, 0x67, 0x6f, 0x72, 0x6d, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x66, 0x65, - 0x61, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x64, 0x65, 0x6d, 0x6f, 0x3b, 0x65, 0x78, 0x61, 0x6d, 0x70, - 0x6c, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x04, 0x2a, 0x02, 0x50, 0x01, 0x52, 0x0c, 0x74, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, + 0x73, 0x6f, 0x63, 0x3a, 0x06, 0xba, 0xb9, 0x19, 0x02, 0x08, 0x01, 0x22, 0x7a, 0x0a, 0x15, 0x54, + 0x65, 0x73, 0x74, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x43, + 0x6c, 0x65, 0x61, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x02, 0x69, 0x64, 0x12, 0x49, 0x0a, 0x0c, 0x74, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, + 0x73, 0x73, 0x6f, 0x63, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x65, 0x78, 0x61, + 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, + 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x08, 0xba, 0xb9, 0x19, 0x04, 0x2a, 0x02, 0x60, + 0x01, 0x52, 0x0c, 0x74, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x3a, + 0x06, 0xba, 0xb9, 0x19, 0x02, 0x08, 0x01, 0x22, 0x7b, 0x0a, 0x16, 0x54, 0x65, 0x73, 0x74, 0x41, + 0x73, 0x73, 0x6f, 0x63, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x41, 0x70, 0x70, 0x65, 0x6e, + 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, + 0x64, 0x12, 0x49, 0x0a, 0x0c, 0x74, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, + 0x63, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, + 0x65, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x08, 0xba, 0xb9, 0x19, 0x04, 0x2a, 0x02, 0x58, 0x01, 0x52, 0x0c, + 0x74, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x3a, 0x06, 0xba, 0xb9, + 0x19, 0x02, 0x08, 0x01, 0x22, 0x3b, 0x0a, 0x12, 0x54, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, + 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x6f, + 0x6d, 0x65, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, + 0x73, 0x6f, 0x6d, 0x65, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x3a, 0x06, 0xba, 0xb9, 0x19, 0x02, 0x08, + 0x01, 0x22, 0x53, 0x0a, 0x0f, 0x50, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x49, 0x6e, 0x63, 0x6c, + 0x75, 0x64, 0x65, 0x64, 0x12, 0x2c, 0x0a, 0x05, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x45, 0x78, + 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x43, 0x68, 0x69, 0x6c, 0x64, 0x52, 0x05, 0x63, 0x68, 0x69, + 0x6c, 0x64, 0x3a, 0x12, 0xba, 0xb9, 0x19, 0x0e, 0x08, 0x01, 0x12, 0x0a, 0x0a, 0x04, 0x55, 0x55, + 0x49, 0x44, 0x12, 0x02, 0x69, 0x64, 0x42, 0x46, 0x5a, 0x44, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x6e, 0x66, 0x6f, 0x62, 0x6c, 0x6f, 0x78, 0x6f, 0x70, 0x65, + 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x67, 0x6f, 0x72, + 0x6d, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, + 0x65, 0x5f, 0x64, 0x65, 0x6d, 0x6f, 0x3b, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/example/feature_demo/demo_types.pb.gorm.go b/example/feature_demo/demo_types.pb.gorm.go index 59496028..bd37f258 100644 --- a/example/feature_demo/demo_types.pb.gorm.go +++ b/example/feature_demo/demo_types.pb.gorm.go @@ -181,6 +181,7 @@ type TypeWithIDORM struct { Id uint32 IntPointId *uint32 Ip string `gorm:"column:ip_addr"` + Metadata []byte `gorm:"type:bytea"` MultiAccountTypes []*JoinTable `gorm:"foreignKey:TypeWithIDID"` Point *IntPointORM `gorm:"foreignKey:IntPointId;references:Id"` SecretInt int32 `gorm:"-"` @@ -265,6 +266,7 @@ func (m *TypeWithID) ToORM(ctx context.Context) (TypeWithIDORM, error) { t := m.DeletedAt.AsTime() to.DeletedAt = &t } + to.Metadata = m.Metadata if posthook, ok := interface{}(m).(TypeWithIDWithAfterToORM); ok { err = posthook.AfterToORM(ctx, &to) } @@ -334,6 +336,7 @@ func (m *TypeWithIDORM) ToPB(ctx context.Context) (TypeWithID, error) { if m.DeletedAt != nil { to.DeletedAt = timestamppb.New(*m.DeletedAt) } + to.Metadata = m.Metadata if posthook, ok := interface{}(m).(TypeWithIDWithAfterToPB); ok { err = posthook.AfterToPB(ctx, &to) } @@ -1995,6 +1998,10 @@ func DefaultApplyFieldMaskTypeWithID(ctx context.Context, patchee *TypeWithID, p patchee.DeletedAt = patcher.DeletedAt continue } + if f == prefix+"Metadata" { + patchee.Metadata = patcher.Metadata + continue + } } if err != nil { return nil, err diff --git a/example/feature_demo/demo_types.proto b/example/feature_demo/demo_types.proto index c6ce01a6..0deb844e 100644 --- a/example/feature_demo/demo_types.proto +++ b/example/feature_demo/demo_types.proto @@ -115,6 +115,7 @@ message TypeWithID { // Limited support for DB type 'time', implemented via strings (string -> DB && DB -> string) gorm.types.TimeOnly time_only = 14; google.protobuf.Timestamp deleted_at = 15; + bytes metadata = 16; } // MultiaccountTypeWithID demonstrates the generated multi-account support diff --git a/plugin/plugin.go b/plugin/plugin.go index 82bd0c33..2d8000c5 100644 --- a/plugin/plugin.go +++ b/plugin/plugin.go @@ -886,7 +886,6 @@ func (b *ORMBuilder) parseBasicFields(msg *protogen.Message, g *protogen.Generat tag := gormOptions.Tag fieldName := camelCase(string(fd.Name())) fieldType := fd.Kind().String() - var typePackage string if b.dbEngine == ENGINE_POSTGRES && b.IsAbleToMakePQArray(fieldType) && field.Desc.IsList() { @@ -994,6 +993,9 @@ func (b *ORMBuilder) parseBasicFields(msg *protogen.Message, g *protogen.Generat } switch fieldType { + case "bytes": + fieldType = "[]byte" + gormOptions.Tag = tagWithType(tag, "bytea") case "float": fieldType = "float32" case "double":