(tableNames []string)
| 1322 | } |
| 1323 | |
| 1324 | func (d *PostgresDatabase) getPrimaryKeyColumnsForTables(tableNames []string) (map[string][]string, error) { |
| 1325 | const query = `SELECT |
| 1326 | tc.table_schema || '.' || tc.table_name AS qualified_table_name, |
| 1327 | kcu.column_name |
| 1328 | FROM |
| 1329 | information_schema.table_constraints AS tc |
| 1330 | JOIN information_schema.key_column_usage AS kcu |
| 1331 | USING (table_schema, table_name, constraint_name) |
| 1332 | WHERE constraint_type = 'PRIMARY KEY' |
| 1333 | AND tc.table_schema || '.' || tc.table_name = ANY($1::text[]) |
| 1334 | ORDER BY tc.table_schema, tc.table_name, kcu.ordinal_position` |
| 1335 | |
| 1336 | rows, err := d.db.Query(query, pq.Array(tableNames)) |
| 1337 | if err != nil { |
| 1338 | return nil, err |
| 1339 | } |
| 1340 | defer rows.Close() |
| 1341 | |
| 1342 | result := make(map[string][]string, len(tableNames)) |
| 1343 | for rows.Next() { |
| 1344 | var tableName, columnName string |
| 1345 | err = rows.Scan(&tableName, &columnName) |
| 1346 | if err != nil { |
| 1347 | return nil, err |
| 1348 | } |
| 1349 | result[tableName] = append(result[tableName], columnName) |
| 1350 | } |
| 1351 | return result, nil |
| 1352 | } |
| 1353 | |
| 1354 | func (d *PostgresDatabase) getPrimaryKeyInfosForTables(tableNames []string) (map[string]primaryKeyInfo, error) { |
| 1355 | var selectCols string |
no test coverage detected