Helper function to get the primary key. For composite primary keys, `row()` is used.
(schema sql.Schema)
| 626 | |
| 627 | // Helper function to get the primary key. For composite primary keys, `row()` is used. |
| 628 | func getPrimaryKeyStruct(schema sql.Schema) string { |
| 629 | pks := make([]string, 0, 1) |
| 630 | for _, col := range schema { |
| 631 | if col.PrimaryKey { |
| 632 | pks = append(pks, catalog.QuoteIdentifierANSI(col.Name)) |
| 633 | } |
| 634 | } |
| 635 | if len(pks) == 0 { |
| 636 | return "" |
| 637 | } else if len(pks) == 1 { |
| 638 | return pks[0] |
| 639 | } |
| 640 | return "row(" + strings.Join(pks, ", ") + ")" |
| 641 | } |
| 642 | |
| 643 | // Helper function to get the primary key list. |
| 644 | func getPrimaryKeyList(schema sql.Schema) string { |
no test coverage detected