1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189 |
- // Code generated by ent, DO NOT EDIT.
- package ent
- import (
- "context"
- "errors"
- "fmt"
- "time"
- "wechat-api/ent/custom_types"
- "wechat-api/ent/messagerecords"
- "wechat-api/ent/predicate"
- "wechat-api/ent/sopnode"
- "wechat-api/ent/sopstage"
- "wechat-api/ent/soptask"
- "entgo.io/ent/dialect/sql"
- "entgo.io/ent/dialect/sql/sqlgraph"
- "entgo.io/ent/dialect/sql/sqljson"
- "entgo.io/ent/schema/field"
- )
- // SopStageUpdate is the builder for updating SopStage entities.
- type SopStageUpdate struct {
- config
- hooks []Hook
- mutation *SopStageMutation
- }
- // Where appends a list predicates to the SopStageUpdate builder.
- func (ssu *SopStageUpdate) Where(ps ...predicate.SopStage) *SopStageUpdate {
- ssu.mutation.Where(ps...)
- return ssu
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (ssu *SopStageUpdate) SetUpdatedAt(t time.Time) *SopStageUpdate {
- ssu.mutation.SetUpdatedAt(t)
- return ssu
- }
- // SetStatus sets the "status" field.
- func (ssu *SopStageUpdate) SetStatus(u uint8) *SopStageUpdate {
- ssu.mutation.ResetStatus()
- ssu.mutation.SetStatus(u)
- return ssu
- }
- // SetNillableStatus sets the "status" field if the given value is not nil.
- func (ssu *SopStageUpdate) SetNillableStatus(u *uint8) *SopStageUpdate {
- if u != nil {
- ssu.SetStatus(*u)
- }
- return ssu
- }
- // AddStatus adds u to the "status" field.
- func (ssu *SopStageUpdate) AddStatus(u int8) *SopStageUpdate {
- ssu.mutation.AddStatus(u)
- return ssu
- }
- // ClearStatus clears the value of the "status" field.
- func (ssu *SopStageUpdate) ClearStatus() *SopStageUpdate {
- ssu.mutation.ClearStatus()
- return ssu
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (ssu *SopStageUpdate) SetDeletedAt(t time.Time) *SopStageUpdate {
- ssu.mutation.SetDeletedAt(t)
- return ssu
- }
- // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
- func (ssu *SopStageUpdate) SetNillableDeletedAt(t *time.Time) *SopStageUpdate {
- if t != nil {
- ssu.SetDeletedAt(*t)
- }
- return ssu
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (ssu *SopStageUpdate) ClearDeletedAt() *SopStageUpdate {
- ssu.mutation.ClearDeletedAt()
- return ssu
- }
- // SetTaskID sets the "task_id" field.
- func (ssu *SopStageUpdate) SetTaskID(u uint64) *SopStageUpdate {
- ssu.mutation.SetTaskID(u)
- return ssu
- }
- // SetNillableTaskID sets the "task_id" field if the given value is not nil.
- func (ssu *SopStageUpdate) SetNillableTaskID(u *uint64) *SopStageUpdate {
- if u != nil {
- ssu.SetTaskID(*u)
- }
- return ssu
- }
- // SetName sets the "name" field.
- func (ssu *SopStageUpdate) SetName(s string) *SopStageUpdate {
- ssu.mutation.SetName(s)
- return ssu
- }
- // SetNillableName sets the "name" field if the given value is not nil.
- func (ssu *SopStageUpdate) SetNillableName(s *string) *SopStageUpdate {
- if s != nil {
- ssu.SetName(*s)
- }
- return ssu
- }
- // SetConditionType sets the "condition_type" field.
- func (ssu *SopStageUpdate) SetConditionType(i int) *SopStageUpdate {
- ssu.mutation.ResetConditionType()
- ssu.mutation.SetConditionType(i)
- return ssu
- }
- // SetNillableConditionType sets the "condition_type" field if the given value is not nil.
- func (ssu *SopStageUpdate) SetNillableConditionType(i *int) *SopStageUpdate {
- if i != nil {
- ssu.SetConditionType(*i)
- }
- return ssu
- }
- // AddConditionType adds i to the "condition_type" field.
- func (ssu *SopStageUpdate) AddConditionType(i int) *SopStageUpdate {
- ssu.mutation.AddConditionType(i)
- return ssu
- }
- // SetConditionOperator sets the "condition_operator" field.
- func (ssu *SopStageUpdate) SetConditionOperator(i int) *SopStageUpdate {
- ssu.mutation.ResetConditionOperator()
- ssu.mutation.SetConditionOperator(i)
- return ssu
- }
- // SetNillableConditionOperator sets the "condition_operator" field if the given value is not nil.
- func (ssu *SopStageUpdate) SetNillableConditionOperator(i *int) *SopStageUpdate {
- if i != nil {
- ssu.SetConditionOperator(*i)
- }
- return ssu
- }
- // AddConditionOperator adds i to the "condition_operator" field.
- func (ssu *SopStageUpdate) AddConditionOperator(i int) *SopStageUpdate {
- ssu.mutation.AddConditionOperator(i)
- return ssu
- }
- // SetConditionList sets the "condition_list" field.
- func (ssu *SopStageUpdate) SetConditionList(ct []custom_types.Condition) *SopStageUpdate {
- ssu.mutation.SetConditionList(ct)
- return ssu
- }
- // AppendConditionList appends ct to the "condition_list" field.
- func (ssu *SopStageUpdate) AppendConditionList(ct []custom_types.Condition) *SopStageUpdate {
- ssu.mutation.AppendConditionList(ct)
- return ssu
- }
- // SetActionMessage sets the "action_message" field.
- func (ssu *SopStageUpdate) SetActionMessage(ct []custom_types.Action) *SopStageUpdate {
- ssu.mutation.SetActionMessage(ct)
- return ssu
- }
- // AppendActionMessage appends ct to the "action_message" field.
- func (ssu *SopStageUpdate) AppendActionMessage(ct []custom_types.Action) *SopStageUpdate {
- ssu.mutation.AppendActionMessage(ct)
- return ssu
- }
- // ClearActionMessage clears the value of the "action_message" field.
- func (ssu *SopStageUpdate) ClearActionMessage() *SopStageUpdate {
- ssu.mutation.ClearActionMessage()
- return ssu
- }
- // SetActionLabel sets the "action_label" field.
- func (ssu *SopStageUpdate) SetActionLabel(u []uint64) *SopStageUpdate {
- ssu.mutation.SetActionLabel(u)
- return ssu
- }
- // AppendActionLabel appends u to the "action_label" field.
- func (ssu *SopStageUpdate) AppendActionLabel(u []uint64) *SopStageUpdate {
- ssu.mutation.AppendActionLabel(u)
- return ssu
- }
- // ClearActionLabel clears the value of the "action_label" field.
- func (ssu *SopStageUpdate) ClearActionLabel() *SopStageUpdate {
- ssu.mutation.ClearActionLabel()
- return ssu
- }
- // SetIndexSort sets the "index_sort" field.
- func (ssu *SopStageUpdate) SetIndexSort(i int) *SopStageUpdate {
- ssu.mutation.ResetIndexSort()
- ssu.mutation.SetIndexSort(i)
- return ssu
- }
- // SetNillableIndexSort sets the "index_sort" field if the given value is not nil.
- func (ssu *SopStageUpdate) SetNillableIndexSort(i *int) *SopStageUpdate {
- if i != nil {
- ssu.SetIndexSort(*i)
- }
- return ssu
- }
- // AddIndexSort adds i to the "index_sort" field.
- func (ssu *SopStageUpdate) AddIndexSort(i int) *SopStageUpdate {
- ssu.mutation.AddIndexSort(i)
- return ssu
- }
- // ClearIndexSort clears the value of the "index_sort" field.
- func (ssu *SopStageUpdate) ClearIndexSort() *SopStageUpdate {
- ssu.mutation.ClearIndexSort()
- return ssu
- }
- // SetSopTaskID sets the "sop_task" edge to the SopTask entity by ID.
- func (ssu *SopStageUpdate) SetSopTaskID(id uint64) *SopStageUpdate {
- ssu.mutation.SetSopTaskID(id)
- return ssu
- }
- // SetSopTask sets the "sop_task" edge to the SopTask entity.
- func (ssu *SopStageUpdate) SetSopTask(s *SopTask) *SopStageUpdate {
- return ssu.SetSopTaskID(s.ID)
- }
- // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by IDs.
- func (ssu *SopStageUpdate) AddStageNodeIDs(ids ...uint64) *SopStageUpdate {
- ssu.mutation.AddStageNodeIDs(ids...)
- return ssu
- }
- // AddStageNodes adds the "stage_nodes" edges to the SopNode entity.
- func (ssu *SopStageUpdate) AddStageNodes(s ...*SopNode) *SopStageUpdate {
- ids := make([]uint64, len(s))
- for i := range s {
- ids[i] = s[i].ID
- }
- return ssu.AddStageNodeIDs(ids...)
- }
- // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by IDs.
- func (ssu *SopStageUpdate) AddStageMessageIDs(ids ...uint64) *SopStageUpdate {
- ssu.mutation.AddStageMessageIDs(ids...)
- return ssu
- }
- // AddStageMessages adds the "stage_messages" edges to the MessageRecords entity.
- func (ssu *SopStageUpdate) AddStageMessages(m ...*MessageRecords) *SopStageUpdate {
- ids := make([]uint64, len(m))
- for i := range m {
- ids[i] = m[i].ID
- }
- return ssu.AddStageMessageIDs(ids...)
- }
- // Mutation returns the SopStageMutation object of the builder.
- func (ssu *SopStageUpdate) Mutation() *SopStageMutation {
- return ssu.mutation
- }
- // ClearSopTask clears the "sop_task" edge to the SopTask entity.
- func (ssu *SopStageUpdate) ClearSopTask() *SopStageUpdate {
- ssu.mutation.ClearSopTask()
- return ssu
- }
- // ClearStageNodes clears all "stage_nodes" edges to the SopNode entity.
- func (ssu *SopStageUpdate) ClearStageNodes() *SopStageUpdate {
- ssu.mutation.ClearStageNodes()
- return ssu
- }
- // RemoveStageNodeIDs removes the "stage_nodes" edge to SopNode entities by IDs.
- func (ssu *SopStageUpdate) RemoveStageNodeIDs(ids ...uint64) *SopStageUpdate {
- ssu.mutation.RemoveStageNodeIDs(ids...)
- return ssu
- }
- // RemoveStageNodes removes "stage_nodes" edges to SopNode entities.
- func (ssu *SopStageUpdate) RemoveStageNodes(s ...*SopNode) *SopStageUpdate {
- ids := make([]uint64, len(s))
- for i := range s {
- ids[i] = s[i].ID
- }
- return ssu.RemoveStageNodeIDs(ids...)
- }
- // ClearStageMessages clears all "stage_messages" edges to the MessageRecords entity.
- func (ssu *SopStageUpdate) ClearStageMessages() *SopStageUpdate {
- ssu.mutation.ClearStageMessages()
- return ssu
- }
- // RemoveStageMessageIDs removes the "stage_messages" edge to MessageRecords entities by IDs.
- func (ssu *SopStageUpdate) RemoveStageMessageIDs(ids ...uint64) *SopStageUpdate {
- ssu.mutation.RemoveStageMessageIDs(ids...)
- return ssu
- }
- // RemoveStageMessages removes "stage_messages" edges to MessageRecords entities.
- func (ssu *SopStageUpdate) RemoveStageMessages(m ...*MessageRecords) *SopStageUpdate {
- ids := make([]uint64, len(m))
- for i := range m {
- ids[i] = m[i].ID
- }
- return ssu.RemoveStageMessageIDs(ids...)
- }
- // Save executes the query and returns the number of nodes affected by the update operation.
- func (ssu *SopStageUpdate) Save(ctx context.Context) (int, error) {
- if err := ssu.defaults(); err != nil {
- return 0, err
- }
- return withHooks(ctx, ssu.sqlSave, ssu.mutation, ssu.hooks)
- }
- // SaveX is like Save, but panics if an error occurs.
- func (ssu *SopStageUpdate) SaveX(ctx context.Context) int {
- affected, err := ssu.Save(ctx)
- if err != nil {
- panic(err)
- }
- return affected
- }
- // Exec executes the query.
- func (ssu *SopStageUpdate) Exec(ctx context.Context) error {
- _, err := ssu.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (ssu *SopStageUpdate) ExecX(ctx context.Context) {
- if err := ssu.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // defaults sets the default values of the builder before save.
- func (ssu *SopStageUpdate) defaults() error {
- if _, ok := ssu.mutation.UpdatedAt(); !ok {
- if sopstage.UpdateDefaultUpdatedAt == nil {
- return fmt.Errorf("ent: uninitialized sopstage.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
- }
- v := sopstage.UpdateDefaultUpdatedAt()
- ssu.mutation.SetUpdatedAt(v)
- }
- return nil
- }
- // check runs all checks and user-defined validators on the builder.
- func (ssu *SopStageUpdate) check() error {
- if _, ok := ssu.mutation.SopTaskID(); ssu.mutation.SopTaskCleared() && !ok {
- return errors.New(`ent: clearing a required unique edge "SopStage.sop_task"`)
- }
- return nil
- }
- func (ssu *SopStageUpdate) sqlSave(ctx context.Context) (n int, err error) {
- if err := ssu.check(); err != nil {
- return n, err
- }
- _spec := sqlgraph.NewUpdateSpec(sopstage.Table, sopstage.Columns, sqlgraph.NewFieldSpec(sopstage.FieldID, field.TypeUint64))
- if ps := ssu.mutation.predicates; len(ps) > 0 {
- _spec.Predicate = func(selector *sql.Selector) {
- for i := range ps {
- ps[i](selector)
- }
- }
- }
- if value, ok := ssu.mutation.UpdatedAt(); ok {
- _spec.SetField(sopstage.FieldUpdatedAt, field.TypeTime, value)
- }
- if value, ok := ssu.mutation.Status(); ok {
- _spec.SetField(sopstage.FieldStatus, field.TypeUint8, value)
- }
- if value, ok := ssu.mutation.AddedStatus(); ok {
- _spec.AddField(sopstage.FieldStatus, field.TypeUint8, value)
- }
- if ssu.mutation.StatusCleared() {
- _spec.ClearField(sopstage.FieldStatus, field.TypeUint8)
- }
- if value, ok := ssu.mutation.DeletedAt(); ok {
- _spec.SetField(sopstage.FieldDeletedAt, field.TypeTime, value)
- }
- if ssu.mutation.DeletedAtCleared() {
- _spec.ClearField(sopstage.FieldDeletedAt, field.TypeTime)
- }
- if value, ok := ssu.mutation.Name(); ok {
- _spec.SetField(sopstage.FieldName, field.TypeString, value)
- }
- if value, ok := ssu.mutation.ConditionType(); ok {
- _spec.SetField(sopstage.FieldConditionType, field.TypeInt, value)
- }
- if value, ok := ssu.mutation.AddedConditionType(); ok {
- _spec.AddField(sopstage.FieldConditionType, field.TypeInt, value)
- }
- if value, ok := ssu.mutation.ConditionOperator(); ok {
- _spec.SetField(sopstage.FieldConditionOperator, field.TypeInt, value)
- }
- if value, ok := ssu.mutation.AddedConditionOperator(); ok {
- _spec.AddField(sopstage.FieldConditionOperator, field.TypeInt, value)
- }
- if value, ok := ssu.mutation.ConditionList(); ok {
- _spec.SetField(sopstage.FieldConditionList, field.TypeJSON, value)
- }
- if value, ok := ssu.mutation.AppendedConditionList(); ok {
- _spec.AddModifier(func(u *sql.UpdateBuilder) {
- sqljson.Append(u, sopstage.FieldConditionList, value)
- })
- }
- if value, ok := ssu.mutation.ActionMessage(); ok {
- _spec.SetField(sopstage.FieldActionMessage, field.TypeJSON, value)
- }
- if value, ok := ssu.mutation.AppendedActionMessage(); ok {
- _spec.AddModifier(func(u *sql.UpdateBuilder) {
- sqljson.Append(u, sopstage.FieldActionMessage, value)
- })
- }
- if ssu.mutation.ActionMessageCleared() {
- _spec.ClearField(sopstage.FieldActionMessage, field.TypeJSON)
- }
- if value, ok := ssu.mutation.ActionLabel(); ok {
- _spec.SetField(sopstage.FieldActionLabel, field.TypeJSON, value)
- }
- if value, ok := ssu.mutation.AppendedActionLabel(); ok {
- _spec.AddModifier(func(u *sql.UpdateBuilder) {
- sqljson.Append(u, sopstage.FieldActionLabel, value)
- })
- }
- if ssu.mutation.ActionLabelCleared() {
- _spec.ClearField(sopstage.FieldActionLabel, field.TypeJSON)
- }
- if value, ok := ssu.mutation.IndexSort(); ok {
- _spec.SetField(sopstage.FieldIndexSort, field.TypeInt, value)
- }
- if value, ok := ssu.mutation.AddedIndexSort(); ok {
- _spec.AddField(sopstage.FieldIndexSort, field.TypeInt, value)
- }
- if ssu.mutation.IndexSortCleared() {
- _spec.ClearField(sopstage.FieldIndexSort, field.TypeInt)
- }
- if ssu.mutation.SopTaskCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: sopstage.SopTaskTable,
- Columns: []string{sopstage.SopTaskColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(soptask.FieldID, field.TypeUint64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := ssu.mutation.SopTaskIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: sopstage.SopTaskTable,
- Columns: []string{sopstage.SopTaskColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(soptask.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- if ssu.mutation.StageNodesCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: sopstage.StageNodesTable,
- Columns: []string{sopstage.StageNodesColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(sopnode.FieldID, field.TypeUint64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := ssu.mutation.RemovedStageNodesIDs(); len(nodes) > 0 && !ssu.mutation.StageNodesCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: sopstage.StageNodesTable,
- Columns: []string{sopstage.StageNodesColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(sopnode.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := ssu.mutation.StageNodesIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: sopstage.StageNodesTable,
- Columns: []string{sopstage.StageNodesColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(sopnode.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- if ssu.mutation.StageMessagesCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: sopstage.StageMessagesTable,
- Columns: []string{sopstage.StageMessagesColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(messagerecords.FieldID, field.TypeUint64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := ssu.mutation.RemovedStageMessagesIDs(); len(nodes) > 0 && !ssu.mutation.StageMessagesCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: sopstage.StageMessagesTable,
- Columns: []string{sopstage.StageMessagesColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(messagerecords.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := ssu.mutation.StageMessagesIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: sopstage.StageMessagesTable,
- Columns: []string{sopstage.StageMessagesColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(messagerecords.FieldID, field.TypeUint64),
- },
- }
- 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, ssu.driver, _spec); err != nil {
- if _, ok := err.(*sqlgraph.NotFoundError); ok {
- err = &NotFoundError{sopstage.Label}
- } else if sqlgraph.IsConstraintError(err) {
- err = &ConstraintError{msg: err.Error(), wrap: err}
- }
- return 0, err
- }
- ssu.mutation.done = true
- return n, nil
- }
- // SopStageUpdateOne is the builder for updating a single SopStage entity.
- type SopStageUpdateOne struct {
- config
- fields []string
- hooks []Hook
- mutation *SopStageMutation
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (ssuo *SopStageUpdateOne) SetUpdatedAt(t time.Time) *SopStageUpdateOne {
- ssuo.mutation.SetUpdatedAt(t)
- return ssuo
- }
- // SetStatus sets the "status" field.
- func (ssuo *SopStageUpdateOne) SetStatus(u uint8) *SopStageUpdateOne {
- ssuo.mutation.ResetStatus()
- ssuo.mutation.SetStatus(u)
- return ssuo
- }
- // SetNillableStatus sets the "status" field if the given value is not nil.
- func (ssuo *SopStageUpdateOne) SetNillableStatus(u *uint8) *SopStageUpdateOne {
- if u != nil {
- ssuo.SetStatus(*u)
- }
- return ssuo
- }
- // AddStatus adds u to the "status" field.
- func (ssuo *SopStageUpdateOne) AddStatus(u int8) *SopStageUpdateOne {
- ssuo.mutation.AddStatus(u)
- return ssuo
- }
- // ClearStatus clears the value of the "status" field.
- func (ssuo *SopStageUpdateOne) ClearStatus() *SopStageUpdateOne {
- ssuo.mutation.ClearStatus()
- return ssuo
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (ssuo *SopStageUpdateOne) SetDeletedAt(t time.Time) *SopStageUpdateOne {
- ssuo.mutation.SetDeletedAt(t)
- return ssuo
- }
- // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
- func (ssuo *SopStageUpdateOne) SetNillableDeletedAt(t *time.Time) *SopStageUpdateOne {
- if t != nil {
- ssuo.SetDeletedAt(*t)
- }
- return ssuo
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (ssuo *SopStageUpdateOne) ClearDeletedAt() *SopStageUpdateOne {
- ssuo.mutation.ClearDeletedAt()
- return ssuo
- }
- // SetTaskID sets the "task_id" field.
- func (ssuo *SopStageUpdateOne) SetTaskID(u uint64) *SopStageUpdateOne {
- ssuo.mutation.SetTaskID(u)
- return ssuo
- }
- // SetNillableTaskID sets the "task_id" field if the given value is not nil.
- func (ssuo *SopStageUpdateOne) SetNillableTaskID(u *uint64) *SopStageUpdateOne {
- if u != nil {
- ssuo.SetTaskID(*u)
- }
- return ssuo
- }
- // SetName sets the "name" field.
- func (ssuo *SopStageUpdateOne) SetName(s string) *SopStageUpdateOne {
- ssuo.mutation.SetName(s)
- return ssuo
- }
- // SetNillableName sets the "name" field if the given value is not nil.
- func (ssuo *SopStageUpdateOne) SetNillableName(s *string) *SopStageUpdateOne {
- if s != nil {
- ssuo.SetName(*s)
- }
- return ssuo
- }
- // SetConditionType sets the "condition_type" field.
- func (ssuo *SopStageUpdateOne) SetConditionType(i int) *SopStageUpdateOne {
- ssuo.mutation.ResetConditionType()
- ssuo.mutation.SetConditionType(i)
- return ssuo
- }
- // SetNillableConditionType sets the "condition_type" field if the given value is not nil.
- func (ssuo *SopStageUpdateOne) SetNillableConditionType(i *int) *SopStageUpdateOne {
- if i != nil {
- ssuo.SetConditionType(*i)
- }
- return ssuo
- }
- // AddConditionType adds i to the "condition_type" field.
- func (ssuo *SopStageUpdateOne) AddConditionType(i int) *SopStageUpdateOne {
- ssuo.mutation.AddConditionType(i)
- return ssuo
- }
- // SetConditionOperator sets the "condition_operator" field.
- func (ssuo *SopStageUpdateOne) SetConditionOperator(i int) *SopStageUpdateOne {
- ssuo.mutation.ResetConditionOperator()
- ssuo.mutation.SetConditionOperator(i)
- return ssuo
- }
- // SetNillableConditionOperator sets the "condition_operator" field if the given value is not nil.
- func (ssuo *SopStageUpdateOne) SetNillableConditionOperator(i *int) *SopStageUpdateOne {
- if i != nil {
- ssuo.SetConditionOperator(*i)
- }
- return ssuo
- }
- // AddConditionOperator adds i to the "condition_operator" field.
- func (ssuo *SopStageUpdateOne) AddConditionOperator(i int) *SopStageUpdateOne {
- ssuo.mutation.AddConditionOperator(i)
- return ssuo
- }
- // SetConditionList sets the "condition_list" field.
- func (ssuo *SopStageUpdateOne) SetConditionList(ct []custom_types.Condition) *SopStageUpdateOne {
- ssuo.mutation.SetConditionList(ct)
- return ssuo
- }
- // AppendConditionList appends ct to the "condition_list" field.
- func (ssuo *SopStageUpdateOne) AppendConditionList(ct []custom_types.Condition) *SopStageUpdateOne {
- ssuo.mutation.AppendConditionList(ct)
- return ssuo
- }
- // SetActionMessage sets the "action_message" field.
- func (ssuo *SopStageUpdateOne) SetActionMessage(ct []custom_types.Action) *SopStageUpdateOne {
- ssuo.mutation.SetActionMessage(ct)
- return ssuo
- }
- // AppendActionMessage appends ct to the "action_message" field.
- func (ssuo *SopStageUpdateOne) AppendActionMessage(ct []custom_types.Action) *SopStageUpdateOne {
- ssuo.mutation.AppendActionMessage(ct)
- return ssuo
- }
- // ClearActionMessage clears the value of the "action_message" field.
- func (ssuo *SopStageUpdateOne) ClearActionMessage() *SopStageUpdateOne {
- ssuo.mutation.ClearActionMessage()
- return ssuo
- }
- // SetActionLabel sets the "action_label" field.
- func (ssuo *SopStageUpdateOne) SetActionLabel(u []uint64) *SopStageUpdateOne {
- ssuo.mutation.SetActionLabel(u)
- return ssuo
- }
- // AppendActionLabel appends u to the "action_label" field.
- func (ssuo *SopStageUpdateOne) AppendActionLabel(u []uint64) *SopStageUpdateOne {
- ssuo.mutation.AppendActionLabel(u)
- return ssuo
- }
- // ClearActionLabel clears the value of the "action_label" field.
- func (ssuo *SopStageUpdateOne) ClearActionLabel() *SopStageUpdateOne {
- ssuo.mutation.ClearActionLabel()
- return ssuo
- }
- // SetIndexSort sets the "index_sort" field.
- func (ssuo *SopStageUpdateOne) SetIndexSort(i int) *SopStageUpdateOne {
- ssuo.mutation.ResetIndexSort()
- ssuo.mutation.SetIndexSort(i)
- return ssuo
- }
- // SetNillableIndexSort sets the "index_sort" field if the given value is not nil.
- func (ssuo *SopStageUpdateOne) SetNillableIndexSort(i *int) *SopStageUpdateOne {
- if i != nil {
- ssuo.SetIndexSort(*i)
- }
- return ssuo
- }
- // AddIndexSort adds i to the "index_sort" field.
- func (ssuo *SopStageUpdateOne) AddIndexSort(i int) *SopStageUpdateOne {
- ssuo.mutation.AddIndexSort(i)
- return ssuo
- }
- // ClearIndexSort clears the value of the "index_sort" field.
- func (ssuo *SopStageUpdateOne) ClearIndexSort() *SopStageUpdateOne {
- ssuo.mutation.ClearIndexSort()
- return ssuo
- }
- // SetSopTaskID sets the "sop_task" edge to the SopTask entity by ID.
- func (ssuo *SopStageUpdateOne) SetSopTaskID(id uint64) *SopStageUpdateOne {
- ssuo.mutation.SetSopTaskID(id)
- return ssuo
- }
- // SetSopTask sets the "sop_task" edge to the SopTask entity.
- func (ssuo *SopStageUpdateOne) SetSopTask(s *SopTask) *SopStageUpdateOne {
- return ssuo.SetSopTaskID(s.ID)
- }
- // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by IDs.
- func (ssuo *SopStageUpdateOne) AddStageNodeIDs(ids ...uint64) *SopStageUpdateOne {
- ssuo.mutation.AddStageNodeIDs(ids...)
- return ssuo
- }
- // AddStageNodes adds the "stage_nodes" edges to the SopNode entity.
- func (ssuo *SopStageUpdateOne) AddStageNodes(s ...*SopNode) *SopStageUpdateOne {
- ids := make([]uint64, len(s))
- for i := range s {
- ids[i] = s[i].ID
- }
- return ssuo.AddStageNodeIDs(ids...)
- }
- // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by IDs.
- func (ssuo *SopStageUpdateOne) AddStageMessageIDs(ids ...uint64) *SopStageUpdateOne {
- ssuo.mutation.AddStageMessageIDs(ids...)
- return ssuo
- }
- // AddStageMessages adds the "stage_messages" edges to the MessageRecords entity.
- func (ssuo *SopStageUpdateOne) AddStageMessages(m ...*MessageRecords) *SopStageUpdateOne {
- ids := make([]uint64, len(m))
- for i := range m {
- ids[i] = m[i].ID
- }
- return ssuo.AddStageMessageIDs(ids...)
- }
- // Mutation returns the SopStageMutation object of the builder.
- func (ssuo *SopStageUpdateOne) Mutation() *SopStageMutation {
- return ssuo.mutation
- }
- // ClearSopTask clears the "sop_task" edge to the SopTask entity.
- func (ssuo *SopStageUpdateOne) ClearSopTask() *SopStageUpdateOne {
- ssuo.mutation.ClearSopTask()
- return ssuo
- }
- // ClearStageNodes clears all "stage_nodes" edges to the SopNode entity.
- func (ssuo *SopStageUpdateOne) ClearStageNodes() *SopStageUpdateOne {
- ssuo.mutation.ClearStageNodes()
- return ssuo
- }
- // RemoveStageNodeIDs removes the "stage_nodes" edge to SopNode entities by IDs.
- func (ssuo *SopStageUpdateOne) RemoveStageNodeIDs(ids ...uint64) *SopStageUpdateOne {
- ssuo.mutation.RemoveStageNodeIDs(ids...)
- return ssuo
- }
- // RemoveStageNodes removes "stage_nodes" edges to SopNode entities.
- func (ssuo *SopStageUpdateOne) RemoveStageNodes(s ...*SopNode) *SopStageUpdateOne {
- ids := make([]uint64, len(s))
- for i := range s {
- ids[i] = s[i].ID
- }
- return ssuo.RemoveStageNodeIDs(ids...)
- }
- // ClearStageMessages clears all "stage_messages" edges to the MessageRecords entity.
- func (ssuo *SopStageUpdateOne) ClearStageMessages() *SopStageUpdateOne {
- ssuo.mutation.ClearStageMessages()
- return ssuo
- }
- // RemoveStageMessageIDs removes the "stage_messages" edge to MessageRecords entities by IDs.
- func (ssuo *SopStageUpdateOne) RemoveStageMessageIDs(ids ...uint64) *SopStageUpdateOne {
- ssuo.mutation.RemoveStageMessageIDs(ids...)
- return ssuo
- }
- // RemoveStageMessages removes "stage_messages" edges to MessageRecords entities.
- func (ssuo *SopStageUpdateOne) RemoveStageMessages(m ...*MessageRecords) *SopStageUpdateOne {
- ids := make([]uint64, len(m))
- for i := range m {
- ids[i] = m[i].ID
- }
- return ssuo.RemoveStageMessageIDs(ids...)
- }
- // Where appends a list predicates to the SopStageUpdate builder.
- func (ssuo *SopStageUpdateOne) Where(ps ...predicate.SopStage) *SopStageUpdateOne {
- ssuo.mutation.Where(ps...)
- return ssuo
- }
- // Select allows selecting one or more fields (columns) of the returned entity.
- // The default is selecting all fields defined in the entity schema.
- func (ssuo *SopStageUpdateOne) Select(field string, fields ...string) *SopStageUpdateOne {
- ssuo.fields = append([]string{field}, fields...)
- return ssuo
- }
- // Save executes the query and returns the updated SopStage entity.
- func (ssuo *SopStageUpdateOne) Save(ctx context.Context) (*SopStage, error) {
- if err := ssuo.defaults(); err != nil {
- return nil, err
- }
- return withHooks(ctx, ssuo.sqlSave, ssuo.mutation, ssuo.hooks)
- }
- // SaveX is like Save, but panics if an error occurs.
- func (ssuo *SopStageUpdateOne) SaveX(ctx context.Context) *SopStage {
- node, err := ssuo.Save(ctx)
- if err != nil {
- panic(err)
- }
- return node
- }
- // Exec executes the query on the entity.
- func (ssuo *SopStageUpdateOne) Exec(ctx context.Context) error {
- _, err := ssuo.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (ssuo *SopStageUpdateOne) ExecX(ctx context.Context) {
- if err := ssuo.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // defaults sets the default values of the builder before save.
- func (ssuo *SopStageUpdateOne) defaults() error {
- if _, ok := ssuo.mutation.UpdatedAt(); !ok {
- if sopstage.UpdateDefaultUpdatedAt == nil {
- return fmt.Errorf("ent: uninitialized sopstage.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
- }
- v := sopstage.UpdateDefaultUpdatedAt()
- ssuo.mutation.SetUpdatedAt(v)
- }
- return nil
- }
- // check runs all checks and user-defined validators on the builder.
- func (ssuo *SopStageUpdateOne) check() error {
- if _, ok := ssuo.mutation.SopTaskID(); ssuo.mutation.SopTaskCleared() && !ok {
- return errors.New(`ent: clearing a required unique edge "SopStage.sop_task"`)
- }
- return nil
- }
- func (ssuo *SopStageUpdateOne) sqlSave(ctx context.Context) (_node *SopStage, err error) {
- if err := ssuo.check(); err != nil {
- return _node, err
- }
- _spec := sqlgraph.NewUpdateSpec(sopstage.Table, sopstage.Columns, sqlgraph.NewFieldSpec(sopstage.FieldID, field.TypeUint64))
- id, ok := ssuo.mutation.ID()
- if !ok {
- return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "SopStage.id" for update`)}
- }
- _spec.Node.ID.Value = id
- if fields := ssuo.fields; len(fields) > 0 {
- _spec.Node.Columns = make([]string, 0, len(fields))
- _spec.Node.Columns = append(_spec.Node.Columns, sopstage.FieldID)
- for _, f := range fields {
- if !sopstage.ValidColumn(f) {
- return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
- }
- if f != sopstage.FieldID {
- _spec.Node.Columns = append(_spec.Node.Columns, f)
- }
- }
- }
- if ps := ssuo.mutation.predicates; len(ps) > 0 {
- _spec.Predicate = func(selector *sql.Selector) {
- for i := range ps {
- ps[i](selector)
- }
- }
- }
- if value, ok := ssuo.mutation.UpdatedAt(); ok {
- _spec.SetField(sopstage.FieldUpdatedAt, field.TypeTime, value)
- }
- if value, ok := ssuo.mutation.Status(); ok {
- _spec.SetField(sopstage.FieldStatus, field.TypeUint8, value)
- }
- if value, ok := ssuo.mutation.AddedStatus(); ok {
- _spec.AddField(sopstage.FieldStatus, field.TypeUint8, value)
- }
- if ssuo.mutation.StatusCleared() {
- _spec.ClearField(sopstage.FieldStatus, field.TypeUint8)
- }
- if value, ok := ssuo.mutation.DeletedAt(); ok {
- _spec.SetField(sopstage.FieldDeletedAt, field.TypeTime, value)
- }
- if ssuo.mutation.DeletedAtCleared() {
- _spec.ClearField(sopstage.FieldDeletedAt, field.TypeTime)
- }
- if value, ok := ssuo.mutation.Name(); ok {
- _spec.SetField(sopstage.FieldName, field.TypeString, value)
- }
- if value, ok := ssuo.mutation.ConditionType(); ok {
- _spec.SetField(sopstage.FieldConditionType, field.TypeInt, value)
- }
- if value, ok := ssuo.mutation.AddedConditionType(); ok {
- _spec.AddField(sopstage.FieldConditionType, field.TypeInt, value)
- }
- if value, ok := ssuo.mutation.ConditionOperator(); ok {
- _spec.SetField(sopstage.FieldConditionOperator, field.TypeInt, value)
- }
- if value, ok := ssuo.mutation.AddedConditionOperator(); ok {
- _spec.AddField(sopstage.FieldConditionOperator, field.TypeInt, value)
- }
- if value, ok := ssuo.mutation.ConditionList(); ok {
- _spec.SetField(sopstage.FieldConditionList, field.TypeJSON, value)
- }
- if value, ok := ssuo.mutation.AppendedConditionList(); ok {
- _spec.AddModifier(func(u *sql.UpdateBuilder) {
- sqljson.Append(u, sopstage.FieldConditionList, value)
- })
- }
- if value, ok := ssuo.mutation.ActionMessage(); ok {
- _spec.SetField(sopstage.FieldActionMessage, field.TypeJSON, value)
- }
- if value, ok := ssuo.mutation.AppendedActionMessage(); ok {
- _spec.AddModifier(func(u *sql.UpdateBuilder) {
- sqljson.Append(u, sopstage.FieldActionMessage, value)
- })
- }
- if ssuo.mutation.ActionMessageCleared() {
- _spec.ClearField(sopstage.FieldActionMessage, field.TypeJSON)
- }
- if value, ok := ssuo.mutation.ActionLabel(); ok {
- _spec.SetField(sopstage.FieldActionLabel, field.TypeJSON, value)
- }
- if value, ok := ssuo.mutation.AppendedActionLabel(); ok {
- _spec.AddModifier(func(u *sql.UpdateBuilder) {
- sqljson.Append(u, sopstage.FieldActionLabel, value)
- })
- }
- if ssuo.mutation.ActionLabelCleared() {
- _spec.ClearField(sopstage.FieldActionLabel, field.TypeJSON)
- }
- if value, ok := ssuo.mutation.IndexSort(); ok {
- _spec.SetField(sopstage.FieldIndexSort, field.TypeInt, value)
- }
- if value, ok := ssuo.mutation.AddedIndexSort(); ok {
- _spec.AddField(sopstage.FieldIndexSort, field.TypeInt, value)
- }
- if ssuo.mutation.IndexSortCleared() {
- _spec.ClearField(sopstage.FieldIndexSort, field.TypeInt)
- }
- if ssuo.mutation.SopTaskCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: sopstage.SopTaskTable,
- Columns: []string{sopstage.SopTaskColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(soptask.FieldID, field.TypeUint64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := ssuo.mutation.SopTaskIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: sopstage.SopTaskTable,
- Columns: []string{sopstage.SopTaskColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(soptask.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- if ssuo.mutation.StageNodesCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: sopstage.StageNodesTable,
- Columns: []string{sopstage.StageNodesColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(sopnode.FieldID, field.TypeUint64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := ssuo.mutation.RemovedStageNodesIDs(); len(nodes) > 0 && !ssuo.mutation.StageNodesCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: sopstage.StageNodesTable,
- Columns: []string{sopstage.StageNodesColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(sopnode.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := ssuo.mutation.StageNodesIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: sopstage.StageNodesTable,
- Columns: []string{sopstage.StageNodesColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(sopnode.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- if ssuo.mutation.StageMessagesCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: sopstage.StageMessagesTable,
- Columns: []string{sopstage.StageMessagesColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(messagerecords.FieldID, field.TypeUint64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := ssuo.mutation.RemovedStageMessagesIDs(); len(nodes) > 0 && !ssuo.mutation.StageMessagesCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: sopstage.StageMessagesTable,
- Columns: []string{sopstage.StageMessagesColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(messagerecords.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := ssuo.mutation.StageMessagesIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: sopstage.StageMessagesTable,
- Columns: []string{sopstage.StageMessagesColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(messagerecords.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- _node = &SopStage{config: ssuo.config}
- _spec.Assign = _node.assignValues
- _spec.ScanValues = _node.scanValues
- if err = sqlgraph.UpdateNode(ctx, ssuo.driver, _spec); err != nil {
- if _, ok := err.(*sqlgraph.NotFoundError); ok {
- err = &NotFoundError{sopstage.Label}
- } else if sqlgraph.IsConstraintError(err) {
- err = &ConstraintError{msg: err.Error(), wrap: err}
- }
- return nil, err
- }
- ssuo.mutation.done = true
- return _node, nil
- }
|