fixed match win/loss/ties
This commit is contained in:
@@ -22,12 +22,6 @@ type MatchCreate struct {
|
||||
hooks []Hook
|
||||
}
|
||||
|
||||
// SetMatchID sets the "match_id" field.
|
||||
func (mc *MatchCreate) SetMatchID(u uint64) *MatchCreate {
|
||||
mc.mutation.SetMatchID(u)
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetShareCode sets the "share_code" field.
|
||||
func (mc *MatchCreate) SetShareCode(s string) *MatchCreate {
|
||||
mc.mutation.SetShareCode(s)
|
||||
@@ -152,6 +146,12 @@ func (mc *MatchCreate) SetNillableEco(s *struct {
|
||||
return mc
|
||||
}
|
||||
|
||||
// SetID sets the "id" field.
|
||||
func (mc *MatchCreate) SetID(u uint64) *MatchCreate {
|
||||
mc.mutation.SetID(u)
|
||||
return mc
|
||||
}
|
||||
|
||||
// AddStatIDs adds the "stats" edge to the Stats entity by IDs.
|
||||
func (mc *MatchCreate) AddStatIDs(ids ...int) *MatchCreate {
|
||||
mc.mutation.AddStatIDs(ids...)
|
||||
@@ -168,14 +168,14 @@ func (mc *MatchCreate) AddStats(s ...*Stats) *MatchCreate {
|
||||
}
|
||||
|
||||
// AddPlayerIDs adds the "players" edge to the Player entity by IDs.
|
||||
func (mc *MatchCreate) AddPlayerIDs(ids ...int) *MatchCreate {
|
||||
func (mc *MatchCreate) AddPlayerIDs(ids ...uint64) *MatchCreate {
|
||||
mc.mutation.AddPlayerIDs(ids...)
|
||||
return mc
|
||||
}
|
||||
|
||||
// AddPlayers adds the "players" edges to the Player entity.
|
||||
func (mc *MatchCreate) AddPlayers(p ...*Player) *MatchCreate {
|
||||
ids := make([]int, len(p))
|
||||
ids := make([]uint64, len(p))
|
||||
for i := range p {
|
||||
ids[i] = p[i].ID
|
||||
}
|
||||
@@ -265,9 +265,6 @@ func (mc *MatchCreate) defaults() {
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (mc *MatchCreate) check() error {
|
||||
if _, ok := mc.mutation.MatchID(); !ok {
|
||||
return &ValidationError{Name: "match_id", err: errors.New(`ent: missing required field "match_id"`)}
|
||||
}
|
||||
if _, ok := mc.mutation.ShareCode(); !ok {
|
||||
return &ValidationError{Name: "share_code", err: errors.New(`ent: missing required field "share_code"`)}
|
||||
}
|
||||
@@ -306,8 +303,10 @@ func (mc *MatchCreate) sqlSave(ctx context.Context) (*Match, error) {
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
id := _spec.ID.Value.(int64)
|
||||
_node.ID = int(id)
|
||||
if _spec.ID.Value != _node.ID {
|
||||
id := _spec.ID.Value.(int64)
|
||||
_node.ID = uint64(id)
|
||||
}
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
@@ -317,18 +316,14 @@ func (mc *MatchCreate) createSpec() (*Match, *sqlgraph.CreateSpec) {
|
||||
_spec = &sqlgraph.CreateSpec{
|
||||
Table: match.Table,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Type: field.TypeUint64,
|
||||
Column: match.FieldID,
|
||||
},
|
||||
}
|
||||
)
|
||||
if value, ok := mc.mutation.MatchID(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUint64,
|
||||
Value: value,
|
||||
Column: match.FieldMatchID,
|
||||
})
|
||||
_node.MatchID = value
|
||||
if id, ok := mc.mutation.ID(); ok {
|
||||
_node.ID = id
|
||||
_spec.ID.Value = id
|
||||
}
|
||||
if value, ok := mc.mutation.ShareCode(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
@@ -454,7 +449,7 @@ func (mc *MatchCreate) createSpec() (*Match, *sqlgraph.CreateSpec) {
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Type: field.TypeUint64,
|
||||
Column: player.FieldID,
|
||||
},
|
||||
},
|
||||
@@ -509,9 +504,9 @@ func (mcb *MatchCreateBulk) Save(ctx context.Context) ([]*Match, error) {
|
||||
}
|
||||
mutation.id = &nodes[i].ID
|
||||
mutation.done = true
|
||||
if specs[i].ID.Value != nil {
|
||||
if specs[i].ID.Value != nil && nodes[i].ID == 0 {
|
||||
id := specs[i].ID.Value.(int64)
|
||||
nodes[i].ID = int(id)
|
||||
nodes[i].ID = uint64(id)
|
||||
}
|
||||
return nodes[i], nil
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user