MCPcopy Create free account
hub / github.com/bytebase/bytebase / getTableObjectSchema

Function getTableObjectSchema

backend/api/v1/document_masking.go:1339–1362  ·  view source on GitHub ↗

getTableObjectSchema retrieves the ObjectSchema for a table/collection/index/container by name from the database config. This is the shared implementation for all document databases (CosmosDB containers, MongoDB collections, Elasticsearch indices).

(ctx context.Context, stores *store.Store, instanceID, databaseName, tableName string)

Source from the content-addressed store, hash-verified

1337// by name from the database config. This is the shared implementation for all document
1338// databases (CosmosDB containers, MongoDB collections, Elasticsearch indices).
1339func getTableObjectSchema(ctx context.Context, stores *store.Store, instanceID, databaseName, tableName string) (*storepb.ObjectSchema, error) {
1340 dbMetadata, err := stores.GetDBSchema(ctx, &store.FindDBSchemaMessage{
1341 Workspace: common.GetWorkspaceIDFromContext(ctx),
1342 InstanceID: instanceID,
1343 DatabaseName: databaseName,
1344 })
1345 if err != nil {
1346 return nil, errors.Wrapf(err, "failed to get database schema: %q", databaseName)
1347 }
1348
1349 if dbMetadata == nil {
1350 return nil, nil
1351 }
1352
1353 for _, schema := range dbMetadata.GetConfig().GetSchemas() {
1354 for _, table := range schema.GetTables() {
1355 if table.GetName() == tableName {
1356 return table.GetObjectSchema(), nil
1357 }
1358 }
1359 }
1360
1361 return nil, nil
1362}
1363
1364// objectSchemaHasSemanticTypes recursively checks if any node in the ObjectSchema has a semantic type set.
1365func objectSchemaHasSemanticTypes(os *storepb.ObjectSchema) bool {

Callers 6

checkSensitivePredicatesFunction · 0.85
maskResultsMethod · 0.85
maskResultsMethod · 0.85
maskResultsMethod · 0.85

Calls 7

GetDBSchemaMethod · 0.80
GetSchemasMethod · 0.45
GetConfigMethod · 0.45
GetTablesMethod · 0.45
GetNameMethod · 0.45
GetObjectSchemaMethod · 0.45

Tested by

no test coverage detected