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

Function matchSubstring

backend/api/mcp/tool_resolve.go:281–290  ·  view source on GitHub ↗

matchSubstring returns databases whose short name contains the input as a substring.

(databases []databaseEntry, name string)

Source from the content-addressed store, hash-verified

279
280// matchSubstring returns databases whose short name contains the input as a substring.
281func matchSubstring(databases []databaseEntry, name string) []databaseEntry {
282 var result []databaseEntry
283 lower := strings.ToLower(name)
284 for _, db := range databases {
285 if strings.Contains(strings.ToLower(extractDatabaseName(db.Name)), lower) {
286 result = append(result, db)
287 }
288 }
289 return result
290}
291
292// extractDatabaseName extracts the database name from a resource name like "instances/prod-pg/databases/employee_db".
293func extractDatabaseName(resourceName string) string {

Callers 1

matchDatabasesFunction · 0.85

Calls 1

extractDatabaseNameFunction · 0.70

Tested by

no test coverage detected