1
0
api/ent/sev_update.go
2024-04-11 10:14:25 +09:00

918 lines
23 KiB
Go

// Code generated by ent, DO NOT EDIT.
package ent
import (
"api/ent/predicate"
"api/ent/sev"
"api/ent/user"
"context"
"errors"
"fmt"
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// SevUpdate is the builder for updating Sev entities.
type SevUpdate struct {
config
hooks []Hook
mutation *SevMutation
}
// Where appends a list predicates to the SevUpdate builder.
func (su *SevUpdate) Where(ps ...predicate.Sev) *SevUpdate {
su.mutation.Where(ps...)
return su
}
// SetToken sets the "token" field.
func (su *SevUpdate) SetToken(s string) *SevUpdate {
su.mutation.SetToken(s)
return su
}
// SetNillableToken sets the "token" field if the given value is not nil.
func (su *SevUpdate) SetNillableToken(s *string) *SevUpdate {
if s != nil {
su.SetToken(*s)
}
return su
}
// ClearToken clears the value of the "token" field.
func (su *SevUpdate) ClearToken() *SevUpdate {
su.mutation.ClearToken()
return su
}
// SetLimit sets the "limit" field.
func (su *SevUpdate) SetLimit(b bool) *SevUpdate {
su.mutation.SetLimit(b)
return su
}
// SetNillableLimit sets the "limit" field if the given value is not nil.
func (su *SevUpdate) SetNillableLimit(b *bool) *SevUpdate {
if b != nil {
su.SetLimit(*b)
}
return su
}
// ClearLimit clears the value of the "limit" field.
func (su *SevUpdate) ClearLimit() *SevUpdate {
su.mutation.ClearLimit()
return su
}
// SetCount sets the "count" field.
func (su *SevUpdate) SetCount(i int) *SevUpdate {
su.mutation.ResetCount()
su.mutation.SetCount(i)
return su
}
// SetNillableCount sets the "count" field if the given value is not nil.
func (su *SevUpdate) SetNillableCount(i *int) *SevUpdate {
if i != nil {
su.SetCount(*i)
}
return su
}
// AddCount adds i to the "count" field.
func (su *SevUpdate) AddCount(i int) *SevUpdate {
su.mutation.AddCount(i)
return su
}
// ClearCount clears the value of the "count" field.
func (su *SevUpdate) ClearCount() *SevUpdate {
su.mutation.ClearCount()
return su
}
// SetHandle sets the "handle" field.
func (su *SevUpdate) SetHandle(s string) *SevUpdate {
su.mutation.SetHandle(s)
return su
}
// SetNillableHandle sets the "handle" field if the given value is not nil.
func (su *SevUpdate) SetNillableHandle(s *string) *SevUpdate {
if s != nil {
su.SetHandle(*s)
}
return su
}
// ClearHandle clears the value of the "handle" field.
func (su *SevUpdate) ClearHandle() *SevUpdate {
su.mutation.ClearHandle()
return su
}
// SetDid sets the "did" field.
func (su *SevUpdate) SetDid(s string) *SevUpdate {
su.mutation.SetDid(s)
return su
}
// SetNillableDid sets the "did" field if the given value is not nil.
func (su *SevUpdate) SetNillableDid(s *string) *SevUpdate {
if s != nil {
su.SetDid(*s)
}
return su
}
// ClearDid clears the value of the "did" field.
func (su *SevUpdate) ClearDid() *SevUpdate {
su.mutation.ClearDid()
return su
}
// SetUID sets the "uid" field.
func (su *SevUpdate) SetUID(i int) *SevUpdate {
su.mutation.ResetUID()
su.mutation.SetUID(i)
return su
}
// SetNillableUID sets the "uid" field if the given value is not nil.
func (su *SevUpdate) SetNillableUID(i *int) *SevUpdate {
if i != nil {
su.SetUID(*i)
}
return su
}
// AddUID adds i to the "uid" field.
func (su *SevUpdate) AddUID(i int) *SevUpdate {
su.mutation.AddUID(i)
return su
}
// ClearUID clears the value of the "uid" field.
func (su *SevUpdate) ClearUID() *SevUpdate {
su.mutation.ClearUID()
return su
}
// SetCid sets the "cid" field.
func (su *SevUpdate) SetCid(i int) *SevUpdate {
su.mutation.ResetCid()
su.mutation.SetCid(i)
return su
}
// SetNillableCid sets the "cid" field if the given value is not nil.
func (su *SevUpdate) SetNillableCid(i *int) *SevUpdate {
if i != nil {
su.SetCid(*i)
}
return su
}
// AddCid adds i to the "cid" field.
func (su *SevUpdate) AddCid(i int) *SevUpdate {
su.mutation.AddCid(i)
return su
}
// ClearCid clears the value of the "cid" field.
func (su *SevUpdate) ClearCid() *SevUpdate {
su.mutation.ClearCid()
return su
}
// SetCp sets the "cp" field.
func (su *SevUpdate) SetCp(i int) *SevUpdate {
su.mutation.ResetCp()
su.mutation.SetCp(i)
return su
}
// SetNillableCp sets the "cp" field if the given value is not nil.
func (su *SevUpdate) SetNillableCp(i *int) *SevUpdate {
if i != nil {
su.SetCp(*i)
}
return su
}
// AddCp adds i to the "cp" field.
func (su *SevUpdate) AddCp(i int) *SevUpdate {
su.mutation.AddCp(i)
return su
}
// ClearCp clears the value of the "cp" field.
func (su *SevUpdate) ClearCp() *SevUpdate {
su.mutation.ClearCp()
return su
}
// SetCard sets the "card" field.
func (su *SevUpdate) SetCard(i int) *SevUpdate {
su.mutation.ResetCard()
su.mutation.SetCard(i)
return su
}
// SetNillableCard sets the "card" field if the given value is not nil.
func (su *SevUpdate) SetNillableCard(i *int) *SevUpdate {
if i != nil {
su.SetCard(*i)
}
return su
}
// AddCard adds i to the "card" field.
func (su *SevUpdate) AddCard(i int) *SevUpdate {
su.mutation.AddCard(i)
return su
}
// ClearCard clears the value of the "card" field.
func (su *SevUpdate) ClearCard() *SevUpdate {
su.mutation.ClearCard()
return su
}
// SetUpdatedAt sets the "updated_at" field.
func (su *SevUpdate) SetUpdatedAt(t time.Time) *SevUpdate {
su.mutation.SetUpdatedAt(t)
return su
}
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func (su *SevUpdate) SetNillableUpdatedAt(t *time.Time) *SevUpdate {
if t != nil {
su.SetUpdatedAt(*t)
}
return su
}
// ClearUpdatedAt clears the value of the "updated_at" field.
func (su *SevUpdate) ClearUpdatedAt() *SevUpdate {
su.mutation.ClearUpdatedAt()
return su
}
// SetOwnerID sets the "owner" edge to the User entity by ID.
func (su *SevUpdate) SetOwnerID(id int) *SevUpdate {
su.mutation.SetOwnerID(id)
return su
}
// SetOwner sets the "owner" edge to the User entity.
func (su *SevUpdate) SetOwner(u *User) *SevUpdate {
return su.SetOwnerID(u.ID)
}
// Mutation returns the SevMutation object of the builder.
func (su *SevUpdate) Mutation() *SevMutation {
return su.mutation
}
// ClearOwner clears the "owner" edge to the User entity.
func (su *SevUpdate) ClearOwner() *SevUpdate {
su.mutation.ClearOwner()
return su
}
// Save executes the query and returns the number of nodes affected by the update operation.
func (su *SevUpdate) Save(ctx context.Context) (int, error) {
return withHooks[int, SevMutation](ctx, su.sqlSave, su.mutation, su.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (su *SevUpdate) SaveX(ctx context.Context) int {
affected, err := su.Save(ctx)
if err != nil {
panic(err)
}
return affected
}
// Exec executes the query.
func (su *SevUpdate) Exec(ctx context.Context) error {
_, err := su.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (su *SevUpdate) ExecX(ctx context.Context) {
if err := su.Exec(ctx); err != nil {
panic(err)
}
}
// check runs all checks and user-defined validators on the builder.
func (su *SevUpdate) check() error {
if _, ok := su.mutation.OwnerID(); su.mutation.OwnerCleared() && !ok {
return errors.New(`ent: clearing a required unique edge "Sev.owner"`)
}
return nil
}
func (su *SevUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := su.check(); err != nil {
return n, err
}
_spec := sqlgraph.NewUpdateSpec(sev.Table, sev.Columns, sqlgraph.NewFieldSpec(sev.FieldID, field.TypeInt))
if ps := su.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := su.mutation.Token(); ok {
_spec.SetField(sev.FieldToken, field.TypeString, value)
}
if su.mutation.TokenCleared() {
_spec.ClearField(sev.FieldToken, field.TypeString)
}
if value, ok := su.mutation.Limit(); ok {
_spec.SetField(sev.FieldLimit, field.TypeBool, value)
}
if su.mutation.LimitCleared() {
_spec.ClearField(sev.FieldLimit, field.TypeBool)
}
if value, ok := su.mutation.Count(); ok {
_spec.SetField(sev.FieldCount, field.TypeInt, value)
}
if value, ok := su.mutation.AddedCount(); ok {
_spec.AddField(sev.FieldCount, field.TypeInt, value)
}
if su.mutation.CountCleared() {
_spec.ClearField(sev.FieldCount, field.TypeInt)
}
if value, ok := su.mutation.Handle(); ok {
_spec.SetField(sev.FieldHandle, field.TypeString, value)
}
if su.mutation.HandleCleared() {
_spec.ClearField(sev.FieldHandle, field.TypeString)
}
if value, ok := su.mutation.Did(); ok {
_spec.SetField(sev.FieldDid, field.TypeString, value)
}
if su.mutation.DidCleared() {
_spec.ClearField(sev.FieldDid, field.TypeString)
}
if value, ok := su.mutation.UID(); ok {
_spec.SetField(sev.FieldUID, field.TypeInt, value)
}
if value, ok := su.mutation.AddedUID(); ok {
_spec.AddField(sev.FieldUID, field.TypeInt, value)
}
if su.mutation.UIDCleared() {
_spec.ClearField(sev.FieldUID, field.TypeInt)
}
if value, ok := su.mutation.Cid(); ok {
_spec.SetField(sev.FieldCid, field.TypeInt, value)
}
if value, ok := su.mutation.AddedCid(); ok {
_spec.AddField(sev.FieldCid, field.TypeInt, value)
}
if su.mutation.CidCleared() {
_spec.ClearField(sev.FieldCid, field.TypeInt)
}
if value, ok := su.mutation.Cp(); ok {
_spec.SetField(sev.FieldCp, field.TypeInt, value)
}
if value, ok := su.mutation.AddedCp(); ok {
_spec.AddField(sev.FieldCp, field.TypeInt, value)
}
if su.mutation.CpCleared() {
_spec.ClearField(sev.FieldCp, field.TypeInt)
}
if value, ok := su.mutation.Card(); ok {
_spec.SetField(sev.FieldCard, field.TypeInt, value)
}
if value, ok := su.mutation.AddedCard(); ok {
_spec.AddField(sev.FieldCard, field.TypeInt, value)
}
if su.mutation.CardCleared() {
_spec.ClearField(sev.FieldCard, field.TypeInt)
}
if value, ok := su.mutation.UpdatedAt(); ok {
_spec.SetField(sev.FieldUpdatedAt, field.TypeTime, value)
}
if su.mutation.UpdatedAtCleared() {
_spec.ClearField(sev.FieldUpdatedAt, field.TypeTime)
}
if su.mutation.CreatedAtCleared() {
_spec.ClearField(sev.FieldCreatedAt, field.TypeTime)
}
if su.mutation.OwnerCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: sev.OwnerTable,
Columns: []string{sev.OwnerColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := su.mutation.OwnerIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: sev.OwnerTable,
Columns: []string{sev.OwnerColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if n, err = sqlgraph.UpdateNodes(ctx, su.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{sev.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
su.mutation.done = true
return n, nil
}
// SevUpdateOne is the builder for updating a single Sev entity.
type SevUpdateOne struct {
config
fields []string
hooks []Hook
mutation *SevMutation
}
// SetToken sets the "token" field.
func (suo *SevUpdateOne) SetToken(s string) *SevUpdateOne {
suo.mutation.SetToken(s)
return suo
}
// SetNillableToken sets the "token" field if the given value is not nil.
func (suo *SevUpdateOne) SetNillableToken(s *string) *SevUpdateOne {
if s != nil {
suo.SetToken(*s)
}
return suo
}
// ClearToken clears the value of the "token" field.
func (suo *SevUpdateOne) ClearToken() *SevUpdateOne {
suo.mutation.ClearToken()
return suo
}
// SetLimit sets the "limit" field.
func (suo *SevUpdateOne) SetLimit(b bool) *SevUpdateOne {
suo.mutation.SetLimit(b)
return suo
}
// SetNillableLimit sets the "limit" field if the given value is not nil.
func (suo *SevUpdateOne) SetNillableLimit(b *bool) *SevUpdateOne {
if b != nil {
suo.SetLimit(*b)
}
return suo
}
// ClearLimit clears the value of the "limit" field.
func (suo *SevUpdateOne) ClearLimit() *SevUpdateOne {
suo.mutation.ClearLimit()
return suo
}
// SetCount sets the "count" field.
func (suo *SevUpdateOne) SetCount(i int) *SevUpdateOne {
suo.mutation.ResetCount()
suo.mutation.SetCount(i)
return suo
}
// SetNillableCount sets the "count" field if the given value is not nil.
func (suo *SevUpdateOne) SetNillableCount(i *int) *SevUpdateOne {
if i != nil {
suo.SetCount(*i)
}
return suo
}
// AddCount adds i to the "count" field.
func (suo *SevUpdateOne) AddCount(i int) *SevUpdateOne {
suo.mutation.AddCount(i)
return suo
}
// ClearCount clears the value of the "count" field.
func (suo *SevUpdateOne) ClearCount() *SevUpdateOne {
suo.mutation.ClearCount()
return suo
}
// SetHandle sets the "handle" field.
func (suo *SevUpdateOne) SetHandle(s string) *SevUpdateOne {
suo.mutation.SetHandle(s)
return suo
}
// SetNillableHandle sets the "handle" field if the given value is not nil.
func (suo *SevUpdateOne) SetNillableHandle(s *string) *SevUpdateOne {
if s != nil {
suo.SetHandle(*s)
}
return suo
}
// ClearHandle clears the value of the "handle" field.
func (suo *SevUpdateOne) ClearHandle() *SevUpdateOne {
suo.mutation.ClearHandle()
return suo
}
// SetDid sets the "did" field.
func (suo *SevUpdateOne) SetDid(s string) *SevUpdateOne {
suo.mutation.SetDid(s)
return suo
}
// SetNillableDid sets the "did" field if the given value is not nil.
func (suo *SevUpdateOne) SetNillableDid(s *string) *SevUpdateOne {
if s != nil {
suo.SetDid(*s)
}
return suo
}
// ClearDid clears the value of the "did" field.
func (suo *SevUpdateOne) ClearDid() *SevUpdateOne {
suo.mutation.ClearDid()
return suo
}
// SetUID sets the "uid" field.
func (suo *SevUpdateOne) SetUID(i int) *SevUpdateOne {
suo.mutation.ResetUID()
suo.mutation.SetUID(i)
return suo
}
// SetNillableUID sets the "uid" field if the given value is not nil.
func (suo *SevUpdateOne) SetNillableUID(i *int) *SevUpdateOne {
if i != nil {
suo.SetUID(*i)
}
return suo
}
// AddUID adds i to the "uid" field.
func (suo *SevUpdateOne) AddUID(i int) *SevUpdateOne {
suo.mutation.AddUID(i)
return suo
}
// ClearUID clears the value of the "uid" field.
func (suo *SevUpdateOne) ClearUID() *SevUpdateOne {
suo.mutation.ClearUID()
return suo
}
// SetCid sets the "cid" field.
func (suo *SevUpdateOne) SetCid(i int) *SevUpdateOne {
suo.mutation.ResetCid()
suo.mutation.SetCid(i)
return suo
}
// SetNillableCid sets the "cid" field if the given value is not nil.
func (suo *SevUpdateOne) SetNillableCid(i *int) *SevUpdateOne {
if i != nil {
suo.SetCid(*i)
}
return suo
}
// AddCid adds i to the "cid" field.
func (suo *SevUpdateOne) AddCid(i int) *SevUpdateOne {
suo.mutation.AddCid(i)
return suo
}
// ClearCid clears the value of the "cid" field.
func (suo *SevUpdateOne) ClearCid() *SevUpdateOne {
suo.mutation.ClearCid()
return suo
}
// SetCp sets the "cp" field.
func (suo *SevUpdateOne) SetCp(i int) *SevUpdateOne {
suo.mutation.ResetCp()
suo.mutation.SetCp(i)
return suo
}
// SetNillableCp sets the "cp" field if the given value is not nil.
func (suo *SevUpdateOne) SetNillableCp(i *int) *SevUpdateOne {
if i != nil {
suo.SetCp(*i)
}
return suo
}
// AddCp adds i to the "cp" field.
func (suo *SevUpdateOne) AddCp(i int) *SevUpdateOne {
suo.mutation.AddCp(i)
return suo
}
// ClearCp clears the value of the "cp" field.
func (suo *SevUpdateOne) ClearCp() *SevUpdateOne {
suo.mutation.ClearCp()
return suo
}
// SetCard sets the "card" field.
func (suo *SevUpdateOne) SetCard(i int) *SevUpdateOne {
suo.mutation.ResetCard()
suo.mutation.SetCard(i)
return suo
}
// SetNillableCard sets the "card" field if the given value is not nil.
func (suo *SevUpdateOne) SetNillableCard(i *int) *SevUpdateOne {
if i != nil {
suo.SetCard(*i)
}
return suo
}
// AddCard adds i to the "card" field.
func (suo *SevUpdateOne) AddCard(i int) *SevUpdateOne {
suo.mutation.AddCard(i)
return suo
}
// ClearCard clears the value of the "card" field.
func (suo *SevUpdateOne) ClearCard() *SevUpdateOne {
suo.mutation.ClearCard()
return suo
}
// SetUpdatedAt sets the "updated_at" field.
func (suo *SevUpdateOne) SetUpdatedAt(t time.Time) *SevUpdateOne {
suo.mutation.SetUpdatedAt(t)
return suo
}
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func (suo *SevUpdateOne) SetNillableUpdatedAt(t *time.Time) *SevUpdateOne {
if t != nil {
suo.SetUpdatedAt(*t)
}
return suo
}
// ClearUpdatedAt clears the value of the "updated_at" field.
func (suo *SevUpdateOne) ClearUpdatedAt() *SevUpdateOne {
suo.mutation.ClearUpdatedAt()
return suo
}
// SetOwnerID sets the "owner" edge to the User entity by ID.
func (suo *SevUpdateOne) SetOwnerID(id int) *SevUpdateOne {
suo.mutation.SetOwnerID(id)
return suo
}
// SetOwner sets the "owner" edge to the User entity.
func (suo *SevUpdateOne) SetOwner(u *User) *SevUpdateOne {
return suo.SetOwnerID(u.ID)
}
// Mutation returns the SevMutation object of the builder.
func (suo *SevUpdateOne) Mutation() *SevMutation {
return suo.mutation
}
// ClearOwner clears the "owner" edge to the User entity.
func (suo *SevUpdateOne) ClearOwner() *SevUpdateOne {
suo.mutation.ClearOwner()
return suo
}
// Where appends a list predicates to the SevUpdate builder.
func (suo *SevUpdateOne) Where(ps ...predicate.Sev) *SevUpdateOne {
suo.mutation.Where(ps...)
return suo
}
// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func (suo *SevUpdateOne) Select(field string, fields ...string) *SevUpdateOne {
suo.fields = append([]string{field}, fields...)
return suo
}
// Save executes the query and returns the updated Sev entity.
func (suo *SevUpdateOne) Save(ctx context.Context) (*Sev, error) {
return withHooks[*Sev, SevMutation](ctx, suo.sqlSave, suo.mutation, suo.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (suo *SevUpdateOne) SaveX(ctx context.Context) *Sev {
node, err := suo.Save(ctx)
if err != nil {
panic(err)
}
return node
}
// Exec executes the query on the entity.
func (suo *SevUpdateOne) Exec(ctx context.Context) error {
_, err := suo.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (suo *SevUpdateOne) ExecX(ctx context.Context) {
if err := suo.Exec(ctx); err != nil {
panic(err)
}
}
// check runs all checks and user-defined validators on the builder.
func (suo *SevUpdateOne) check() error {
if _, ok := suo.mutation.OwnerID(); suo.mutation.OwnerCleared() && !ok {
return errors.New(`ent: clearing a required unique edge "Sev.owner"`)
}
return nil
}
func (suo *SevUpdateOne) sqlSave(ctx context.Context) (_node *Sev, err error) {
if err := suo.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(sev.Table, sev.Columns, sqlgraph.NewFieldSpec(sev.FieldID, field.TypeInt))
id, ok := suo.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Sev.id" for update`)}
}
_spec.Node.ID.Value = id
if fields := suo.fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, sev.FieldID)
for _, f := range fields {
if !sev.ValidColumn(f) {
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
if f != sev.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, f)
}
}
}
if ps := suo.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := suo.mutation.Token(); ok {
_spec.SetField(sev.FieldToken, field.TypeString, value)
}
if suo.mutation.TokenCleared() {
_spec.ClearField(sev.FieldToken, field.TypeString)
}
if value, ok := suo.mutation.Limit(); ok {
_spec.SetField(sev.FieldLimit, field.TypeBool, value)
}
if suo.mutation.LimitCleared() {
_spec.ClearField(sev.FieldLimit, field.TypeBool)
}
if value, ok := suo.mutation.Count(); ok {
_spec.SetField(sev.FieldCount, field.TypeInt, value)
}
if value, ok := suo.mutation.AddedCount(); ok {
_spec.AddField(sev.FieldCount, field.TypeInt, value)
}
if suo.mutation.CountCleared() {
_spec.ClearField(sev.FieldCount, field.TypeInt)
}
if value, ok := suo.mutation.Handle(); ok {
_spec.SetField(sev.FieldHandle, field.TypeString, value)
}
if suo.mutation.HandleCleared() {
_spec.ClearField(sev.FieldHandle, field.TypeString)
}
if value, ok := suo.mutation.Did(); ok {
_spec.SetField(sev.FieldDid, field.TypeString, value)
}
if suo.mutation.DidCleared() {
_spec.ClearField(sev.FieldDid, field.TypeString)
}
if value, ok := suo.mutation.UID(); ok {
_spec.SetField(sev.FieldUID, field.TypeInt, value)
}
if value, ok := suo.mutation.AddedUID(); ok {
_spec.AddField(sev.FieldUID, field.TypeInt, value)
}
if suo.mutation.UIDCleared() {
_spec.ClearField(sev.FieldUID, field.TypeInt)
}
if value, ok := suo.mutation.Cid(); ok {
_spec.SetField(sev.FieldCid, field.TypeInt, value)
}
if value, ok := suo.mutation.AddedCid(); ok {
_spec.AddField(sev.FieldCid, field.TypeInt, value)
}
if suo.mutation.CidCleared() {
_spec.ClearField(sev.FieldCid, field.TypeInt)
}
if value, ok := suo.mutation.Cp(); ok {
_spec.SetField(sev.FieldCp, field.TypeInt, value)
}
if value, ok := suo.mutation.AddedCp(); ok {
_spec.AddField(sev.FieldCp, field.TypeInt, value)
}
if suo.mutation.CpCleared() {
_spec.ClearField(sev.FieldCp, field.TypeInt)
}
if value, ok := suo.mutation.Card(); ok {
_spec.SetField(sev.FieldCard, field.TypeInt, value)
}
if value, ok := suo.mutation.AddedCard(); ok {
_spec.AddField(sev.FieldCard, field.TypeInt, value)
}
if suo.mutation.CardCleared() {
_spec.ClearField(sev.FieldCard, field.TypeInt)
}
if value, ok := suo.mutation.UpdatedAt(); ok {
_spec.SetField(sev.FieldUpdatedAt, field.TypeTime, value)
}
if suo.mutation.UpdatedAtCleared() {
_spec.ClearField(sev.FieldUpdatedAt, field.TypeTime)
}
if suo.mutation.CreatedAtCleared() {
_spec.ClearField(sev.FieldCreatedAt, field.TypeTime)
}
if suo.mutation.OwnerCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: sev.OwnerTable,
Columns: []string{sev.OwnerColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := suo.mutation.OwnerIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: sev.OwnerTable,
Columns: []string{sev.OwnerColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
_node = &Sev{config: suo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
if err = sqlgraph.UpdateNode(ctx, suo.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{sev.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
suo.mutation.done = true
return _node, nil
}