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

Function getObjectSchemaByPath

backend/api/v1/document_masking.go:349–394  ·  view source on GitHub ↗
(objectSchema *storepb.ObjectSchema, path *parserbase.PathAST)

Source from the content-addressed store, hash-verified

347}
348
349func getObjectSchemaByPath(objectSchema *storepb.ObjectSchema, path *parserbase.PathAST) (*storepb.ObjectSchema, string) {
350 outer := objectSchema
351 outerSemanticType := outer.SemanticType
352 if outerSemanticType != "" {
353 return outer, outer.SemanticType
354 }
355 for node := path.Root; node != nil; node = node.GetNext() {
356 identifier := node.GetIdentifier()
357 switch outer.Type {
358 case storepb.ObjectSchema_OBJECT:
359 v := outer.GetStructKind().GetProperties()
360 if v == nil {
361 return nil, outerSemanticType
362 }
363 inner, ok := v[identifier]
364 if !ok {
365 return nil, outerSemanticType
366 }
367 outer = inner
368 outerSemanticType = outer.SemanticType
369 case storepb.ObjectSchema_ARRAY:
370 v := outer.GetArrayKind().GetKind()
371 if v == nil {
372 return nil, outerSemanticType
373 }
374 if v.Type != storepb.ObjectSchema_OBJECT {
375 return nil, outerSemanticType
376 }
377 p := v.GetStructKind().GetProperties()
378 if p == nil {
379 return nil, outerSemanticType
380 }
381 inner, ok := p[identifier]
382 if !ok {
383 return nil, outerSemanticType
384 }
385 outer = inner
386 outerSemanticType = outer.SemanticType
387 default:
388 // Other schema types
389 return nil, outerSemanticType
390 }
391 }
392
393 return outer, outerSemanticType
394}
395
396func walkAndMaskJSONRecursive(data any, objectSchema *storepb.ObjectSchema, semanticTypeToMasker map[string]masker.Masker) (any, error) {
397 if objectSchema == nil {

Callers 4

maskFieldBySourcePathsFunction · 0.85
maskFieldByDirectLookupFunction · 0.85
maskBySourcePathsFunction · 0.85
findMaskerForScalarValueFunction · 0.85

Calls 6

GetNextMethod · 0.65
GetIdentifierMethod · 0.65
GetPropertiesMethod · 0.45
GetStructKindMethod · 0.45
GetKindMethod · 0.45
GetArrayKindMethod · 0.45

Tested by

no test coverage detected