(tbl string, b squirrel.StatementBuilderType)
| 221 | } |
| 222 | |
| 223 | func primaryKeyField(tbl string, b squirrel.StatementBuilderType) ([]string, error) { |
| 224 | q := b.Select("column_name"). |
| 225 | From("INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS c"). |
| 226 | LeftJoin("INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS t USING(constraint_name)"). |
| 227 | Where("t.table_name = ? AND t.constraint_type = 'PRIMARY KEY'", tbl). |
| 228 | OrderBy("ordinal_position") |
| 229 | |
| 230 | rows, err := q.Query() |
| 231 | if err != nil { |
| 232 | return []string{}, err |
| 233 | } |
| 234 | |
| 235 | res := []string{} |
| 236 | for rows.Next() { |
| 237 | var s string |
| 238 | rows.Scan(&s) |
| 239 | res = append(res, s) |
| 240 | } |
| 241 | return res, nil |
| 242 | } |
| 243 | |
| 244 | func sequentialKey(tbl, pk string, b squirrel.StatementBuilderType) bool { |
| 245 |
no test coverage detected