Skip to content

Commit

Permalink
feat(spanner): add support for PROTO enum columns
Browse files Browse the repository at this point in the history
  • Loading branch information
newtonnthiga committed Jul 26, 2024
1 parent 80b646a commit b2d9dfa
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion internal/spanner/services/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -1383,10 +1383,20 @@ func (s *SpannerService) GetSpannerTable(ctx context.Context, name string) (*Spa
fileDescriptorSet: nil,
}
}

if strings.HasPrefix(columnType.DatabaseTypeName(), "ENUM<") {
// Set the proto file descriptor set
column.ProtoFileDescriptorSet = &ProtoFileDescriptorSet{
ProtoPackage: wrapperspb.String(strings.TrimSuffix(strings.TrimPrefix(columnType.DatabaseTypeName(), "ENUM<"), ">")),
FileDescriptorSetPath: nil,
FileDescriptorSetPathSource: 0,
fileDescriptorSet: nil,
}
}
}

column.Type = columnType.DatabaseTypeName()
if strings.HasPrefix(columnType.DatabaseTypeName(), "PROTO<") {
if strings.HasPrefix(columnType.DatabaseTypeName(), "PROTO<") || strings.HasPrefix(columnType.DatabaseTypeName(), "ENUM<") {
// Set the correct column type
// PROTO<my_package.MyMessage>
column.Type = SpannerTableDataType_PROTO.String()
Expand Down

0 comments on commit b2d9dfa

Please sign in to comment.