MCPcopy Index your code
hub / github.com/bytebase/bytebase / convertStoreObjectSchema

Function convertStoreObjectSchema

backend/api/v1/database_catalog_service.go:170–207  ·  view source on GitHub ↗
(objectSchema *storepb.ObjectSchema)

Source from the content-addressed store, hash-verified

168}
169
170func convertStoreObjectSchema(objectSchema *storepb.ObjectSchema) *v1pb.ObjectSchema {
171 if objectSchema == nil {
172 return nil
173 }
174 o := &v1pb.ObjectSchema{}
175 switch objectSchema.Type {
176 case storepb.ObjectSchema_STRING:
177 o.Type = v1pb.ObjectSchema_STRING
178 case storepb.ObjectSchema_NUMBER:
179 o.Type = v1pb.ObjectSchema_NUMBER
180 case storepb.ObjectSchema_BOOLEAN:
181 o.Type = v1pb.ObjectSchema_BOOLEAN
182 case storepb.ObjectSchema_OBJECT:
183 o.Type = v1pb.ObjectSchema_OBJECT
184 case storepb.ObjectSchema_ARRAY:
185 o.Type = v1pb.ObjectSchema_ARRAY
186 default:
187 }
188 switch objectSchema.Kind.(type) {
189 case *storepb.ObjectSchema_StructKind_:
190 properties := make(map[string]*v1pb.ObjectSchema)
191 for k, v := range objectSchema.GetStructKind().Properties {
192 properties[k] = convertStoreObjectSchema(v)
193 }
194 o.Kind = &v1pb.ObjectSchema_StructKind_{
195 StructKind: &v1pb.ObjectSchema_StructKind{Properties: properties},
196 }
197 case *storepb.ObjectSchema_ArrayKind_:
198 o.Kind = &v1pb.ObjectSchema_ArrayKind_{
199 ArrayKind: &v1pb.ObjectSchema_ArrayKind{
200 Kind: convertStoreObjectSchema(objectSchema.GetArrayKind().GetKind()),
201 },
202 }
203 default:
204 }
205 o.SemanticType = objectSchema.SemanticType
206 return o
207}
208
209func convertDatabaseCatalog(catalog *v1pb.DatabaseCatalog) *storepb.DatabaseConfig {
210 c := &storepb.DatabaseConfig{}

Callers 2

convertTableCatalogFunction · 0.85
convertColumnCatalogFunction · 0.85

Calls 3

GetStructKindMethod · 0.45
GetKindMethod · 0.45
GetArrayKindMethod · 0.45

Tested by

no test coverage detected