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)
| 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. |
| 649 | func 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). |
| 663 | func formatSchemaOutput(output *SchemaOutput, include string, warnings []string) string { |