615 lines
19 KiB
Go
615 lines
19 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"math"
|
|
"schisandra-album-cloud-microservices/common/ent/predicate"
|
|
"schisandra-album-cloud-microservices/common/ent/scaauthuser"
|
|
"schisandra-album-cloud-microservices/common/ent/scaauthusersocial"
|
|
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
)
|
|
|
|
// ScaAuthUserSocialQuery is the builder for querying ScaAuthUserSocial entities.
|
|
type ScaAuthUserSocialQuery struct {
|
|
config
|
|
ctx *QueryContext
|
|
order []scaauthusersocial.OrderOption
|
|
inters []Interceptor
|
|
predicates []predicate.ScaAuthUserSocial
|
|
withScaAuthUser *ScaAuthUserQuery
|
|
withFKs bool
|
|
// intermediate query (i.e. traversal path).
|
|
sql *sql.Selector
|
|
path func(context.Context) (*sql.Selector, error)
|
|
}
|
|
|
|
// Where adds a new predicate for the ScaAuthUserSocialQuery builder.
|
|
func (sausq *ScaAuthUserSocialQuery) Where(ps ...predicate.ScaAuthUserSocial) *ScaAuthUserSocialQuery {
|
|
sausq.predicates = append(sausq.predicates, ps...)
|
|
return sausq
|
|
}
|
|
|
|
// Limit the number of records to be returned by this query.
|
|
func (sausq *ScaAuthUserSocialQuery) Limit(limit int) *ScaAuthUserSocialQuery {
|
|
sausq.ctx.Limit = &limit
|
|
return sausq
|
|
}
|
|
|
|
// Offset to start from.
|
|
func (sausq *ScaAuthUserSocialQuery) Offset(offset int) *ScaAuthUserSocialQuery {
|
|
sausq.ctx.Offset = &offset
|
|
return sausq
|
|
}
|
|
|
|
// 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 (sausq *ScaAuthUserSocialQuery) Unique(unique bool) *ScaAuthUserSocialQuery {
|
|
sausq.ctx.Unique = &unique
|
|
return sausq
|
|
}
|
|
|
|
// Order specifies how the records should be ordered.
|
|
func (sausq *ScaAuthUserSocialQuery) Order(o ...scaauthusersocial.OrderOption) *ScaAuthUserSocialQuery {
|
|
sausq.order = append(sausq.order, o...)
|
|
return sausq
|
|
}
|
|
|
|
// QueryScaAuthUser chains the current query on the "sca_auth_user" edge.
|
|
func (sausq *ScaAuthUserSocialQuery) QueryScaAuthUser() *ScaAuthUserQuery {
|
|
query := (&ScaAuthUserClient{config: sausq.config}).Query()
|
|
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
|
if err := sausq.prepareQuery(ctx); err != nil {
|
|
return nil, err
|
|
}
|
|
selector := sausq.sqlQuery(ctx)
|
|
if err := selector.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
step := sqlgraph.NewStep(
|
|
sqlgraph.From(scaauthusersocial.Table, scaauthusersocial.FieldID, selector),
|
|
sqlgraph.To(scaauthuser.Table, scaauthuser.FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2O, true, scaauthusersocial.ScaAuthUserTable, scaauthusersocial.ScaAuthUserColumn),
|
|
)
|
|
fromU = sqlgraph.SetNeighbors(sausq.driver.Dialect(), step)
|
|
return fromU, nil
|
|
}
|
|
return query
|
|
}
|
|
|
|
// First returns the first ScaAuthUserSocial entity from the query.
|
|
// Returns a *NotFoundError when no ScaAuthUserSocial was found.
|
|
func (sausq *ScaAuthUserSocialQuery) First(ctx context.Context) (*ScaAuthUserSocial, error) {
|
|
nodes, err := sausq.Limit(1).All(setContextOp(ctx, sausq.ctx, ent.OpQueryFirst))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if len(nodes) == 0 {
|
|
return nil, &NotFoundError{scaauthusersocial.Label}
|
|
}
|
|
return nodes[0], nil
|
|
}
|
|
|
|
// FirstX is like First, but panics if an error occurs.
|
|
func (sausq *ScaAuthUserSocialQuery) FirstX(ctx context.Context) *ScaAuthUserSocial {
|
|
node, err := sausq.First(ctx)
|
|
if err != nil && !IsNotFound(err) {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// FirstID returns the first ScaAuthUserSocial ID from the query.
|
|
// Returns a *NotFoundError when no ScaAuthUserSocial ID was found.
|
|
func (sausq *ScaAuthUserSocialQuery) FirstID(ctx context.Context) (id int64, err error) {
|
|
var ids []int64
|
|
if ids, err = sausq.Limit(1).IDs(setContextOp(ctx, sausq.ctx, ent.OpQueryFirstID)); err != nil {
|
|
return
|
|
}
|
|
if len(ids) == 0 {
|
|
err = &NotFoundError{scaauthusersocial.Label}
|
|
return
|
|
}
|
|
return ids[0], nil
|
|
}
|
|
|
|
// FirstIDX is like FirstID, but panics if an error occurs.
|
|
func (sausq *ScaAuthUserSocialQuery) FirstIDX(ctx context.Context) int64 {
|
|
id, err := sausq.FirstID(ctx)
|
|
if err != nil && !IsNotFound(err) {
|
|
panic(err)
|
|
}
|
|
return id
|
|
}
|
|
|
|
// Only returns a single ScaAuthUserSocial entity found by the query, ensuring it only returns one.
|
|
// Returns a *NotSingularError when more than one ScaAuthUserSocial entity is found.
|
|
// Returns a *NotFoundError when no ScaAuthUserSocial entities are found.
|
|
func (sausq *ScaAuthUserSocialQuery) Only(ctx context.Context) (*ScaAuthUserSocial, error) {
|
|
nodes, err := sausq.Limit(2).All(setContextOp(ctx, sausq.ctx, ent.OpQueryOnly))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
switch len(nodes) {
|
|
case 1:
|
|
return nodes[0], nil
|
|
case 0:
|
|
return nil, &NotFoundError{scaauthusersocial.Label}
|
|
default:
|
|
return nil, &NotSingularError{scaauthusersocial.Label}
|
|
}
|
|
}
|
|
|
|
// OnlyX is like Only, but panics if an error occurs.
|
|
func (sausq *ScaAuthUserSocialQuery) OnlyX(ctx context.Context) *ScaAuthUserSocial {
|
|
node, err := sausq.Only(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// OnlyID is like Only, but returns the only ScaAuthUserSocial ID in the query.
|
|
// Returns a *NotSingularError when more than one ScaAuthUserSocial ID is found.
|
|
// Returns a *NotFoundError when no entities are found.
|
|
func (sausq *ScaAuthUserSocialQuery) OnlyID(ctx context.Context) (id int64, err error) {
|
|
var ids []int64
|
|
if ids, err = sausq.Limit(2).IDs(setContextOp(ctx, sausq.ctx, ent.OpQueryOnlyID)); err != nil {
|
|
return
|
|
}
|
|
switch len(ids) {
|
|
case 1:
|
|
id = ids[0]
|
|
case 0:
|
|
err = &NotFoundError{scaauthusersocial.Label}
|
|
default:
|
|
err = &NotSingularError{scaauthusersocial.Label}
|
|
}
|
|
return
|
|
}
|
|
|
|
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
|
func (sausq *ScaAuthUserSocialQuery) OnlyIDX(ctx context.Context) int64 {
|
|
id, err := sausq.OnlyID(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return id
|
|
}
|
|
|
|
// All executes the query and returns a list of ScaAuthUserSocials.
|
|
func (sausq *ScaAuthUserSocialQuery) All(ctx context.Context) ([]*ScaAuthUserSocial, error) {
|
|
ctx = setContextOp(ctx, sausq.ctx, ent.OpQueryAll)
|
|
if err := sausq.prepareQuery(ctx); err != nil {
|
|
return nil, err
|
|
}
|
|
qr := querierAll[[]*ScaAuthUserSocial, *ScaAuthUserSocialQuery]()
|
|
return withInterceptors[[]*ScaAuthUserSocial](ctx, sausq, qr, sausq.inters)
|
|
}
|
|
|
|
// AllX is like All, but panics if an error occurs.
|
|
func (sausq *ScaAuthUserSocialQuery) AllX(ctx context.Context) []*ScaAuthUserSocial {
|
|
nodes, err := sausq.All(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return nodes
|
|
}
|
|
|
|
// IDs executes the query and returns a list of ScaAuthUserSocial IDs.
|
|
func (sausq *ScaAuthUserSocialQuery) IDs(ctx context.Context) (ids []int64, err error) {
|
|
if sausq.ctx.Unique == nil && sausq.path != nil {
|
|
sausq.Unique(true)
|
|
}
|
|
ctx = setContextOp(ctx, sausq.ctx, ent.OpQueryIDs)
|
|
if err = sausq.Select(scaauthusersocial.FieldID).Scan(ctx, &ids); err != nil {
|
|
return nil, err
|
|
}
|
|
return ids, nil
|
|
}
|
|
|
|
// IDsX is like IDs, but panics if an error occurs.
|
|
func (sausq *ScaAuthUserSocialQuery) IDsX(ctx context.Context) []int64 {
|
|
ids, err := sausq.IDs(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return ids
|
|
}
|
|
|
|
// Count returns the count of the given query.
|
|
func (sausq *ScaAuthUserSocialQuery) Count(ctx context.Context) (int, error) {
|
|
ctx = setContextOp(ctx, sausq.ctx, ent.OpQueryCount)
|
|
if err := sausq.prepareQuery(ctx); err != nil {
|
|
return 0, err
|
|
}
|
|
return withInterceptors[int](ctx, sausq, querierCount[*ScaAuthUserSocialQuery](), sausq.inters)
|
|
}
|
|
|
|
// CountX is like Count, but panics if an error occurs.
|
|
func (sausq *ScaAuthUserSocialQuery) CountX(ctx context.Context) int {
|
|
count, err := sausq.Count(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return count
|
|
}
|
|
|
|
// Exist returns true if the query has elements in the graph.
|
|
func (sausq *ScaAuthUserSocialQuery) Exist(ctx context.Context) (bool, error) {
|
|
ctx = setContextOp(ctx, sausq.ctx, ent.OpQueryExist)
|
|
switch _, err := sausq.FirstID(ctx); {
|
|
case IsNotFound(err):
|
|
return false, nil
|
|
case err != nil:
|
|
return false, fmt.Errorf("ent: check existence: %w", err)
|
|
default:
|
|
return true, nil
|
|
}
|
|
}
|
|
|
|
// ExistX is like Exist, but panics if an error occurs.
|
|
func (sausq *ScaAuthUserSocialQuery) ExistX(ctx context.Context) bool {
|
|
exist, err := sausq.Exist(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return exist
|
|
}
|
|
|
|
// Clone returns a duplicate of the ScaAuthUserSocialQuery builder, including all associated steps. It can be
|
|
// used to prepare common query builders and use them differently after the clone is made.
|
|
func (sausq *ScaAuthUserSocialQuery) Clone() *ScaAuthUserSocialQuery {
|
|
if sausq == nil {
|
|
return nil
|
|
}
|
|
return &ScaAuthUserSocialQuery{
|
|
config: sausq.config,
|
|
ctx: sausq.ctx.Clone(),
|
|
order: append([]scaauthusersocial.OrderOption{}, sausq.order...),
|
|
inters: append([]Interceptor{}, sausq.inters...),
|
|
predicates: append([]predicate.ScaAuthUserSocial{}, sausq.predicates...),
|
|
withScaAuthUser: sausq.withScaAuthUser.Clone(),
|
|
// clone intermediate query.
|
|
sql: sausq.sql.Clone(),
|
|
path: sausq.path,
|
|
}
|
|
}
|
|
|
|
// WithScaAuthUser tells the query-builder to eager-load the nodes that are connected to
|
|
// the "sca_auth_user" edge. The optional arguments are used to configure the query builder of the edge.
|
|
func (sausq *ScaAuthUserSocialQuery) WithScaAuthUser(opts ...func(*ScaAuthUserQuery)) *ScaAuthUserSocialQuery {
|
|
query := (&ScaAuthUserClient{config: sausq.config}).Query()
|
|
for _, opt := range opts {
|
|
opt(query)
|
|
}
|
|
sausq.withScaAuthUser = query
|
|
return sausq
|
|
}
|
|
|
|
// 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 {
|
|
// UserID string `json:"user_id,omitempty"`
|
|
// Count int `json:"count,omitempty"`
|
|
// }
|
|
//
|
|
// client.ScaAuthUserSocial.Query().
|
|
// GroupBy(scaauthusersocial.FieldUserID).
|
|
// Aggregate(ent.Count()).
|
|
// Scan(ctx, &v)
|
|
func (sausq *ScaAuthUserSocialQuery) GroupBy(field string, fields ...string) *ScaAuthUserSocialGroupBy {
|
|
sausq.ctx.Fields = append([]string{field}, fields...)
|
|
grbuild := &ScaAuthUserSocialGroupBy{build: sausq}
|
|
grbuild.flds = &sausq.ctx.Fields
|
|
grbuild.label = scaauthusersocial.Label
|
|
grbuild.scan = grbuild.Scan
|
|
return grbuild
|
|
}
|
|
|
|
// 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 {
|
|
// UserID string `json:"user_id,omitempty"`
|
|
// }
|
|
//
|
|
// client.ScaAuthUserSocial.Query().
|
|
// Select(scaauthusersocial.FieldUserID).
|
|
// Scan(ctx, &v)
|
|
func (sausq *ScaAuthUserSocialQuery) Select(fields ...string) *ScaAuthUserSocialSelect {
|
|
sausq.ctx.Fields = append(sausq.ctx.Fields, fields...)
|
|
sbuild := &ScaAuthUserSocialSelect{ScaAuthUserSocialQuery: sausq}
|
|
sbuild.label = scaauthusersocial.Label
|
|
sbuild.flds, sbuild.scan = &sausq.ctx.Fields, sbuild.Scan
|
|
return sbuild
|
|
}
|
|
|
|
// Aggregate returns a ScaAuthUserSocialSelect configured with the given aggregations.
|
|
func (sausq *ScaAuthUserSocialQuery) Aggregate(fns ...AggregateFunc) *ScaAuthUserSocialSelect {
|
|
return sausq.Select().Aggregate(fns...)
|
|
}
|
|
|
|
func (sausq *ScaAuthUserSocialQuery) prepareQuery(ctx context.Context) error {
|
|
for _, inter := range sausq.inters {
|
|
if inter == nil {
|
|
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
|
|
}
|
|
if trv, ok := inter.(Traverser); ok {
|
|
if err := trv.Traverse(ctx, sausq); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
}
|
|
for _, f := range sausq.ctx.Fields {
|
|
if !scaauthusersocial.ValidColumn(f) {
|
|
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
|
}
|
|
}
|
|
if sausq.path != nil {
|
|
prev, err := sausq.path(ctx)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
sausq.sql = prev
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (sausq *ScaAuthUserSocialQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ScaAuthUserSocial, error) {
|
|
var (
|
|
nodes = []*ScaAuthUserSocial{}
|
|
withFKs = sausq.withFKs
|
|
_spec = sausq.querySpec()
|
|
loadedTypes = [1]bool{
|
|
sausq.withScaAuthUser != nil,
|
|
}
|
|
)
|
|
if sausq.withScaAuthUser != nil {
|
|
withFKs = true
|
|
}
|
|
if withFKs {
|
|
_spec.Node.Columns = append(_spec.Node.Columns, scaauthusersocial.ForeignKeys...)
|
|
}
|
|
_spec.ScanValues = func(columns []string) ([]any, error) {
|
|
return (*ScaAuthUserSocial).scanValues(nil, columns)
|
|
}
|
|
_spec.Assign = func(columns []string, values []any) error {
|
|
node := &ScaAuthUserSocial{config: sausq.config}
|
|
nodes = append(nodes, node)
|
|
node.Edges.loadedTypes = loadedTypes
|
|
return node.assignValues(columns, values)
|
|
}
|
|
for i := range hooks {
|
|
hooks[i](ctx, _spec)
|
|
}
|
|
if err := sqlgraph.QueryNodes(ctx, sausq.driver, _spec); err != nil {
|
|
return nil, err
|
|
}
|
|
if len(nodes) == 0 {
|
|
return nodes, nil
|
|
}
|
|
if query := sausq.withScaAuthUser; query != nil {
|
|
if err := sausq.loadScaAuthUser(ctx, query, nodes, nil,
|
|
func(n *ScaAuthUserSocial, e *ScaAuthUser) { n.Edges.ScaAuthUser = e }); err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
return nodes, nil
|
|
}
|
|
|
|
func (sausq *ScaAuthUserSocialQuery) loadScaAuthUser(ctx context.Context, query *ScaAuthUserQuery, nodes []*ScaAuthUserSocial, init func(*ScaAuthUserSocial), assign func(*ScaAuthUserSocial, *ScaAuthUser)) error {
|
|
ids := make([]int64, 0, len(nodes))
|
|
nodeids := make(map[int64][]*ScaAuthUserSocial)
|
|
for i := range nodes {
|
|
if nodes[i].sca_auth_user_sca_auth_user_social == nil {
|
|
continue
|
|
}
|
|
fk := *nodes[i].sca_auth_user_sca_auth_user_social
|
|
if _, ok := nodeids[fk]; !ok {
|
|
ids = append(ids, fk)
|
|
}
|
|
nodeids[fk] = append(nodeids[fk], nodes[i])
|
|
}
|
|
if len(ids) == 0 {
|
|
return nil
|
|
}
|
|
query.Where(scaauthuser.IDIn(ids...))
|
|
neighbors, err := query.All(ctx)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
for _, n := range neighbors {
|
|
nodes, ok := nodeids[n.ID]
|
|
if !ok {
|
|
return fmt.Errorf(`unexpected foreign-key "sca_auth_user_sca_auth_user_social" returned %v`, n.ID)
|
|
}
|
|
for i := range nodes {
|
|
assign(nodes[i], n)
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (sausq *ScaAuthUserSocialQuery) sqlCount(ctx context.Context) (int, error) {
|
|
_spec := sausq.querySpec()
|
|
_spec.Node.Columns = sausq.ctx.Fields
|
|
if len(sausq.ctx.Fields) > 0 {
|
|
_spec.Unique = sausq.ctx.Unique != nil && *sausq.ctx.Unique
|
|
}
|
|
return sqlgraph.CountNodes(ctx, sausq.driver, _spec)
|
|
}
|
|
|
|
func (sausq *ScaAuthUserSocialQuery) querySpec() *sqlgraph.QuerySpec {
|
|
_spec := sqlgraph.NewQuerySpec(scaauthusersocial.Table, scaauthusersocial.Columns, sqlgraph.NewFieldSpec(scaauthusersocial.FieldID, field.TypeInt64))
|
|
_spec.From = sausq.sql
|
|
if unique := sausq.ctx.Unique; unique != nil {
|
|
_spec.Unique = *unique
|
|
} else if sausq.path != nil {
|
|
_spec.Unique = true
|
|
}
|
|
if fields := sausq.ctx.Fields; len(fields) > 0 {
|
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
|
_spec.Node.Columns = append(_spec.Node.Columns, scaauthusersocial.FieldID)
|
|
for i := range fields {
|
|
if fields[i] != scaauthusersocial.FieldID {
|
|
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
|
|
}
|
|
}
|
|
}
|
|
if ps := sausq.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if limit := sausq.ctx.Limit; limit != nil {
|
|
_spec.Limit = *limit
|
|
}
|
|
if offset := sausq.ctx.Offset; offset != nil {
|
|
_spec.Offset = *offset
|
|
}
|
|
if ps := sausq.order; len(ps) > 0 {
|
|
_spec.Order = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
return _spec
|
|
}
|
|
|
|
func (sausq *ScaAuthUserSocialQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
|
builder := sql.Dialect(sausq.driver.Dialect())
|
|
t1 := builder.Table(scaauthusersocial.Table)
|
|
columns := sausq.ctx.Fields
|
|
if len(columns) == 0 {
|
|
columns = scaauthusersocial.Columns
|
|
}
|
|
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
|
if sausq.sql != nil {
|
|
selector = sausq.sql
|
|
selector.Select(selector.Columns(columns...)...)
|
|
}
|
|
if sausq.ctx.Unique != nil && *sausq.ctx.Unique {
|
|
selector.Distinct()
|
|
}
|
|
for _, p := range sausq.predicates {
|
|
p(selector)
|
|
}
|
|
for _, p := range sausq.order {
|
|
p(selector)
|
|
}
|
|
if offset := sausq.ctx.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 := sausq.ctx.Limit; limit != nil {
|
|
selector.Limit(*limit)
|
|
}
|
|
return selector
|
|
}
|
|
|
|
// ScaAuthUserSocialGroupBy is the group-by builder for ScaAuthUserSocial entities.
|
|
type ScaAuthUserSocialGroupBy struct {
|
|
selector
|
|
build *ScaAuthUserSocialQuery
|
|
}
|
|
|
|
// Aggregate adds the given aggregation functions to the group-by query.
|
|
func (sausgb *ScaAuthUserSocialGroupBy) Aggregate(fns ...AggregateFunc) *ScaAuthUserSocialGroupBy {
|
|
sausgb.fns = append(sausgb.fns, fns...)
|
|
return sausgb
|
|
}
|
|
|
|
// Scan applies the selector query and scans the result into the given value.
|
|
func (sausgb *ScaAuthUserSocialGroupBy) Scan(ctx context.Context, v any) error {
|
|
ctx = setContextOp(ctx, sausgb.build.ctx, ent.OpQueryGroupBy)
|
|
if err := sausgb.build.prepareQuery(ctx); err != nil {
|
|
return err
|
|
}
|
|
return scanWithInterceptors[*ScaAuthUserSocialQuery, *ScaAuthUserSocialGroupBy](ctx, sausgb.build, sausgb, sausgb.build.inters, v)
|
|
}
|
|
|
|
func (sausgb *ScaAuthUserSocialGroupBy) sqlScan(ctx context.Context, root *ScaAuthUserSocialQuery, v any) error {
|
|
selector := root.sqlQuery(ctx).Select()
|
|
aggregation := make([]string, 0, len(sausgb.fns))
|
|
for _, fn := range sausgb.fns {
|
|
aggregation = append(aggregation, fn(selector))
|
|
}
|
|
if len(selector.SelectedColumns()) == 0 {
|
|
columns := make([]string, 0, len(*sausgb.flds)+len(sausgb.fns))
|
|
for _, f := range *sausgb.flds {
|
|
columns = append(columns, selector.C(f))
|
|
}
|
|
columns = append(columns, aggregation...)
|
|
selector.Select(columns...)
|
|
}
|
|
selector.GroupBy(selector.Columns(*sausgb.flds...)...)
|
|
if err := selector.Err(); err != nil {
|
|
return err
|
|
}
|
|
rows := &sql.Rows{}
|
|
query, args := selector.Query()
|
|
if err := sausgb.build.driver.Query(ctx, query, args, rows); err != nil {
|
|
return err
|
|
}
|
|
defer rows.Close()
|
|
return sql.ScanSlice(rows, v)
|
|
}
|
|
|
|
// ScaAuthUserSocialSelect is the builder for selecting fields of ScaAuthUserSocial entities.
|
|
type ScaAuthUserSocialSelect struct {
|
|
*ScaAuthUserSocialQuery
|
|
selector
|
|
}
|
|
|
|
// Aggregate adds the given aggregation functions to the selector query.
|
|
func (sauss *ScaAuthUserSocialSelect) Aggregate(fns ...AggregateFunc) *ScaAuthUserSocialSelect {
|
|
sauss.fns = append(sauss.fns, fns...)
|
|
return sauss
|
|
}
|
|
|
|
// Scan applies the selector query and scans the result into the given value.
|
|
func (sauss *ScaAuthUserSocialSelect) Scan(ctx context.Context, v any) error {
|
|
ctx = setContextOp(ctx, sauss.ctx, ent.OpQuerySelect)
|
|
if err := sauss.prepareQuery(ctx); err != nil {
|
|
return err
|
|
}
|
|
return scanWithInterceptors[*ScaAuthUserSocialQuery, *ScaAuthUserSocialSelect](ctx, sauss.ScaAuthUserSocialQuery, sauss, sauss.inters, v)
|
|
}
|
|
|
|
func (sauss *ScaAuthUserSocialSelect) sqlScan(ctx context.Context, root *ScaAuthUserSocialQuery, v any) error {
|
|
selector := root.sqlQuery(ctx)
|
|
aggregation := make([]string, 0, len(sauss.fns))
|
|
for _, fn := range sauss.fns {
|
|
aggregation = append(aggregation, fn(selector))
|
|
}
|
|
switch n := len(*sauss.selector.flds); {
|
|
case n == 0 && len(aggregation) > 0:
|
|
selector.Select(aggregation...)
|
|
case n != 0 && len(aggregation) > 0:
|
|
selector.AppendSelect(aggregation...)
|
|
}
|
|
rows := &sql.Rows{}
|
|
query, args := selector.Query()
|
|
if err := sauss.driver.Query(ctx, query, args, rows); err != nil {
|
|
return err
|
|
}
|
|
defer rows.Close()
|
|
return sql.ScanSlice(rows, v)
|
|
}
|