(db *sql.DB, table, column string)
| 655 | } |
| 656 | |
| 657 | func columnExists(db *sql.DB, table, column string) (bool, error) { |
| 658 | rows, err := db.Query(fmt.Sprintf(`PRAGMA table_info(%s)`, table)) |
| 659 | if err != nil { |
| 660 | return false, fmt.Errorf("pragma table_info(%s): %w", table, err) |
| 661 | } |
| 662 | defer rows.Close() |
| 663 | for rows.Next() { |
| 664 | var cid int |
| 665 | var name, ctype string |
| 666 | var notnull, pk int |
| 667 | var dflt sql.NullString |
| 668 | if err := rows.Scan(&cid, &name, &ctype, ¬null, &dflt, &pk); err != nil { |
| 669 | return false, err |
| 670 | } |
| 671 | if name == column { |
| 672 | return true, nil |
| 673 | } |
| 674 | } |
| 675 | return false, rows.Err() |
| 676 | } |
| 677 | |
| 678 | // ---------- project queries ---------- |
| 679 |
no outgoing calls