MCPcopy Create free account
hub / github.com/riverqueue/river / ColumnExists

Method ColumnExists

riverdriver/riversqlite/river_sqlite_driver.go:183–199  ·  view source on GitHub ↗
(ctx context.Context, params *riverdriver.ColumnExistsParams)

Source from the content-addressed store, hash-verified

181}
182
183func (e *Executor) ColumnExists(ctx context.Context, params *riverdriver.ColumnExistsParams) (bool, error) {
184 // Unfortunately this doesn't work in sqlc because of the "table value"
185 // pragma isn't supported. This seems like it should be fixable, but for now
186 // run the raw SQL to accomplish it.
187 const sql = `
188 SELECT EXISTS (
189 SELECT 1
190 FROM pragma_table_info
191 WHERE schema = ? AND arg = ? AND name = ?
192 )`
193 var exists int64
194 if err := e.dbtx.QueryRowContext(ctx, sql, cmp.Or(params.Schema, "main"), params.Table, params.Column).Scan(&exists); err != nil {
195 return false, interpretError(err)
196 }
197
198 return exists > 0, nil
199}
200
201func (e *Executor) Exec(ctx context.Context, sql string, args ...any) error {
202 _, err := e.dbtx.ExecContext(ctx, sql, args...)

Callers

nothing calls this directly

Implementers 3

Executorriverdriver/riverpgxv5/river_pgx_v5_dr
Executorriverdriver/riverdatabasesql/river_dat
Executorriverdriver/riversqlite/river_sqlite_d

Calls 3

interpretErrorFunction · 0.70
ScanMethod · 0.65
QueryRowContextMethod · 0.65

Tested by

no test coverage detected