dex/storage/ent/db/oauth2client_query.go

907 lines
24 KiB
Go
Raw Normal View History

// Code generated by entc, DO NOT EDIT.
package db
import (
"context"
"errors"
"fmt"
"math"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/dexidp/dex/storage/ent/db/oauth2client"
"github.com/dexidp/dex/storage/ent/db/predicate"
)
// OAuth2ClientQuery is the builder for querying OAuth2Client entities.
type OAuth2ClientQuery struct {
config
limit *int
offset *int
unique *bool
order []OrderFunc
fields []string
predicates []predicate.OAuth2Client
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
}
// Where adds a new predicate for the OAuth2ClientQuery builder.
func (oq *OAuth2ClientQuery) Where(ps ...predicate.OAuth2Client) *OAuth2ClientQuery {
oq.predicates = append(oq.predicates, ps...)
return oq
}
// Limit adds a limit step to the query.
func (oq *OAuth2ClientQuery) Limit(limit int) *OAuth2ClientQuery {
oq.limit = &limit
return oq
}
// Offset adds an offset step to the query.
func (oq *OAuth2ClientQuery) Offset(offset int) *OAuth2ClientQuery {
oq.offset = &offset
return oq
}
// 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 (oq *OAuth2ClientQuery) Unique(unique bool) *OAuth2ClientQuery {
oq.unique = &unique
return oq
}
// Order adds an order step to the query.
func (oq *OAuth2ClientQuery) Order(o ...OrderFunc) *OAuth2ClientQuery {
oq.order = append(oq.order, o...)
return oq
}
// First returns the first OAuth2Client entity from the query.
// Returns a *NotFoundError when no OAuth2Client was found.
func (oq *OAuth2ClientQuery) First(ctx context.Context) (*OAuth2Client, error) {
nodes, err := oq.Limit(1).All(ctx)
if err != nil {
return nil, err
}
if len(nodes) == 0 {
return nil, &NotFoundError{oauth2client.Label}
}
return nodes[0], nil
}
// FirstX is like First, but panics if an error occurs.
func (oq *OAuth2ClientQuery) FirstX(ctx context.Context) *OAuth2Client {
node, err := oq.First(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return node
}
// FirstID returns the first OAuth2Client ID from the query.
// Returns a *NotFoundError when no OAuth2Client ID was found.
func (oq *OAuth2ClientQuery) FirstID(ctx context.Context) (id string, err error) {
var ids []string
if ids, err = oq.Limit(1).IDs(ctx); err != nil {
return
}
if len(ids) == 0 {
err = &NotFoundError{oauth2client.Label}
return
}
return ids[0], nil
}
// FirstIDX is like FirstID, but panics if an error occurs.
func (oq *OAuth2ClientQuery) FirstIDX(ctx context.Context) string {
id, err := oq.FirstID(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return id
}
// Only returns a single OAuth2Client entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when exactly one OAuth2Client entity is not found.
// Returns a *NotFoundError when no OAuth2Client entities are found.
func (oq *OAuth2ClientQuery) Only(ctx context.Context) (*OAuth2Client, error) {
nodes, err := oq.Limit(2).All(ctx)
if err != nil {
return nil, err
}
switch len(nodes) {
case 1:
return nodes[0], nil
case 0:
return nil, &NotFoundError{oauth2client.Label}
default:
return nil, &NotSingularError{oauth2client.Label}
}
}
// OnlyX is like Only, but panics if an error occurs.
func (oq *OAuth2ClientQuery) OnlyX(ctx context.Context) *OAuth2Client {
node, err := oq.Only(ctx)
if err != nil {
panic(err)
}
return node
}
// OnlyID is like Only, but returns the only OAuth2Client ID in the query.
// Returns a *NotSingularError when exactly one OAuth2Client ID is not found.
// Returns a *NotFoundError when no entities are found.
func (oq *OAuth2ClientQuery) OnlyID(ctx context.Context) (id string, err error) {
var ids []string
if ids, err = oq.Limit(2).IDs(ctx); err != nil {
return
}
switch len(ids) {
case 1:
id = ids[0]
case 0:
err = &NotFoundError{oauth2client.Label}
default:
err = &NotSingularError{oauth2client.Label}
}
return
}
// OnlyIDX is like OnlyID, but panics if an error occurs.
func (oq *OAuth2ClientQuery) OnlyIDX(ctx context.Context) string {
id, err := oq.OnlyID(ctx)
if err != nil {
panic(err)
}
return id
}
// All executes the query and returns a list of OAuth2Clients.
func (oq *OAuth2ClientQuery) All(ctx context.Context) ([]*OAuth2Client, error) {
if err := oq.prepareQuery(ctx); err != nil {
return nil, err
}
return oq.sqlAll(ctx)
}
// AllX is like All, but panics if an error occurs.
func (oq *OAuth2ClientQuery) AllX(ctx context.Context) []*OAuth2Client {
nodes, err := oq.All(ctx)
if err != nil {
panic(err)
}
return nodes
}
// IDs executes the query and returns a list of OAuth2Client IDs.
func (oq *OAuth2ClientQuery) IDs(ctx context.Context) ([]string, error) {
var ids []string
if err := oq.Select(oauth2client.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
return ids, nil
}
// IDsX is like IDs, but panics if an error occurs.
func (oq *OAuth2ClientQuery) IDsX(ctx context.Context) []string {
ids, err := oq.IDs(ctx)
if err != nil {
panic(err)
}
return ids
}
// Count returns the count of the given query.
func (oq *OAuth2ClientQuery) Count(ctx context.Context) (int, error) {
if err := oq.prepareQuery(ctx); err != nil {
return 0, err
}
return oq.sqlCount(ctx)
}
// CountX is like Count, but panics if an error occurs.
func (oq *OAuth2ClientQuery) CountX(ctx context.Context) int {
count, err := oq.Count(ctx)
if err != nil {
panic(err)
}
return count
}
// Exist returns true if the query has elements in the graph.
func (oq *OAuth2ClientQuery) Exist(ctx context.Context) (bool, error) {
if err := oq.prepareQuery(ctx); err != nil {
return false, err
}
return oq.sqlExist(ctx)
}
// ExistX is like Exist, but panics if an error occurs.
func (oq *OAuth2ClientQuery) ExistX(ctx context.Context) bool {
exist, err := oq.Exist(ctx)
if err != nil {
panic(err)
}
return exist
}
// Clone returns a duplicate of the OAuth2ClientQuery builder, including all associated steps. It can be
// used to prepare common query builders and use them differently after the clone is made.
func (oq *OAuth2ClientQuery) Clone() *OAuth2ClientQuery {
if oq == nil {
return nil
}
return &OAuth2ClientQuery{
config: oq.config,
limit: oq.limit,
offset: oq.offset,
order: append([]OrderFunc{}, oq.order...),
predicates: append([]predicate.OAuth2Client{}, oq.predicates...),
// clone intermediate query.
sql: oq.sql.Clone(),
path: oq.path,
}
}
// 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 {
// Secret string `json:"secret,omitempty"`
// Count int `json:"count,omitempty"`
// }
//
// client.OAuth2Client.Query().
// GroupBy(oauth2client.FieldSecret).
// Aggregate(db.Count()).
// Scan(ctx, &v)
//
func (oq *OAuth2ClientQuery) GroupBy(field string, fields ...string) *OAuth2ClientGroupBy {
group := &OAuth2ClientGroupBy{config: oq.config}
group.fields = append([]string{field}, fields...)
group.path = func(ctx context.Context) (prev *sql.Selector, err error) {
if err := oq.prepareQuery(ctx); err != nil {
return nil, err
}
return oq.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 {
// Secret string `json:"secret,omitempty"`
// }
//
// client.OAuth2Client.Query().
// Select(oauth2client.FieldSecret).
// Scan(ctx, &v)
//
func (oq *OAuth2ClientQuery) Select(field string, fields ...string) *OAuth2ClientSelect {
oq.fields = append([]string{field}, fields...)
return &OAuth2ClientSelect{OAuth2ClientQuery: oq}
}
func (oq *OAuth2ClientQuery) prepareQuery(ctx context.Context) error {
for _, f := range oq.fields {
if !oauth2client.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)}
}
}
if oq.path != nil {
prev, err := oq.path(ctx)
if err != nil {
return err
}
oq.sql = prev
}
return nil
}
func (oq *OAuth2ClientQuery) sqlAll(ctx context.Context) ([]*OAuth2Client, error) {
var (
nodes = []*OAuth2Client{}
_spec = oq.querySpec()
)
_spec.ScanValues = func(columns []string) ([]interface{}, error) {
node := &OAuth2Client{config: oq.config}
nodes = append(nodes, node)
return node.scanValues(columns)
}
_spec.Assign = func(columns []string, values []interface{}) error {
if len(nodes) == 0 {
return fmt.Errorf("db: Assign called without calling ScanValues")
}
node := nodes[len(nodes)-1]
return node.assignValues(columns, values)
}
if err := sqlgraph.QueryNodes(ctx, oq.driver, _spec); err != nil {
return nil, err
}
if len(nodes) == 0 {
return nodes, nil
}
return nodes, nil
}
func (oq *OAuth2ClientQuery) sqlCount(ctx context.Context) (int, error) {
_spec := oq.querySpec()
return sqlgraph.CountNodes(ctx, oq.driver, _spec)
}
func (oq *OAuth2ClientQuery) sqlExist(ctx context.Context) (bool, error) {
n, err := oq.sqlCount(ctx)
if err != nil {
return false, fmt.Errorf("db: check existence: %w", err)
}
return n > 0, nil
}
func (oq *OAuth2ClientQuery) querySpec() *sqlgraph.QuerySpec {
_spec := &sqlgraph.QuerySpec{
Node: &sqlgraph.NodeSpec{
Table: oauth2client.Table,
Columns: oauth2client.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeString,
Column: oauth2client.FieldID,
},
},
From: oq.sql,
Unique: true,
}
if unique := oq.unique; unique != nil {
_spec.Unique = *unique
}
if fields := oq.fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, oauth2client.FieldID)
for i := range fields {
if fields[i] != oauth2client.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
}
}
}
if ps := oq.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if limit := oq.limit; limit != nil {
_spec.Limit = *limit
}
if offset := oq.offset; offset != nil {
_spec.Offset = *offset
}
if ps := oq.order; len(ps) > 0 {
_spec.Order = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
return _spec
}
func (oq *OAuth2ClientQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(oq.driver.Dialect())
t1 := builder.Table(oauth2client.Table)
selector := builder.Select(t1.Columns(oauth2client.Columns...)...).From(t1)
if oq.sql != nil {
selector = oq.sql
selector.Select(selector.Columns(oauth2client.Columns...)...)
}
for _, p := range oq.predicates {
p(selector)
}
for _, p := range oq.order {
p(selector)
}
if offset := oq.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 := oq.limit; limit != nil {
selector.Limit(*limit)
}
return selector
}
// OAuth2ClientGroupBy is the group-by builder for OAuth2Client entities.
type OAuth2ClientGroupBy 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 (ogb *OAuth2ClientGroupBy) Aggregate(fns ...AggregateFunc) *OAuth2ClientGroupBy {
ogb.fns = append(ogb.fns, fns...)
return ogb
}
// Scan applies the group-by query and scans the result into the given value.
func (ogb *OAuth2ClientGroupBy) Scan(ctx context.Context, v interface{}) error {
query, err := ogb.path(ctx)
if err != nil {
return err
}
ogb.sql = query
return ogb.sqlScan(ctx, v)
}
// ScanX is like Scan, but panics if an error occurs.
func (ogb *OAuth2ClientGroupBy) ScanX(ctx context.Context, v interface{}) {
if err := ogb.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 (ogb *OAuth2ClientGroupBy) Strings(ctx context.Context) ([]string, error) {
if len(ogb.fields) > 1 {
return nil, errors.New("db: OAuth2ClientGroupBy.Strings is not achievable when grouping more than 1 field")
}
var v []string
if err := ogb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// StringsX is like Strings, but panics if an error occurs.
func (ogb *OAuth2ClientGroupBy) StringsX(ctx context.Context) []string {
v, err := ogb.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 (ogb *OAuth2ClientGroupBy) String(ctx context.Context) (_ string, err error) {
var v []string
if v, err = ogb.Strings(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{oauth2client.Label}
default:
err = fmt.Errorf("db: OAuth2ClientGroupBy.Strings returned %d results when one was expected", len(v))
}
return
}
// StringX is like String, but panics if an error occurs.
func (ogb *OAuth2ClientGroupBy) StringX(ctx context.Context) string {
v, err := ogb.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 (ogb *OAuth2ClientGroupBy) Ints(ctx context.Context) ([]int, error) {
if len(ogb.fields) > 1 {
return nil, errors.New("db: OAuth2ClientGroupBy.Ints is not achievable when grouping more than 1 field")
}
var v []int
if err := ogb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// IntsX is like Ints, but panics if an error occurs.
func (ogb *OAuth2ClientGroupBy) IntsX(ctx context.Context) []int {
v, err := ogb.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 (ogb *OAuth2ClientGroupBy) Int(ctx context.Context) (_ int, err error) {
var v []int
if v, err = ogb.Ints(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{oauth2client.Label}
default:
err = fmt.Errorf("db: OAuth2ClientGroupBy.Ints returned %d results when one was expected", len(v))
}
return
}
// IntX is like Int, but panics if an error occurs.
func (ogb *OAuth2ClientGroupBy) IntX(ctx context.Context) int {
v, err := ogb.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 (ogb *OAuth2ClientGroupBy) Float64s(ctx context.Context) ([]float64, error) {
if len(ogb.fields) > 1 {
return nil, errors.New("db: OAuth2ClientGroupBy.Float64s is not achievable when grouping more than 1 field")
}
var v []float64
if err := ogb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// Float64sX is like Float64s, but panics if an error occurs.
func (ogb *OAuth2ClientGroupBy) Float64sX(ctx context.Context) []float64 {
v, err := ogb.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 (ogb *OAuth2ClientGroupBy) Float64(ctx context.Context) (_ float64, err error) {
var v []float64
if v, err = ogb.Float64s(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{oauth2client.Label}
default:
err = fmt.Errorf("db: OAuth2ClientGroupBy.Float64s returned %d results when one was expected", len(v))
}
return
}
// Float64X is like Float64, but panics if an error occurs.
func (ogb *OAuth2ClientGroupBy) Float64X(ctx context.Context) float64 {
v, err := ogb.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 (ogb *OAuth2ClientGroupBy) Bools(ctx context.Context) ([]bool, error) {
if len(ogb.fields) > 1 {
return nil, errors.New("db: OAuth2ClientGroupBy.Bools is not achievable when grouping more than 1 field")
}
var v []bool
if err := ogb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// BoolsX is like Bools, but panics if an error occurs.
func (ogb *OAuth2ClientGroupBy) BoolsX(ctx context.Context) []bool {
v, err := ogb.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 (ogb *OAuth2ClientGroupBy) Bool(ctx context.Context) (_ bool, err error) {
var v []bool
if v, err = ogb.Bools(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{oauth2client.Label}
default:
err = fmt.Errorf("db: OAuth2ClientGroupBy.Bools returned %d results when one was expected", len(v))
}
return
}
// BoolX is like Bool, but panics if an error occurs.
func (ogb *OAuth2ClientGroupBy) BoolX(ctx context.Context) bool {
v, err := ogb.Bool(ctx)
if err != nil {
panic(err)
}
return v
}
func (ogb *OAuth2ClientGroupBy) sqlScan(ctx context.Context, v interface{}) error {
for _, f := range ogb.fields {
if !oauth2client.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)}
}
}
selector := ogb.sqlQuery()
if err := selector.Err(); err != nil {
return err
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := ogb.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
func (ogb *OAuth2ClientGroupBy) sqlQuery() *sql.Selector {
selector := ogb.sql
columns := make([]string, 0, len(ogb.fields)+len(ogb.fns))
columns = append(columns, ogb.fields...)
for _, fn := range ogb.fns {
columns = append(columns, fn(selector))
}
return selector.Select(columns...).GroupBy(ogb.fields...)
}
// OAuth2ClientSelect is the builder for selecting fields of OAuth2Client entities.
type OAuth2ClientSelect struct {
*OAuth2ClientQuery
// intermediate query (i.e. traversal path).
sql *sql.Selector
}
// Scan applies the selector query and scans the result into the given value.
func (os *OAuth2ClientSelect) Scan(ctx context.Context, v interface{}) error {
if err := os.prepareQuery(ctx); err != nil {
return err
}
os.sql = os.OAuth2ClientQuery.sqlQuery(ctx)
return os.sqlScan(ctx, v)
}
// ScanX is like Scan, but panics if an error occurs.
func (os *OAuth2ClientSelect) ScanX(ctx context.Context, v interface{}) {
if err := os.Scan(ctx, v); err != nil {
panic(err)
}
}
// Strings returns list of strings from a selector. It is only allowed when selecting one field.
func (os *OAuth2ClientSelect) Strings(ctx context.Context) ([]string, error) {
if len(os.fields) > 1 {
return nil, errors.New("db: OAuth2ClientSelect.Strings is not achievable when selecting more than 1 field")
}
var v []string
if err := os.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// StringsX is like Strings, but panics if an error occurs.
func (os *OAuth2ClientSelect) StringsX(ctx context.Context) []string {
v, err := os.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 (os *OAuth2ClientSelect) String(ctx context.Context) (_ string, err error) {
var v []string
if v, err = os.Strings(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{oauth2client.Label}
default:
err = fmt.Errorf("db: OAuth2ClientSelect.Strings returned %d results when one was expected", len(v))
}
return
}
// StringX is like String, but panics if an error occurs.
func (os *OAuth2ClientSelect) StringX(ctx context.Context) string {
v, err := os.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 (os *OAuth2ClientSelect) Ints(ctx context.Context) ([]int, error) {
if len(os.fields) > 1 {
return nil, errors.New("db: OAuth2ClientSelect.Ints is not achievable when selecting more than 1 field")
}
var v []int
if err := os.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// IntsX is like Ints, but panics if an error occurs.
func (os *OAuth2ClientSelect) IntsX(ctx context.Context) []int {
v, err := os.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 (os *OAuth2ClientSelect) Int(ctx context.Context) (_ int, err error) {
var v []int
if v, err = os.Ints(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{oauth2client.Label}
default:
err = fmt.Errorf("db: OAuth2ClientSelect.Ints returned %d results when one was expected", len(v))
}
return
}
// IntX is like Int, but panics if an error occurs.
func (os *OAuth2ClientSelect) IntX(ctx context.Context) int {
v, err := os.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 (os *OAuth2ClientSelect) Float64s(ctx context.Context) ([]float64, error) {
if len(os.fields) > 1 {
return nil, errors.New("db: OAuth2ClientSelect.Float64s is not achievable when selecting more than 1 field")
}
var v []float64
if err := os.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// Float64sX is like Float64s, but panics if an error occurs.
func (os *OAuth2ClientSelect) Float64sX(ctx context.Context) []float64 {
v, err := os.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 (os *OAuth2ClientSelect) Float64(ctx context.Context) (_ float64, err error) {
var v []float64
if v, err = os.Float64s(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{oauth2client.Label}
default:
err = fmt.Errorf("db: OAuth2ClientSelect.Float64s returned %d results when one was expected", len(v))
}
return
}
// Float64X is like Float64, but panics if an error occurs.
func (os *OAuth2ClientSelect) Float64X(ctx context.Context) float64 {
v, err := os.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 (os *OAuth2ClientSelect) Bools(ctx context.Context) ([]bool, error) {
if len(os.fields) > 1 {
return nil, errors.New("db: OAuth2ClientSelect.Bools is not achievable when selecting more than 1 field")
}
var v []bool
if err := os.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// BoolsX is like Bools, but panics if an error occurs.
func (os *OAuth2ClientSelect) BoolsX(ctx context.Context) []bool {
v, err := os.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 (os *OAuth2ClientSelect) Bool(ctx context.Context) (_ bool, err error) {
var v []bool
if v, err = os.Bools(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{oauth2client.Label}
default:
err = fmt.Errorf("db: OAuth2ClientSelect.Bools returned %d results when one was expected", len(v))
}
return
}
// BoolX is like Bool, but panics if an error occurs.
func (os *OAuth2ClientSelect) BoolX(ctx context.Context) bool {
v, err := os.Bool(ctx)
if err != nil {
panic(err)
}
return v
}
func (os *OAuth2ClientSelect) sqlScan(ctx context.Context, v interface{}) error {
rows := &sql.Rows{}
query, args := os.sqlQuery().Query()
if err := os.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
func (os *OAuth2ClientSelect) sqlQuery() sql.Querier {
selector := os.sql
selector.Select(selector.Columns(os.fields...)...)
return selector
}