diff options
Diffstat (limited to 'pgruntime/helpers.go')
| -rw-r--r-- | pgruntime/helpers.go | 20 |
1 files changed, 0 insertions, 20 deletions
diff --git a/pgruntime/helpers.go b/pgruntime/helpers.go index 1019e6e..3f4723a 100644 --- a/pgruntime/helpers.go +++ b/pgruntime/helpers.go @@ -47,26 +47,6 @@ func selectOneValue[T any](ctx context.Context, db gsql.Handle, query string, ar return result, errext.WithCleanup(err, "stmt.Close", stmt.Close()) } -// Convenience function for executing a one-off SQL query returning several single-column rows. -// TODO: move to gsql (and also add ForeachValue with a callback instead of a slice return, maybe even ForeachPair and ForeachTriple) -func selectSeveralValues[T any](ctx context.Context, db gsql.Handle, query string, args ...any) ([]T, error) { - rows, err := db.GSQLQuery(ctx, query, args) - if err != nil { - return nil, err - } - var result []T - for rows.Next() { - // TODO: this should share growRecordSlice() from Oblast to optimize allocations - var value T - err := rows.Scan(&value) - if err != nil { - return nil, errext.WithCleanup(err, "rows.Close", rows.Close()) - } - result = append(result, value) - } - return result, errext.WithCleanup(nil, "rows.Err", rows.Err()) -} - // Convenience function for preparing an identifier that needs to be inserted into a query verbatim // (e.g. a database name for CREATE DATABASE). func quoteIdentifier(name string) string { |
