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

Function extractSourceTable

backend/api/v1/sql_service.go:517–535  ·  view source on GitHub ↗
(comment string)

Source from the content-addressed store, hash-verified

515}
516
517func extractSourceTable(comment string) (string, string, string, error) {
518 pattern := `\((\w+),\s*(\w+)(?:,\s*(\w+))?\)`
519 re := regexp.MustCompile(pattern)
520
521 matches := re.FindStringSubmatch(comment)
522
523 if len(matches) == 3 || (len(matches) == 4 && matches[3] == "") {
524 databaseName := matches[1]
525 tableName := matches[2]
526 return databaseName, "", tableName, nil
527 } else if len(matches) == 4 {
528 databaseName := matches[1]
529 schemaName := matches[2]
530 tableName := matches[3]
531 return databaseName, schemaName, tableName, nil
532 }
533
534 return "", "", "", errors.Errorf("failed to extract source table from comment: %s", comment)
535}
536
537func getSchemaMetadata(engine storepb.Engine, dbMetadata *model.DatabaseMetadata) *model.SchemaMetadata {
538 switch engine {

Callers 1

Calls 1

ErrorfMethod · 0.80

Tested by

no test coverage detected