MCPcopy Create free account
hub / github.com/Facets-cloud/flow / columnExists

Function columnExists

internal/flowdb/db.go:657–676  ·  view source on GitHub ↗
(db *sql.DB, table, column string)

Source from the content-addressed store, hash-verified

655}
656
657func 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, &notnull, &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

Calls

no outgoing calls