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

Function primaryKeyColumns

backend/api/mcp/tool_schema.go:649–660  ·  view source on GitHub ↗

primaryKeyColumns scans indexes for the primary-key index and returns the set of column names it covers. Note: IndexMetadata.expressions may contain expressions rather than column names for expression indexes (e.g. PostgreSQL CREATE INDEX ON users (LOWER(email))). PostgreSQL does not currently allo

(indexes []indexMetadata)

Source from the content-addressed store, hash-verified

647// expression text against column name is correct today. Revisit if PG ever
648// allows expression PKs; silent misses are preferred over flagging the wrong column.
649func primaryKeyColumns(indexes []indexMetadata) map[string]bool {
650 result := map[string]bool{}
651 for _, idx := range indexes {
652 if !idx.Primary {
653 continue
654 }
655 for _, expr := range idx.Expressions {
656 result[expr] = true
657 }
658 }
659 return result
660}
661
662// formatSchemaOutput produces a text header + JSON body (same pattern as query_database).
663func formatSchemaOutput(output *SchemaOutput, include string, warnings []string) string {

Callers 1

buildTableEntryFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected