regenerate ent

This commit is contained in:
2025-10-26 05:09:47 +01:00
parent 5358d9dd0f
commit ab8b0b983c
46 changed files with 6050 additions and 5607 deletions

View File

@@ -7,6 +7,7 @@ import (
"fmt"
"math"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
@@ -31,44 +32,44 @@ type WeaponQuery struct {
}
// Where adds a new predicate for the WeaponQuery builder.
func (wq *WeaponQuery) Where(ps ...predicate.Weapon) *WeaponQuery {
wq.predicates = append(wq.predicates, ps...)
return wq
func (_q *WeaponQuery) Where(ps ...predicate.Weapon) *WeaponQuery {
_q.predicates = append(_q.predicates, ps...)
return _q
}
// Limit the number of records to be returned by this query.
func (wq *WeaponQuery) Limit(limit int) *WeaponQuery {
wq.ctx.Limit = &limit
return wq
func (_q *WeaponQuery) Limit(limit int) *WeaponQuery {
_q.ctx.Limit = &limit
return _q
}
// Offset to start from.
func (wq *WeaponQuery) Offset(offset int) *WeaponQuery {
wq.ctx.Offset = &offset
return wq
func (_q *WeaponQuery) Offset(offset int) *WeaponQuery {
_q.ctx.Offset = &offset
return _q
}
// 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 (wq *WeaponQuery) Unique(unique bool) *WeaponQuery {
wq.ctx.Unique = &unique
return wq
func (_q *WeaponQuery) Unique(unique bool) *WeaponQuery {
_q.ctx.Unique = &unique
return _q
}
// Order specifies how the records should be ordered.
func (wq *WeaponQuery) Order(o ...weapon.OrderOption) *WeaponQuery {
wq.order = append(wq.order, o...)
return wq
func (_q *WeaponQuery) Order(o ...weapon.OrderOption) *WeaponQuery {
_q.order = append(_q.order, o...)
return _q
}
// QueryStat chains the current query on the "stat" edge.
func (wq *WeaponQuery) QueryStat() *MatchPlayerQuery {
query := (&MatchPlayerClient{config: wq.config}).Query()
func (_q *WeaponQuery) QueryStat() *MatchPlayerQuery {
query := (&MatchPlayerClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := wq.prepareQuery(ctx); err != nil {
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
}
selector := wq.sqlQuery(ctx)
selector := _q.sqlQuery(ctx)
if err := selector.Err(); err != nil {
return nil, err
}
@@ -77,7 +78,7 @@ func (wq *WeaponQuery) QueryStat() *MatchPlayerQuery {
sqlgraph.To(matchplayer.Table, matchplayer.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, weapon.StatTable, weapon.StatColumn),
)
fromU = sqlgraph.SetNeighbors(wq.driver.Dialect(), step)
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
return fromU, nil
}
return query
@@ -85,8 +86,8 @@ func (wq *WeaponQuery) QueryStat() *MatchPlayerQuery {
// First returns the first Weapon entity from the query.
// Returns a *NotFoundError when no Weapon was found.
func (wq *WeaponQuery) First(ctx context.Context) (*Weapon, error) {
nodes, err := wq.Limit(1).All(setContextOp(ctx, wq.ctx, "First"))
func (_q *WeaponQuery) First(ctx context.Context) (*Weapon, error) {
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
@@ -97,8 +98,8 @@ func (wq *WeaponQuery) First(ctx context.Context) (*Weapon, error) {
}
// FirstX is like First, but panics if an error occurs.
func (wq *WeaponQuery) FirstX(ctx context.Context) *Weapon {
node, err := wq.First(ctx)
func (_q *WeaponQuery) FirstX(ctx context.Context) *Weapon {
node, err := _q.First(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
@@ -107,9 +108,9 @@ func (wq *WeaponQuery) FirstX(ctx context.Context) *Weapon {
// FirstID returns the first Weapon ID from the query.
// Returns a *NotFoundError when no Weapon ID was found.
func (wq *WeaponQuery) FirstID(ctx context.Context) (id int, err error) {
func (_q *WeaponQuery) FirstID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = wq.Limit(1).IDs(setContextOp(ctx, wq.ctx, "FirstID")); err != nil {
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
@@ -120,8 +121,8 @@ func (wq *WeaponQuery) FirstID(ctx context.Context) (id int, err error) {
}
// FirstIDX is like FirstID, but panics if an error occurs.
func (wq *WeaponQuery) FirstIDX(ctx context.Context) int {
id, err := wq.FirstID(ctx)
func (_q *WeaponQuery) FirstIDX(ctx context.Context) int {
id, err := _q.FirstID(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
@@ -131,8 +132,8 @@ func (wq *WeaponQuery) FirstIDX(ctx context.Context) int {
// Only returns a single Weapon entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when more than one Weapon entity is found.
// Returns a *NotFoundError when no Weapon entities are found.
func (wq *WeaponQuery) Only(ctx context.Context) (*Weapon, error) {
nodes, err := wq.Limit(2).All(setContextOp(ctx, wq.ctx, "Only"))
func (_q *WeaponQuery) Only(ctx context.Context) (*Weapon, error) {
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
@@ -147,8 +148,8 @@ func (wq *WeaponQuery) Only(ctx context.Context) (*Weapon, error) {
}
// OnlyX is like Only, but panics if an error occurs.
func (wq *WeaponQuery) OnlyX(ctx context.Context) *Weapon {
node, err := wq.Only(ctx)
func (_q *WeaponQuery) OnlyX(ctx context.Context) *Weapon {
node, err := _q.Only(ctx)
if err != nil {
panic(err)
}
@@ -158,9 +159,9 @@ func (wq *WeaponQuery) OnlyX(ctx context.Context) *Weapon {
// OnlyID is like Only, but returns the only Weapon ID in the query.
// Returns a *NotSingularError when more than one Weapon ID is found.
// Returns a *NotFoundError when no entities are found.
func (wq *WeaponQuery) OnlyID(ctx context.Context) (id int, err error) {
func (_q *WeaponQuery) OnlyID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = wq.Limit(2).IDs(setContextOp(ctx, wq.ctx, "OnlyID")); err != nil {
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
@@ -175,8 +176,8 @@ func (wq *WeaponQuery) OnlyID(ctx context.Context) (id int, err error) {
}
// OnlyIDX is like OnlyID, but panics if an error occurs.
func (wq *WeaponQuery) OnlyIDX(ctx context.Context) int {
id, err := wq.OnlyID(ctx)
func (_q *WeaponQuery) OnlyIDX(ctx context.Context) int {
id, err := _q.OnlyID(ctx)
if err != nil {
panic(err)
}
@@ -184,18 +185,18 @@ func (wq *WeaponQuery) OnlyIDX(ctx context.Context) int {
}
// All executes the query and returns a list of Weapons.
func (wq *WeaponQuery) All(ctx context.Context) ([]*Weapon, error) {
ctx = setContextOp(ctx, wq.ctx, "All")
if err := wq.prepareQuery(ctx); err != nil {
func (_q *WeaponQuery) All(ctx context.Context) ([]*Weapon, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
}
qr := querierAll[[]*Weapon, *WeaponQuery]()
return withInterceptors[[]*Weapon](ctx, wq, qr, wq.inters)
return withInterceptors[[]*Weapon](ctx, _q, qr, _q.inters)
}
// AllX is like All, but panics if an error occurs.
func (wq *WeaponQuery) AllX(ctx context.Context) []*Weapon {
nodes, err := wq.All(ctx)
func (_q *WeaponQuery) AllX(ctx context.Context) []*Weapon {
nodes, err := _q.All(ctx)
if err != nil {
panic(err)
}
@@ -203,20 +204,20 @@ func (wq *WeaponQuery) AllX(ctx context.Context) []*Weapon {
}
// IDs executes the query and returns a list of Weapon IDs.
func (wq *WeaponQuery) IDs(ctx context.Context) (ids []int, err error) {
if wq.ctx.Unique == nil && wq.path != nil {
wq.Unique(true)
func (_q *WeaponQuery) IDs(ctx context.Context) (ids []int, err error) {
if _q.ctx.Unique == nil && _q.path != nil {
_q.Unique(true)
}
ctx = setContextOp(ctx, wq.ctx, "IDs")
if err = wq.Select(weapon.FieldID).Scan(ctx, &ids); err != nil {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
if err = _q.Select(weapon.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
return ids, nil
}
// IDsX is like IDs, but panics if an error occurs.
func (wq *WeaponQuery) IDsX(ctx context.Context) []int {
ids, err := wq.IDs(ctx)
func (_q *WeaponQuery) IDsX(ctx context.Context) []int {
ids, err := _q.IDs(ctx)
if err != nil {
panic(err)
}
@@ -224,17 +225,17 @@ func (wq *WeaponQuery) IDsX(ctx context.Context) []int {
}
// Count returns the count of the given query.
func (wq *WeaponQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, wq.ctx, "Count")
if err := wq.prepareQuery(ctx); err != nil {
func (_q *WeaponQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
if err := _q.prepareQuery(ctx); err != nil {
return 0, err
}
return withInterceptors[int](ctx, wq, querierCount[*WeaponQuery](), wq.inters)
return withInterceptors[int](ctx, _q, querierCount[*WeaponQuery](), _q.inters)
}
// CountX is like Count, but panics if an error occurs.
func (wq *WeaponQuery) CountX(ctx context.Context) int {
count, err := wq.Count(ctx)
func (_q *WeaponQuery) CountX(ctx context.Context) int {
count, err := _q.Count(ctx)
if err != nil {
panic(err)
}
@@ -242,9 +243,9 @@ func (wq *WeaponQuery) CountX(ctx context.Context) int {
}
// Exist returns true if the query has elements in the graph.
func (wq *WeaponQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, wq.ctx, "Exist")
switch _, err := wq.FirstID(ctx); {
func (_q *WeaponQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
switch _, err := _q.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
@@ -255,8 +256,8 @@ func (wq *WeaponQuery) Exist(ctx context.Context) (bool, error) {
}
// ExistX is like Exist, but panics if an error occurs.
func (wq *WeaponQuery) ExistX(ctx context.Context) bool {
exist, err := wq.Exist(ctx)
func (_q *WeaponQuery) ExistX(ctx context.Context) bool {
exist, err := _q.Exist(ctx)
if err != nil {
panic(err)
}
@@ -265,32 +266,33 @@ func (wq *WeaponQuery) ExistX(ctx context.Context) bool {
// Clone returns a duplicate of the WeaponQuery builder, including all associated steps. It can be
// used to prepare common query builders and use them differently after the clone is made.
func (wq *WeaponQuery) Clone() *WeaponQuery {
if wq == nil {
func (_q *WeaponQuery) Clone() *WeaponQuery {
if _q == nil {
return nil
}
return &WeaponQuery{
config: wq.config,
ctx: wq.ctx.Clone(),
order: append([]weapon.OrderOption{}, wq.order...),
inters: append([]Interceptor{}, wq.inters...),
predicates: append([]predicate.Weapon{}, wq.predicates...),
withStat: wq.withStat.Clone(),
config: _q.config,
ctx: _q.ctx.Clone(),
order: append([]weapon.OrderOption{}, _q.order...),
inters: append([]Interceptor{}, _q.inters...),
predicates: append([]predicate.Weapon{}, _q.predicates...),
withStat: _q.withStat.Clone(),
// clone intermediate query.
sql: wq.sql.Clone(),
path: wq.path,
sql: _q.sql.Clone(),
path: _q.path,
modifiers: append([]func(*sql.Selector){}, _q.modifiers...),
}
}
// WithStat tells the query-builder to eager-load the nodes that are connected to
// the "stat" edge. The optional arguments are used to configure the query builder of the edge.
func (wq *WeaponQuery) WithStat(opts ...func(*MatchPlayerQuery)) *WeaponQuery {
query := (&MatchPlayerClient{config: wq.config}).Query()
func (_q *WeaponQuery) WithStat(opts ...func(*MatchPlayerQuery)) *WeaponQuery {
query := (&MatchPlayerClient{config: _q.config}).Query()
for _, opt := range opts {
opt(query)
}
wq.withStat = query
return wq
_q.withStat = query
return _q
}
// GroupBy is used to group vertices by one or more fields/columns.
@@ -307,10 +309,10 @@ func (wq *WeaponQuery) WithStat(opts ...func(*MatchPlayerQuery)) *WeaponQuery {
// GroupBy(weapon.FieldVictim).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
func (wq *WeaponQuery) GroupBy(field string, fields ...string) *WeaponGroupBy {
wq.ctx.Fields = append([]string{field}, fields...)
grbuild := &WeaponGroupBy{build: wq}
grbuild.flds = &wq.ctx.Fields
func (_q *WeaponQuery) GroupBy(field string, fields ...string) *WeaponGroupBy {
_q.ctx.Fields = append([]string{field}, fields...)
grbuild := &WeaponGroupBy{build: _q}
grbuild.flds = &_q.ctx.Fields
grbuild.label = weapon.Label
grbuild.scan = grbuild.Scan
return grbuild
@@ -328,55 +330,55 @@ func (wq *WeaponQuery) GroupBy(field string, fields ...string) *WeaponGroupBy {
// client.Weapon.Query().
// Select(weapon.FieldVictim).
// Scan(ctx, &v)
func (wq *WeaponQuery) Select(fields ...string) *WeaponSelect {
wq.ctx.Fields = append(wq.ctx.Fields, fields...)
sbuild := &WeaponSelect{WeaponQuery: wq}
func (_q *WeaponQuery) Select(fields ...string) *WeaponSelect {
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
sbuild := &WeaponSelect{WeaponQuery: _q}
sbuild.label = weapon.Label
sbuild.flds, sbuild.scan = &wq.ctx.Fields, sbuild.Scan
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
return sbuild
}
// Aggregate returns a WeaponSelect configured with the given aggregations.
func (wq *WeaponQuery) Aggregate(fns ...AggregateFunc) *WeaponSelect {
return wq.Select().Aggregate(fns...)
func (_q *WeaponQuery) Aggregate(fns ...AggregateFunc) *WeaponSelect {
return _q.Select().Aggregate(fns...)
}
func (wq *WeaponQuery) prepareQuery(ctx context.Context) error {
for _, inter := range wq.inters {
func (_q *WeaponQuery) prepareQuery(ctx context.Context) error {
for _, inter := range _q.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, wq); err != nil {
if err := trv.Traverse(ctx, _q); err != nil {
return err
}
}
}
for _, f := range wq.ctx.Fields {
for _, f := range _q.ctx.Fields {
if !weapon.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
}
if wq.path != nil {
prev, err := wq.path(ctx)
if _q.path != nil {
prev, err := _q.path(ctx)
if err != nil {
return err
}
wq.sql = prev
_q.sql = prev
}
return nil
}
func (wq *WeaponQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Weapon, error) {
func (_q *WeaponQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Weapon, error) {
var (
nodes = []*Weapon{}
withFKs = wq.withFKs
_spec = wq.querySpec()
withFKs = _q.withFKs
_spec = _q.querySpec()
loadedTypes = [1]bool{
wq.withStat != nil,
_q.withStat != nil,
}
)
if wq.withStat != nil {
if _q.withStat != nil {
withFKs = true
}
if withFKs {
@@ -386,25 +388,25 @@ func (wq *WeaponQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Weapo
return (*Weapon).scanValues(nil, columns)
}
_spec.Assign = func(columns []string, values []any) error {
node := &Weapon{config: wq.config}
node := &Weapon{config: _q.config}
nodes = append(nodes, node)
node.Edges.loadedTypes = loadedTypes
return node.assignValues(columns, values)
}
if len(wq.modifiers) > 0 {
_spec.Modifiers = wq.modifiers
if len(_q.modifiers) > 0 {
_spec.Modifiers = _q.modifiers
}
for i := range hooks {
hooks[i](ctx, _spec)
}
if err := sqlgraph.QueryNodes(ctx, wq.driver, _spec); err != nil {
if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
return nil, err
}
if len(nodes) == 0 {
return nodes, nil
}
if query := wq.withStat; query != nil {
if err := wq.loadStat(ctx, query, nodes, nil,
if query := _q.withStat; query != nil {
if err := _q.loadStat(ctx, query, nodes, nil,
func(n *Weapon, e *MatchPlayer) { n.Edges.Stat = e }); err != nil {
return nil, err
}
@@ -412,7 +414,7 @@ func (wq *WeaponQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Weapo
return nodes, nil
}
func (wq *WeaponQuery) loadStat(ctx context.Context, query *MatchPlayerQuery, nodes []*Weapon, init func(*Weapon), assign func(*Weapon, *MatchPlayer)) error {
func (_q *WeaponQuery) loadStat(ctx context.Context, query *MatchPlayerQuery, nodes []*Weapon, init func(*Weapon), assign func(*Weapon, *MatchPlayer)) error {
ids := make([]int, 0, len(nodes))
nodeids := make(map[int][]*Weapon)
for i := range nodes {
@@ -445,27 +447,27 @@ func (wq *WeaponQuery) loadStat(ctx context.Context, query *MatchPlayerQuery, no
return nil
}
func (wq *WeaponQuery) sqlCount(ctx context.Context) (int, error) {
_spec := wq.querySpec()
if len(wq.modifiers) > 0 {
_spec.Modifiers = wq.modifiers
func (_q *WeaponQuery) sqlCount(ctx context.Context) (int, error) {
_spec := _q.querySpec()
if len(_q.modifiers) > 0 {
_spec.Modifiers = _q.modifiers
}
_spec.Node.Columns = wq.ctx.Fields
if len(wq.ctx.Fields) > 0 {
_spec.Unique = wq.ctx.Unique != nil && *wq.ctx.Unique
_spec.Node.Columns = _q.ctx.Fields
if len(_q.ctx.Fields) > 0 {
_spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
}
return sqlgraph.CountNodes(ctx, wq.driver, _spec)
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
}
func (wq *WeaponQuery) querySpec() *sqlgraph.QuerySpec {
func (_q *WeaponQuery) querySpec() *sqlgraph.QuerySpec {
_spec := sqlgraph.NewQuerySpec(weapon.Table, weapon.Columns, sqlgraph.NewFieldSpec(weapon.FieldID, field.TypeInt))
_spec.From = wq.sql
if unique := wq.ctx.Unique; unique != nil {
_spec.From = _q.sql
if unique := _q.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if wq.path != nil {
} else if _q.path != nil {
_spec.Unique = true
}
if fields := wq.ctx.Fields; len(fields) > 0 {
if fields := _q.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, weapon.FieldID)
for i := range fields {
@@ -474,20 +476,20 @@ func (wq *WeaponQuery) querySpec() *sqlgraph.QuerySpec {
}
}
}
if ps := wq.predicates; len(ps) > 0 {
if ps := _q.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if limit := wq.ctx.Limit; limit != nil {
if limit := _q.ctx.Limit; limit != nil {
_spec.Limit = *limit
}
if offset := wq.ctx.Offset; offset != nil {
if offset := _q.ctx.Offset; offset != nil {
_spec.Offset = *offset
}
if ps := wq.order; len(ps) > 0 {
if ps := _q.order; len(ps) > 0 {
_spec.Order = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
@@ -497,45 +499,45 @@ func (wq *WeaponQuery) querySpec() *sqlgraph.QuerySpec {
return _spec
}
func (wq *WeaponQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(wq.driver.Dialect())
func (_q *WeaponQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(_q.driver.Dialect())
t1 := builder.Table(weapon.Table)
columns := wq.ctx.Fields
columns := _q.ctx.Fields
if len(columns) == 0 {
columns = weapon.Columns
}
selector := builder.Select(t1.Columns(columns...)...).From(t1)
if wq.sql != nil {
selector = wq.sql
if _q.sql != nil {
selector = _q.sql
selector.Select(selector.Columns(columns...)...)
}
if wq.ctx.Unique != nil && *wq.ctx.Unique {
if _q.ctx.Unique != nil && *_q.ctx.Unique {
selector.Distinct()
}
for _, m := range wq.modifiers {
for _, m := range _q.modifiers {
m(selector)
}
for _, p := range wq.predicates {
for _, p := range _q.predicates {
p(selector)
}
for _, p := range wq.order {
for _, p := range _q.order {
p(selector)
}
if offset := wq.ctx.Offset; offset != nil {
if offset := _q.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 := wq.ctx.Limit; limit != nil {
if limit := _q.ctx.Limit; limit != nil {
selector.Limit(*limit)
}
return selector
}
// Modify adds a query modifier for attaching custom logic to queries.
func (wq *WeaponQuery) Modify(modifiers ...func(s *sql.Selector)) *WeaponSelect {
wq.modifiers = append(wq.modifiers, modifiers...)
return wq.Select()
func (_q *WeaponQuery) Modify(modifiers ...func(s *sql.Selector)) *WeaponSelect {
_q.modifiers = append(_q.modifiers, modifiers...)
return _q.Select()
}
// WeaponGroupBy is the group-by builder for Weapon entities.
@@ -545,41 +547,41 @@ type WeaponGroupBy struct {
}
// Aggregate adds the given aggregation functions to the group-by query.
func (wgb *WeaponGroupBy) Aggregate(fns ...AggregateFunc) *WeaponGroupBy {
wgb.fns = append(wgb.fns, fns...)
return wgb
func (_g *WeaponGroupBy) Aggregate(fns ...AggregateFunc) *WeaponGroupBy {
_g.fns = append(_g.fns, fns...)
return _g
}
// Scan applies the selector query and scans the result into the given value.
func (wgb *WeaponGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, wgb.build.ctx, "GroupBy")
if err := wgb.build.prepareQuery(ctx); err != nil {
func (_g *WeaponGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
if err := _g.build.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*WeaponQuery, *WeaponGroupBy](ctx, wgb.build, wgb, wgb.build.inters, v)
return scanWithInterceptors[*WeaponQuery, *WeaponGroupBy](ctx, _g.build, _g, _g.build.inters, v)
}
func (wgb *WeaponGroupBy) sqlScan(ctx context.Context, root *WeaponQuery, v any) error {
func (_g *WeaponGroupBy) sqlScan(ctx context.Context, root *WeaponQuery, v any) error {
selector := root.sqlQuery(ctx).Select()
aggregation := make([]string, 0, len(wgb.fns))
for _, fn := range wgb.fns {
aggregation := make([]string, 0, len(_g.fns))
for _, fn := range _g.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*wgb.flds)+len(wgb.fns))
for _, f := range *wgb.flds {
columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
for _, f := range *_g.flds {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
selector.GroupBy(selector.Columns(*wgb.flds...)...)
selector.GroupBy(selector.Columns(*_g.flds...)...)
if err := selector.Err(); err != nil {
return err
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := wgb.build.driver.Query(ctx, query, args, rows); err != nil {
if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
@@ -593,27 +595,27 @@ type WeaponSelect struct {
}
// Aggregate adds the given aggregation functions to the selector query.
func (ws *WeaponSelect) Aggregate(fns ...AggregateFunc) *WeaponSelect {
ws.fns = append(ws.fns, fns...)
return ws
func (_s *WeaponSelect) Aggregate(fns ...AggregateFunc) *WeaponSelect {
_s.fns = append(_s.fns, fns...)
return _s
}
// Scan applies the selector query and scans the result into the given value.
func (ws *WeaponSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, ws.ctx, "Select")
if err := ws.prepareQuery(ctx); err != nil {
func (_s *WeaponSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
if err := _s.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*WeaponQuery, *WeaponSelect](ctx, ws.WeaponQuery, ws, ws.inters, v)
return scanWithInterceptors[*WeaponQuery, *WeaponSelect](ctx, _s.WeaponQuery, _s, _s.inters, v)
}
func (ws *WeaponSelect) sqlScan(ctx context.Context, root *WeaponQuery, v any) error {
func (_s *WeaponSelect) sqlScan(ctx context.Context, root *WeaponQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(ws.fns))
for _, fn := range ws.fns {
aggregation := make([]string, 0, len(_s.fns))
for _, fn := range _s.fns {
aggregation = append(aggregation, fn(selector))
}
switch n := len(*ws.selector.flds); {
switch n := len(*_s.selector.flds); {
case n == 0 && len(aggregation) > 0:
selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0:
@@ -621,7 +623,7 @@ func (ws *WeaponSelect) sqlScan(ctx context.Context, root *WeaponQuery, v any) e
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := ws.driver.Query(ctx, query, args, rows); err != nil {
if err := _s.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
@@ -629,7 +631,7 @@ func (ws *WeaponSelect) sqlScan(ctx context.Context, root *WeaponQuery, v any) e
}
// Modify adds a query modifier for attaching custom logic to queries.
func (ws *WeaponSelect) Modify(modifiers ...func(s *sql.Selector)) *WeaponSelect {
ws.modifiers = append(ws.modifiers, modifiers...)
return ws
func (_s *WeaponSelect) Modify(modifiers ...func(s *sql.Selector)) *WeaponSelect {
_s.modifiers = append(_s.modifiers, modifiers...)
return _s
}