fix: shop_players 关系表主键与模型对齐
This commit is contained in:
@@ -12,7 +12,6 @@ import (
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// ShopPlayersQuery is the builder for querying ShopPlayers entities.
|
||||
@@ -80,29 +79,6 @@ func (_q *ShopPlayersQuery) FirstX(ctx context.Context) *ShopPlayers {
|
||||
return node
|
||||
}
|
||||
|
||||
// FirstID returns the first ShopPlayers ID from the query.
|
||||
// Returns a *NotFoundError when no ShopPlayers ID was found.
|
||||
func (_q *ShopPlayersQuery) FirstID(ctx context.Context) (id int64, err error) {
|
||||
var ids []int64
|
||||
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
err = &NotFoundError{shopplayers.Label}
|
||||
return
|
||||
}
|
||||
return ids[0], nil
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (_q *ShopPlayersQuery) FirstIDX(ctx context.Context) int64 {
|
||||
id, err := _q.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// Only returns a single ShopPlayers entity found by the query, ensuring it only returns one.
|
||||
// Returns a *NotSingularError when more than one ShopPlayers entity is found.
|
||||
// Returns a *NotFoundError when no ShopPlayers entities are found.
|
||||
@@ -130,34 +106,6 @@ func (_q *ShopPlayersQuery) OnlyX(ctx context.Context) *ShopPlayers {
|
||||
return node
|
||||
}
|
||||
|
||||
// OnlyID is like Only, but returns the only ShopPlayers ID in the query.
|
||||
// Returns a *NotSingularError when more than one ShopPlayers ID is found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (_q *ShopPlayersQuery) OnlyID(ctx context.Context) (id int64, err error) {
|
||||
var ids []int64
|
||||
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
case 1:
|
||||
id = ids[0]
|
||||
case 0:
|
||||
err = &NotFoundError{shopplayers.Label}
|
||||
default:
|
||||
err = &NotSingularError{shopplayers.Label}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (_q *ShopPlayersQuery) OnlyIDX(ctx context.Context) int64 {
|
||||
id, err := _q.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of ShopPlayersSlice.
|
||||
func (_q *ShopPlayersQuery) All(ctx context.Context) ([]*ShopPlayers, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
|
||||
@@ -177,27 +125,6 @@ func (_q *ShopPlayersQuery) AllX(ctx context.Context) []*ShopPlayers {
|
||||
return nodes
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of ShopPlayers IDs.
|
||||
func (_q *ShopPlayersQuery) IDs(ctx context.Context) (ids []int64, err error) {
|
||||
if _q.ctx.Unique == nil && _q.path != nil {
|
||||
_q.Unique(true)
|
||||
}
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
|
||||
if err = _q.Select(shopplayers.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (_q *ShopPlayersQuery) IDsX(ctx context.Context) []int64 {
|
||||
ids, err := _q.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return ids
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (_q *ShopPlayersQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
|
||||
@@ -219,7 +146,7 @@ func (_q *ShopPlayersQuery) CountX(ctx context.Context) int {
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (_q *ShopPlayersQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
|
||||
switch _, err := _q.FirstID(ctx); {
|
||||
switch _, err := _q.First(ctx); {
|
||||
case IsNotFound(err):
|
||||
return false, nil
|
||||
case err != nil:
|
||||
@@ -365,7 +292,7 @@ func (_q *ShopPlayersQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
}
|
||||
|
||||
func (_q *ShopPlayersQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := sqlgraph.NewQuerySpec(shopplayers.Table, shopplayers.Columns, sqlgraph.NewFieldSpec(shopplayers.FieldID, field.TypeInt64))
|
||||
_spec := sqlgraph.NewQuerySpec(shopplayers.Table, shopplayers.Columns, nil)
|
||||
_spec.From = _q.sql
|
||||
if unique := _q.ctx.Unique; unique != nil {
|
||||
_spec.Unique = *unique
|
||||
@@ -374,11 +301,8 @@ func (_q *ShopPlayersQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
}
|
||||
if fields := _q.ctx.Fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, shopplayers.FieldID)
|
||||
for i := range fields {
|
||||
if fields[i] != shopplayers.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
|
||||
}
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
|
||||
}
|
||||
}
|
||||
if ps := _q.predicates; len(ps) > 0 {
|
||||
|
||||
Reference in New Issue
Block a user