diff --git a/bindings/postgres/postgres.go b/bindings/postgres/postgres.go index 3a0ab98252..0f20c052b3 100644 --- a/bindings/postgres/postgres.go +++ b/bindings/postgres/postgres.go @@ -186,13 +186,21 @@ func (p *Postgres) query(ctx context.Context, sql string, args ...any) (result [ return nil, fmt.Errorf("error executing query: %w", err) } + cols := rows.FieldDescriptions() + rs := make([]any, 0) for rows.Next() { val, rowErr := rows.Values() if rowErr != nil { return nil, fmt.Errorf("error reading result '%v': %w", rows.Err(), rowErr) } - rs = append(rs, val) //nolint:asasalint + + r := map[string]interface{}{} + for i, col := range cols { + r[string(col.Name)] = val[i] + } + + rs = append(rs, r) //nolint:asasalint } result, err = json.Marshal(rs)