// Code generated by entc, DO NOT EDIT. package ent import ( "context" "errors" "fmt" "math" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/oceanbase/configserver/ent/obcluster" "github.com/oceanbase/configserver/ent/predicate" ) // ObClusterQuery is the builder for querying ObCluster entities. type ObClusterQuery struct { config limit *int offset *int unique *bool order []OrderFunc fields []string predicates []predicate.ObCluster // intermediate query (i.e. traversal path). sql *sql.Selector path func(context.Context) (*sql.Selector, error) } // Where adds a new predicate for the ObClusterQuery builder. func (ocq *ObClusterQuery) Where(ps ...predicate.ObCluster) *ObClusterQuery { ocq.predicates = append(ocq.predicates, ps...) return ocq } // Limit adds a limit step to the query. func (ocq *ObClusterQuery) Limit(limit int) *ObClusterQuery { ocq.limit = &limit return ocq } // Offset adds an offset step to the query. func (ocq *ObClusterQuery) Offset(offset int) *ObClusterQuery { ocq.offset = &offset return ocq } // Unique configures the query builder to filter duplicate records on query. // By default, unique is set to true, and can be disabled using this method. func (ocq *ObClusterQuery) Unique(unique bool) *ObClusterQuery { ocq.unique = &unique return ocq } // Order adds an order step to the query. func (ocq *ObClusterQuery) Order(o ...OrderFunc) *ObClusterQuery { ocq.order = append(ocq.order, o...) return ocq } // First returns the first ObCluster entity from the query. // Returns a *NotFoundError when no ObCluster was found. func (ocq *ObClusterQuery) First(ctx context.Context) (*ObCluster, error) { nodes, err := ocq.Limit(1).All(ctx) if err != nil { return nil, err } if len(nodes) == 0 { return nil, &NotFoundError{obcluster.Label} } return nodes[0], nil } // FirstX is like First, but panics if an error occurs. func (ocq *ObClusterQuery) FirstX(ctx context.Context) *ObCluster { node, err := ocq.First(ctx) if err != nil && !IsNotFound(err) { panic(err) } return node } // FirstID returns the first ObCluster ID from the query. // Returns a *NotFoundError when no ObCluster ID was found. func (ocq *ObClusterQuery) FirstID(ctx context.Context) (id int, err error) { var ids []int if ids, err = ocq.Limit(1).IDs(ctx); err != nil { return } if len(ids) == 0 { err = &NotFoundError{obcluster.Label} return } return ids[0], nil } // FirstIDX is like FirstID, but panics if an error occurs. func (ocq *ObClusterQuery) FirstIDX(ctx context.Context) int { id, err := ocq.FirstID(ctx) if err != nil && !IsNotFound(err) { panic(err) } return id } // Only returns a single ObCluster entity found by the query, ensuring it only returns one. // Returns a *NotSingularError when more than one ObCluster entity is found. // Returns a *NotFoundError when no ObCluster entities are found. func (ocq *ObClusterQuery) Only(ctx context.Context) (*ObCluster, error) { nodes, err := ocq.Limit(2).All(ctx) if err != nil { return nil, err } switch len(nodes) { case 1: return nodes[0], nil case 0: return nil, &NotFoundError{obcluster.Label} default: return nil, &NotSingularError{obcluster.Label} } } // OnlyX is like Only, but panics if an error occurs. func (ocq *ObClusterQuery) OnlyX(ctx context.Context) *ObCluster { node, err := ocq.Only(ctx) if err != nil { panic(err) } return node } // OnlyID is like Only, but returns the only ObCluster ID in the query. // Returns a *NotSingularError when more than one ObCluster ID is found. // Returns a *NotFoundError when no entities are found. func (ocq *ObClusterQuery) OnlyID(ctx context.Context) (id int, err error) { var ids []int if ids, err = ocq.Limit(2).IDs(ctx); err != nil { return } switch len(ids) { case 1: id = ids[0] case 0: err = &NotFoundError{obcluster.Label} default: err = &NotSingularError{obcluster.Label} } return } // OnlyIDX is like OnlyID, but panics if an error occurs. func (ocq *ObClusterQuery) OnlyIDX(ctx context.Context) int { id, err := ocq.OnlyID(ctx) if err != nil { panic(err) } return id } // All executes the query and returns a list of ObClusters. func (ocq *ObClusterQuery) All(ctx context.Context) ([]*ObCluster, error) { if err := ocq.prepareQuery(ctx); err != nil { return nil, err } return ocq.sqlAll(ctx) } // AllX is like All, but panics if an error occurs. func (ocq *ObClusterQuery) AllX(ctx context.Context) []*ObCluster { nodes, err := ocq.All(ctx) if err != nil { panic(err) } return nodes } // IDs executes the query and returns a list of ObCluster IDs. func (ocq *ObClusterQuery) IDs(ctx context.Context) ([]int, error) { var ids []int if err := ocq.Select(obcluster.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil } // IDsX is like IDs, but panics if an error occurs. func (ocq *ObClusterQuery) IDsX(ctx context.Context) []int { ids, err := ocq.IDs(ctx) if err != nil { panic(err) } return ids } // Count returns the count of the given query. func (ocq *ObClusterQuery) Count(ctx context.Context) (int, error) { if err := ocq.prepareQuery(ctx); err != nil { return 0, err } return ocq.sqlCount(ctx) } // CountX is like Count, but panics if an error occurs. func (ocq *ObClusterQuery) CountX(ctx context.Context) int { count, err := ocq.Count(ctx) if err != nil { panic(err) } return count } // Exist returns true if the query has elements in the graph. func (ocq *ObClusterQuery) Exist(ctx context.Context) (bool, error) { if err := ocq.prepareQuery(ctx); err != nil { return false, err } return ocq.sqlExist(ctx) } // ExistX is like Exist, but panics if an error occurs. func (ocq *ObClusterQuery) ExistX(ctx context.Context) bool { exist, err := ocq.Exist(ctx) if err != nil { panic(err) } return exist } // Clone returns a duplicate of the ObClusterQuery builder, including all associated steps. It can be // used to prepare common query builders and use them differently after the clone is made. func (ocq *ObClusterQuery) Clone() *ObClusterQuery { if ocq == nil { return nil } return &ObClusterQuery{ config: ocq.config, limit: ocq.limit, offset: ocq.offset, order: append([]OrderFunc{}, ocq.order...), predicates: append([]predicate.ObCluster{}, ocq.predicates...), // clone intermediate query. sql: ocq.sql.Clone(), path: ocq.path, unique: ocq.unique, } } // GroupBy is used to group vertices by one or more fields/columns. // It is often used with aggregate functions, like: count, max, mean, min, sum. // // Example: // // var v []struct { // CreateTime time.Time `json:"create_time,omitempty"` // Count int `json:"count,omitempty"` // } // // client.ObCluster.Query(). // GroupBy(obcluster.FieldCreateTime). // Aggregate(ent.Count()). // Scan(ctx, &v) // func (ocq *ObClusterQuery) GroupBy(field string, fields ...string) *ObClusterGroupBy { group := &ObClusterGroupBy{config: ocq.config} group.fields = append([]string{field}, fields...) group.path = func(ctx context.Context) (prev *sql.Selector, err error) { if err := ocq.prepareQuery(ctx); err != nil { return nil, err } return ocq.sqlQuery(ctx), nil } return group } // Select allows the selection one or more fields/columns for the given query, // instead of selecting all fields in the entity. // // Example: // // var v []struct { // CreateTime time.Time `json:"create_time,omitempty"` // } // // client.ObCluster.Query(). // Select(obcluster.FieldCreateTime). // Scan(ctx, &v) // func (ocq *ObClusterQuery) Select(fields ...string) *ObClusterSelect { ocq.fields = append(ocq.fields, fields...) return &ObClusterSelect{ObClusterQuery: ocq} } func (ocq *ObClusterQuery) prepareQuery(ctx context.Context) error { for _, f := range ocq.fields { if !obcluster.ValidColumn(f) { return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} } } if ocq.path != nil { prev, err := ocq.path(ctx) if err != nil { return err } ocq.sql = prev } return nil } func (ocq *ObClusterQuery) sqlAll(ctx context.Context) ([]*ObCluster, error) { var ( nodes = []*ObCluster{} _spec = ocq.querySpec() ) _spec.ScanValues = func(columns []string) ([]interface{}, error) { node := &ObCluster{config: ocq.config} nodes = append(nodes, node) return node.scanValues(columns) } _spec.Assign = func(columns []string, values []interface{}) error { if len(nodes) == 0 { return fmt.Errorf("ent: Assign called without calling ScanValues") } node := nodes[len(nodes)-1] return node.assignValues(columns, values) } if err := sqlgraph.QueryNodes(ctx, ocq.driver, _spec); err != nil { return nil, err } if len(nodes) == 0 { return nodes, nil } return nodes, nil } func (ocq *ObClusterQuery) sqlCount(ctx context.Context) (int, error) { _spec := ocq.querySpec() _spec.Node.Columns = ocq.fields if len(ocq.fields) > 0 { _spec.Unique = ocq.unique != nil && *ocq.unique } return sqlgraph.CountNodes(ctx, ocq.driver, _spec) } func (ocq *ObClusterQuery) sqlExist(ctx context.Context) (bool, error) { n, err := ocq.sqlCount(ctx) if err != nil { return false, fmt.Errorf("ent: check existence: %w", err) } return n > 0, nil } func (ocq *ObClusterQuery) querySpec() *sqlgraph.QuerySpec { _spec := &sqlgraph.QuerySpec{ Node: &sqlgraph.NodeSpec{ Table: obcluster.Table, Columns: obcluster.Columns, ID: &sqlgraph.FieldSpec{ Type: field.TypeInt, Column: obcluster.FieldID, }, }, From: ocq.sql, Unique: true, } if unique := ocq.unique; unique != nil { _spec.Unique = *unique } if fields := ocq.fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, obcluster.FieldID) for i := range fields { if fields[i] != obcluster.FieldID { _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) } } } if ps := ocq.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } if limit := ocq.limit; limit != nil { _spec.Limit = *limit } if offset := ocq.offset; offset != nil { _spec.Offset = *offset } if ps := ocq.order; len(ps) > 0 { _spec.Order = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } return _spec } func (ocq *ObClusterQuery) sqlQuery(ctx context.Context) *sql.Selector { builder := sql.Dialect(ocq.driver.Dialect()) t1 := builder.Table(obcluster.Table) columns := ocq.fields if len(columns) == 0 { columns = obcluster.Columns } selector := builder.Select(t1.Columns(columns...)...).From(t1) if ocq.sql != nil { selector = ocq.sql selector.Select(selector.Columns(columns...)...) } if ocq.unique != nil && *ocq.unique { selector.Distinct() } for _, p := range ocq.predicates { p(selector) } for _, p := range ocq.order { p(selector) } if offset := ocq.offset; offset != nil { // limit is mandatory for offset clause. We start // with default value, and override it below if needed. selector.Offset(*offset).Limit(math.MaxInt32) } if limit := ocq.limit; limit != nil { selector.Limit(*limit) } return selector } // ObClusterGroupBy is the group-by builder for ObCluster entities. type ObClusterGroupBy struct { config fields []string fns []AggregateFunc // intermediate query (i.e. traversal path). sql *sql.Selector path func(context.Context) (*sql.Selector, error) } // Aggregate adds the given aggregation functions to the group-by query. func (ocgb *ObClusterGroupBy) Aggregate(fns ...AggregateFunc) *ObClusterGroupBy { ocgb.fns = append(ocgb.fns, fns...) return ocgb } // Scan applies the group-by query and scans the result into the given value. func (ocgb *ObClusterGroupBy) Scan(ctx context.Context, v interface{}) error { query, err := ocgb.path(ctx) if err != nil { return err } ocgb.sql = query return ocgb.sqlScan(ctx, v) } // ScanX is like Scan, but panics if an error occurs. func (ocgb *ObClusterGroupBy) ScanX(ctx context.Context, v interface{}) { if err := ocgb.Scan(ctx, v); err != nil { panic(err) } } // Strings returns list of strings from group-by. // It is only allowed when executing a group-by query with one field. func (ocgb *ObClusterGroupBy) Strings(ctx context.Context) ([]string, error) { if len(ocgb.fields) > 1 { return nil, errors.New("ent: ObClusterGroupBy.Strings is not achievable when grouping more than 1 field") } var v []string if err := ocgb.Scan(ctx, &v); err != nil { return nil, err } return v, nil } // StringsX is like Strings, but panics if an error occurs. func (ocgb *ObClusterGroupBy) StringsX(ctx context.Context) []string { v, err := ocgb.Strings(ctx) if err != nil { panic(err) } return v } // String returns a single string from a group-by query. // It is only allowed when executing a group-by query with one field. func (ocgb *ObClusterGroupBy) String(ctx context.Context) (_ string, err error) { var v []string if v, err = ocgb.Strings(ctx); err != nil { return } switch len(v) { case 1: return v[0], nil case 0: err = &NotFoundError{obcluster.Label} default: err = fmt.Errorf("ent: ObClusterGroupBy.Strings returned %d results when one was expected", len(v)) } return } // StringX is like String, but panics if an error occurs. func (ocgb *ObClusterGroupBy) StringX(ctx context.Context) string { v, err := ocgb.String(ctx) if err != nil { panic(err) } return v } // Ints returns list of ints from group-by. // It is only allowed when executing a group-by query with one field. func (ocgb *ObClusterGroupBy) Ints(ctx context.Context) ([]int, error) { if len(ocgb.fields) > 1 { return nil, errors.New("ent: ObClusterGroupBy.Ints is not achievable when grouping more than 1 field") } var v []int if err := ocgb.Scan(ctx, &v); err != nil { return nil, err } return v, nil } // IntsX is like Ints, but panics if an error occurs. func (ocgb *ObClusterGroupBy) IntsX(ctx context.Context) []int { v, err := ocgb.Ints(ctx) if err != nil { panic(err) } return v } // Int returns a single int from a group-by query. // It is only allowed when executing a group-by query with one field. func (ocgb *ObClusterGroupBy) Int(ctx context.Context) (_ int, err error) { var v []int if v, err = ocgb.Ints(ctx); err != nil { return } switch len(v) { case 1: return v[0], nil case 0: err = &NotFoundError{obcluster.Label} default: err = fmt.Errorf("ent: ObClusterGroupBy.Ints returned %d results when one was expected", len(v)) } return } // IntX is like Int, but panics if an error occurs. func (ocgb *ObClusterGroupBy) IntX(ctx context.Context) int { v, err := ocgb.Int(ctx) if err != nil { panic(err) } return v } // Float64s returns list of float64s from group-by. // It is only allowed when executing a group-by query with one field. func (ocgb *ObClusterGroupBy) Float64s(ctx context.Context) ([]float64, error) { if len(ocgb.fields) > 1 { return nil, errors.New("ent: ObClusterGroupBy.Float64s is not achievable when grouping more than 1 field") } var v []float64 if err := ocgb.Scan(ctx, &v); err != nil { return nil, err } return v, nil } // Float64sX is like Float64s, but panics if an error occurs. func (ocgb *ObClusterGroupBy) Float64sX(ctx context.Context) []float64 { v, err := ocgb.Float64s(ctx) if err != nil { panic(err) } return v } // Float64 returns a single float64 from a group-by query. // It is only allowed when executing a group-by query with one field. func (ocgb *ObClusterGroupBy) Float64(ctx context.Context) (_ float64, err error) { var v []float64 if v, err = ocgb.Float64s(ctx); err != nil { return } switch len(v) { case 1: return v[0], nil case 0: err = &NotFoundError{obcluster.Label} default: err = fmt.Errorf("ent: ObClusterGroupBy.Float64s returned %d results when one was expected", len(v)) } return } // Float64X is like Float64, but panics if an error occurs. func (ocgb *ObClusterGroupBy) Float64X(ctx context.Context) float64 { v, err := ocgb.Float64(ctx) if err != nil { panic(err) } return v } // Bools returns list of bools from group-by. // It is only allowed when executing a group-by query with one field. func (ocgb *ObClusterGroupBy) Bools(ctx context.Context) ([]bool, error) { if len(ocgb.fields) > 1 { return nil, errors.New("ent: ObClusterGroupBy.Bools is not achievable when grouping more than 1 field") } var v []bool if err := ocgb.Scan(ctx, &v); err != nil { return nil, err } return v, nil } // BoolsX is like Bools, but panics if an error occurs. func (ocgb *ObClusterGroupBy) BoolsX(ctx context.Context) []bool { v, err := ocgb.Bools(ctx) if err != nil { panic(err) } return v } // Bool returns a single bool from a group-by query. // It is only allowed when executing a group-by query with one field. func (ocgb *ObClusterGroupBy) Bool(ctx context.Context) (_ bool, err error) { var v []bool if v, err = ocgb.Bools(ctx); err != nil { return } switch len(v) { case 1: return v[0], nil case 0: err = &NotFoundError{obcluster.Label} default: err = fmt.Errorf("ent: ObClusterGroupBy.Bools returned %d results when one was expected", len(v)) } return } // BoolX is like Bool, but panics if an error occurs. func (ocgb *ObClusterGroupBy) BoolX(ctx context.Context) bool { v, err := ocgb.Bool(ctx) if err != nil { panic(err) } return v } func (ocgb *ObClusterGroupBy) sqlScan(ctx context.Context, v interface{}) error { for _, f := range ocgb.fields { if !obcluster.ValidColumn(f) { return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)} } } selector := ocgb.sqlQuery() if err := selector.Err(); err != nil { return err } rows := &sql.Rows{} query, args := selector.Query() if err := ocgb.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() return sql.ScanSlice(rows, v) } func (ocgb *ObClusterGroupBy) sqlQuery() *sql.Selector { selector := ocgb.sql.Select() aggregation := make([]string, 0, len(ocgb.fns)) for _, fn := range ocgb.fns { aggregation = append(aggregation, fn(selector)) } // If no columns were selected in a custom aggregation function, the default // selection is the fields used for "group-by", and the aggregation functions. if len(selector.SelectedColumns()) == 0 { columns := make([]string, 0, len(ocgb.fields)+len(ocgb.fns)) for _, f := range ocgb.fields { columns = append(columns, selector.C(f)) } columns = append(columns, aggregation...) selector.Select(columns...) } return selector.GroupBy(selector.Columns(ocgb.fields...)...) } // ObClusterSelect is the builder for selecting fields of ObCluster entities. type ObClusterSelect struct { *ObClusterQuery // intermediate query (i.e. traversal path). sql *sql.Selector } // Scan applies the selector query and scans the result into the given value. func (ocs *ObClusterSelect) Scan(ctx context.Context, v interface{}) error { if err := ocs.prepareQuery(ctx); err != nil { return err } ocs.sql = ocs.ObClusterQuery.sqlQuery(ctx) return ocs.sqlScan(ctx, v) } // ScanX is like Scan, but panics if an error occurs. func (ocs *ObClusterSelect) ScanX(ctx context.Context, v interface{}) { if err := ocs.Scan(ctx, v); err != nil { panic(err) } } // Strings returns list of strings from a selector. It is only allowed when selecting one field. func (ocs *ObClusterSelect) Strings(ctx context.Context) ([]string, error) { if len(ocs.fields) > 1 { return nil, errors.New("ent: ObClusterSelect.Strings is not achievable when selecting more than 1 field") } var v []string if err := ocs.Scan(ctx, &v); err != nil { return nil, err } return v, nil } // StringsX is like Strings, but panics if an error occurs. func (ocs *ObClusterSelect) StringsX(ctx context.Context) []string { v, err := ocs.Strings(ctx) if err != nil { panic(err) } return v } // String returns a single string from a selector. It is only allowed when selecting one field. func (ocs *ObClusterSelect) String(ctx context.Context) (_ string, err error) { var v []string if v, err = ocs.Strings(ctx); err != nil { return } switch len(v) { case 1: return v[0], nil case 0: err = &NotFoundError{obcluster.Label} default: err = fmt.Errorf("ent: ObClusterSelect.Strings returned %d results when one was expected", len(v)) } return } // StringX is like String, but panics if an error occurs. func (ocs *ObClusterSelect) StringX(ctx context.Context) string { v, err := ocs.String(ctx) if err != nil { panic(err) } return v } // Ints returns list of ints from a selector. It is only allowed when selecting one field. func (ocs *ObClusterSelect) Ints(ctx context.Context) ([]int, error) { if len(ocs.fields) > 1 { return nil, errors.New("ent: ObClusterSelect.Ints is not achievable when selecting more than 1 field") } var v []int if err := ocs.Scan(ctx, &v); err != nil { return nil, err } return v, nil } // IntsX is like Ints, but panics if an error occurs. func (ocs *ObClusterSelect) IntsX(ctx context.Context) []int { v, err := ocs.Ints(ctx) if err != nil { panic(err) } return v } // Int returns a single int from a selector. It is only allowed when selecting one field. func (ocs *ObClusterSelect) Int(ctx context.Context) (_ int, err error) { var v []int if v, err = ocs.Ints(ctx); err != nil { return } switch len(v) { case 1: return v[0], nil case 0: err = &NotFoundError{obcluster.Label} default: err = fmt.Errorf("ent: ObClusterSelect.Ints returned %d results when one was expected", len(v)) } return } // IntX is like Int, but panics if an error occurs. func (ocs *ObClusterSelect) IntX(ctx context.Context) int { v, err := ocs.Int(ctx) if err != nil { panic(err) } return v } // Float64s returns list of float64s from a selector. It is only allowed when selecting one field. func (ocs *ObClusterSelect) Float64s(ctx context.Context) ([]float64, error) { if len(ocs.fields) > 1 { return nil, errors.New("ent: ObClusterSelect.Float64s is not achievable when selecting more than 1 field") } var v []float64 if err := ocs.Scan(ctx, &v); err != nil { return nil, err } return v, nil } // Float64sX is like Float64s, but panics if an error occurs. func (ocs *ObClusterSelect) Float64sX(ctx context.Context) []float64 { v, err := ocs.Float64s(ctx) if err != nil { panic(err) } return v } // Float64 returns a single float64 from a selector. It is only allowed when selecting one field. func (ocs *ObClusterSelect) Float64(ctx context.Context) (_ float64, err error) { var v []float64 if v, err = ocs.Float64s(ctx); err != nil { return } switch len(v) { case 1: return v[0], nil case 0: err = &NotFoundError{obcluster.Label} default: err = fmt.Errorf("ent: ObClusterSelect.Float64s returned %d results when one was expected", len(v)) } return } // Float64X is like Float64, but panics if an error occurs. func (ocs *ObClusterSelect) Float64X(ctx context.Context) float64 { v, err := ocs.Float64(ctx) if err != nil { panic(err) } return v } // Bools returns list of bools from a selector. It is only allowed when selecting one field. func (ocs *ObClusterSelect) Bools(ctx context.Context) ([]bool, error) { if len(ocs.fields) > 1 { return nil, errors.New("ent: ObClusterSelect.Bools is not achievable when selecting more than 1 field") } var v []bool if err := ocs.Scan(ctx, &v); err != nil { return nil, err } return v, nil } // BoolsX is like Bools, but panics if an error occurs. func (ocs *ObClusterSelect) BoolsX(ctx context.Context) []bool { v, err := ocs.Bools(ctx) if err != nil { panic(err) } return v } // Bool returns a single bool from a selector. It is only allowed when selecting one field. func (ocs *ObClusterSelect) Bool(ctx context.Context) (_ bool, err error) { var v []bool if v, err = ocs.Bools(ctx); err != nil { return } switch len(v) { case 1: return v[0], nil case 0: err = &NotFoundError{obcluster.Label} default: err = fmt.Errorf("ent: ObClusterSelect.Bools returned %d results when one was expected", len(v)) } return } // BoolX is like Bool, but panics if an error occurs. func (ocs *ObClusterSelect) BoolX(ctx context.Context) bool { v, err := ocs.Bool(ctx) if err != nil { panic(err) } return v } func (ocs *ObClusterSelect) sqlScan(ctx context.Context, v interface{}) error { rows := &sql.Rows{} query, args := ocs.sql.Query() if err := ocs.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() return sql.ScanSlice(rows, v) }