mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-11-29 16:18:40 +08:00
1062 lines
33 KiB
Go
1062 lines
33 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package db
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"time"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
"github.com/chaitin/MonkeyCode/backend/db/mcptool"
|
|
"github.com/chaitin/MonkeyCode/backend/db/mcptoolcall"
|
|
"github.com/chaitin/MonkeyCode/backend/db/mcpupstream"
|
|
"github.com/chaitin/MonkeyCode/backend/db/predicate"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// MCPToolCallUpdate is the builder for updating MCPToolCall entities.
|
|
type MCPToolCallUpdate struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *MCPToolCallMutation
|
|
modifiers []func(*sql.UpdateBuilder)
|
|
}
|
|
|
|
// Where appends a list predicates to the MCPToolCallUpdate builder.
|
|
func (_u *MCPToolCallUpdate) Where(ps ...predicate.MCPToolCall) *MCPToolCallUpdate {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// SetRequestID sets the "request_id" field.
|
|
func (_u *MCPToolCallUpdate) SetRequestID(v string) *MCPToolCallUpdate {
|
|
_u.mutation.SetRequestID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableRequestID sets the "request_id" field if the given value is not nil.
|
|
func (_u *MCPToolCallUpdate) SetNillableRequestID(v *string) *MCPToolCallUpdate {
|
|
if v != nil {
|
|
_u.SetRequestID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetTaskID sets the "task_id" field.
|
|
func (_u *MCPToolCallUpdate) SetTaskID(v uuid.UUID) *MCPToolCallUpdate {
|
|
_u.mutation.SetTaskID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableTaskID sets the "task_id" field if the given value is not nil.
|
|
func (_u *MCPToolCallUpdate) SetNillableTaskID(v *uuid.UUID) *MCPToolCallUpdate {
|
|
if v != nil {
|
|
_u.SetTaskID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetUserID sets the "user_id" field.
|
|
func (_u *MCPToolCallUpdate) SetUserID(v uuid.UUID) *MCPToolCallUpdate {
|
|
_u.mutation.SetUserID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUserID sets the "user_id" field if the given value is not nil.
|
|
func (_u *MCPToolCallUpdate) SetNillableUserID(v *uuid.UUID) *MCPToolCallUpdate {
|
|
if v != nil {
|
|
_u.SetUserID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetUpstreamID sets the "upstream_id" field.
|
|
func (_u *MCPToolCallUpdate) SetUpstreamID(v uuid.UUID) *MCPToolCallUpdate {
|
|
_u.mutation.SetUpstreamID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUpstreamID sets the "upstream_id" field if the given value is not nil.
|
|
func (_u *MCPToolCallUpdate) SetNillableUpstreamID(v *uuid.UUID) *MCPToolCallUpdate {
|
|
if v != nil {
|
|
_u.SetUpstreamID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetToolID sets the "tool_id" field.
|
|
func (_u *MCPToolCallUpdate) SetToolID(v uuid.UUID) *MCPToolCallUpdate {
|
|
_u.mutation.SetToolID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableToolID sets the "tool_id" field if the given value is not nil.
|
|
func (_u *MCPToolCallUpdate) SetNillableToolID(v *uuid.UUID) *MCPToolCallUpdate {
|
|
if v != nil {
|
|
_u.SetToolID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetToolNameSnapshot sets the "tool_name_snapshot" field.
|
|
func (_u *MCPToolCallUpdate) SetToolNameSnapshot(v string) *MCPToolCallUpdate {
|
|
_u.mutation.SetToolNameSnapshot(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableToolNameSnapshot sets the "tool_name_snapshot" field if the given value is not nil.
|
|
func (_u *MCPToolCallUpdate) SetNillableToolNameSnapshot(v *string) *MCPToolCallUpdate {
|
|
if v != nil {
|
|
_u.SetToolNameSnapshot(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetToolScopeSnapshot sets the "tool_scope_snapshot" field.
|
|
func (_u *MCPToolCallUpdate) SetToolScopeSnapshot(v mcptoolcall.ToolScopeSnapshot) *MCPToolCallUpdate {
|
|
_u.mutation.SetToolScopeSnapshot(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableToolScopeSnapshot sets the "tool_scope_snapshot" field if the given value is not nil.
|
|
func (_u *MCPToolCallUpdate) SetNillableToolScopeSnapshot(v *mcptoolcall.ToolScopeSnapshot) *MCPToolCallUpdate {
|
|
if v != nil {
|
|
_u.SetToolScopeSnapshot(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetPriceSnapshot sets the "price_snapshot" field.
|
|
func (_u *MCPToolCallUpdate) SetPriceSnapshot(v int64) *MCPToolCallUpdate {
|
|
_u.mutation.ResetPriceSnapshot()
|
|
_u.mutation.SetPriceSnapshot(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillablePriceSnapshot sets the "price_snapshot" field if the given value is not nil.
|
|
func (_u *MCPToolCallUpdate) SetNillablePriceSnapshot(v *int64) *MCPToolCallUpdate {
|
|
if v != nil {
|
|
_u.SetPriceSnapshot(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddPriceSnapshot adds value to the "price_snapshot" field.
|
|
func (_u *MCPToolCallUpdate) AddPriceSnapshot(v int64) *MCPToolCallUpdate {
|
|
_u.mutation.AddPriceSnapshot(v)
|
|
return _u
|
|
}
|
|
|
|
// SetStatus sets the "status" field.
|
|
func (_u *MCPToolCallUpdate) SetStatus(v mcptoolcall.Status) *MCPToolCallUpdate {
|
|
_u.mutation.SetStatus(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableStatus sets the "status" field if the given value is not nil.
|
|
func (_u *MCPToolCallUpdate) SetNillableStatus(v *mcptoolcall.Status) *MCPToolCallUpdate {
|
|
if v != nil {
|
|
_u.SetStatus(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetArgsJSON sets the "args_json" field.
|
|
func (_u *MCPToolCallUpdate) SetArgsJSON(v map[string]interface{}) *MCPToolCallUpdate {
|
|
_u.mutation.SetArgsJSON(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearArgsJSON clears the value of the "args_json" field.
|
|
func (_u *MCPToolCallUpdate) ClearArgsJSON() *MCPToolCallUpdate {
|
|
_u.mutation.ClearArgsJSON()
|
|
return _u
|
|
}
|
|
|
|
// SetResultJSON sets the "result_json" field.
|
|
func (_u *MCPToolCallUpdate) SetResultJSON(v map[string]interface{}) *MCPToolCallUpdate {
|
|
_u.mutation.SetResultJSON(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearResultJSON clears the value of the "result_json" field.
|
|
func (_u *MCPToolCallUpdate) ClearResultJSON() *MCPToolCallUpdate {
|
|
_u.mutation.ClearResultJSON()
|
|
return _u
|
|
}
|
|
|
|
// SetErrorMessage sets the "error_message" field.
|
|
func (_u *MCPToolCallUpdate) SetErrorMessage(v string) *MCPToolCallUpdate {
|
|
_u.mutation.SetErrorMessage(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableErrorMessage sets the "error_message" field if the given value is not nil.
|
|
func (_u *MCPToolCallUpdate) SetNillableErrorMessage(v *string) *MCPToolCallUpdate {
|
|
if v != nil {
|
|
_u.SetErrorMessage(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetUpstreamRequestID sets the "upstream_request_id" field.
|
|
func (_u *MCPToolCallUpdate) SetUpstreamRequestID(v string) *MCPToolCallUpdate {
|
|
_u.mutation.SetUpstreamRequestID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUpstreamRequestID sets the "upstream_request_id" field if the given value is not nil.
|
|
func (_u *MCPToolCallUpdate) SetNillableUpstreamRequestID(v *string) *MCPToolCallUpdate {
|
|
if v != nil {
|
|
_u.SetUpstreamRequestID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearUpstreamRequestID clears the value of the "upstream_request_id" field.
|
|
func (_u *MCPToolCallUpdate) ClearUpstreamRequestID() *MCPToolCallUpdate {
|
|
_u.mutation.ClearUpstreamRequestID()
|
|
return _u
|
|
}
|
|
|
|
// SetStartedAt sets the "started_at" field.
|
|
func (_u *MCPToolCallUpdate) SetStartedAt(v time.Time) *MCPToolCallUpdate {
|
|
_u.mutation.SetStartedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableStartedAt sets the "started_at" field if the given value is not nil.
|
|
func (_u *MCPToolCallUpdate) SetNillableStartedAt(v *time.Time) *MCPToolCallUpdate {
|
|
if v != nil {
|
|
_u.SetStartedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetFinishedAt sets the "finished_at" field.
|
|
func (_u *MCPToolCallUpdate) SetFinishedAt(v time.Time) *MCPToolCallUpdate {
|
|
_u.mutation.SetFinishedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableFinishedAt sets the "finished_at" field if the given value is not nil.
|
|
func (_u *MCPToolCallUpdate) SetNillableFinishedAt(v *time.Time) *MCPToolCallUpdate {
|
|
if v != nil {
|
|
_u.SetFinishedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearFinishedAt clears the value of the "finished_at" field.
|
|
func (_u *MCPToolCallUpdate) ClearFinishedAt() *MCPToolCallUpdate {
|
|
_u.mutation.ClearFinishedAt()
|
|
return _u
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (_u *MCPToolCallUpdate) SetCreatedAt(v time.Time) *MCPToolCallUpdate {
|
|
_u.mutation.SetCreatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (_u *MCPToolCallUpdate) SetNillableCreatedAt(v *time.Time) *MCPToolCallUpdate {
|
|
if v != nil {
|
|
_u.SetCreatedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (_u *MCPToolCallUpdate) SetUpdatedAt(v time.Time) *MCPToolCallUpdate {
|
|
_u.mutation.SetUpdatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetUpstream sets the "upstream" edge to the MCPUpstream entity.
|
|
func (_u *MCPToolCallUpdate) SetUpstream(v *MCPUpstream) *MCPToolCallUpdate {
|
|
return _u.SetUpstreamID(v.ID)
|
|
}
|
|
|
|
// SetTool sets the "tool" edge to the MCPTool entity.
|
|
func (_u *MCPToolCallUpdate) SetTool(v *MCPTool) *MCPToolCallUpdate {
|
|
return _u.SetToolID(v.ID)
|
|
}
|
|
|
|
// Mutation returns the MCPToolCallMutation object of the builder.
|
|
func (_u *MCPToolCallUpdate) Mutation() *MCPToolCallMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// ClearUpstream clears the "upstream" edge to the MCPUpstream entity.
|
|
func (_u *MCPToolCallUpdate) ClearUpstream() *MCPToolCallUpdate {
|
|
_u.mutation.ClearUpstream()
|
|
return _u
|
|
}
|
|
|
|
// ClearTool clears the "tool" edge to the MCPTool entity.
|
|
func (_u *MCPToolCallUpdate) ClearTool() *MCPToolCallUpdate {
|
|
_u.mutation.ClearTool()
|
|
return _u
|
|
}
|
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
func (_u *MCPToolCallUpdate) Save(ctx context.Context) (int, error) {
|
|
_u.defaults()
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *MCPToolCallUpdate) SaveX(ctx context.Context) int {
|
|
affected, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return affected
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_u *MCPToolCallUpdate) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *MCPToolCallUpdate) ExecX(ctx context.Context) {
|
|
if err := _u.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (_u *MCPToolCallUpdate) defaults() {
|
|
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
|
v := mcptoolcall.UpdateDefaultUpdatedAt()
|
|
_u.mutation.SetUpdatedAt(v)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_u *MCPToolCallUpdate) check() error {
|
|
if v, ok := _u.mutation.RequestID(); ok {
|
|
if err := mcptoolcall.RequestIDValidator(v); err != nil {
|
|
return &ValidationError{Name: "request_id", err: fmt.Errorf(`db: validator failed for field "MCPToolCall.request_id": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.ToolNameSnapshot(); ok {
|
|
if err := mcptoolcall.ToolNameSnapshotValidator(v); err != nil {
|
|
return &ValidationError{Name: "tool_name_snapshot", err: fmt.Errorf(`db: validator failed for field "MCPToolCall.tool_name_snapshot": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.ToolScopeSnapshot(); ok {
|
|
if err := mcptoolcall.ToolScopeSnapshotValidator(v); err != nil {
|
|
return &ValidationError{Name: "tool_scope_snapshot", err: fmt.Errorf(`db: validator failed for field "MCPToolCall.tool_scope_snapshot": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Status(); ok {
|
|
if err := mcptoolcall.StatusValidator(v); err != nil {
|
|
return &ValidationError{Name: "status", err: fmt.Errorf(`db: validator failed for field "MCPToolCall.status": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.UpstreamRequestID(); ok {
|
|
if err := mcptoolcall.UpstreamRequestIDValidator(v); err != nil {
|
|
return &ValidationError{Name: "upstream_request_id", err: fmt.Errorf(`db: validator failed for field "MCPToolCall.upstream_request_id": %w`, err)}
|
|
}
|
|
}
|
|
if _u.mutation.UpstreamCleared() && len(_u.mutation.UpstreamIDs()) > 0 {
|
|
return errors.New(`db: clearing a required unique edge "MCPToolCall.upstream"`)
|
|
}
|
|
if _u.mutation.ToolCleared() && len(_u.mutation.ToolIDs()) > 0 {
|
|
return errors.New(`db: clearing a required unique edge "MCPToolCall.tool"`)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
|
func (_u *MCPToolCallUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *MCPToolCallUpdate {
|
|
_u.modifiers = append(_u.modifiers, modifiers...)
|
|
return _u
|
|
}
|
|
|
|
func (_u *MCPToolCallUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(mcptoolcall.Table, mcptoolcall.Columns, sqlgraph.NewFieldSpec(mcptoolcall.FieldID, field.TypeUUID))
|
|
if ps := _u.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := _u.mutation.RequestID(); ok {
|
|
_spec.SetField(mcptoolcall.FieldRequestID, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.TaskID(); ok {
|
|
_spec.SetField(mcptoolcall.FieldTaskID, field.TypeUUID, value)
|
|
}
|
|
if value, ok := _u.mutation.UserID(); ok {
|
|
_spec.SetField(mcptoolcall.FieldUserID, field.TypeUUID, value)
|
|
}
|
|
if value, ok := _u.mutation.ToolNameSnapshot(); ok {
|
|
_spec.SetField(mcptoolcall.FieldToolNameSnapshot, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.ToolScopeSnapshot(); ok {
|
|
_spec.SetField(mcptoolcall.FieldToolScopeSnapshot, field.TypeEnum, value)
|
|
}
|
|
if value, ok := _u.mutation.PriceSnapshot(); ok {
|
|
_spec.SetField(mcptoolcall.FieldPriceSnapshot, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedPriceSnapshot(); ok {
|
|
_spec.AddField(mcptoolcall.FieldPriceSnapshot, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.Status(); ok {
|
|
_spec.SetField(mcptoolcall.FieldStatus, field.TypeEnum, value)
|
|
}
|
|
if value, ok := _u.mutation.ArgsJSON(); ok {
|
|
_spec.SetField(mcptoolcall.FieldArgsJSON, field.TypeJSON, value)
|
|
}
|
|
if _u.mutation.ArgsJSONCleared() {
|
|
_spec.ClearField(mcptoolcall.FieldArgsJSON, field.TypeJSON)
|
|
}
|
|
if value, ok := _u.mutation.ResultJSON(); ok {
|
|
_spec.SetField(mcptoolcall.FieldResultJSON, field.TypeJSON, value)
|
|
}
|
|
if _u.mutation.ResultJSONCleared() {
|
|
_spec.ClearField(mcptoolcall.FieldResultJSON, field.TypeJSON)
|
|
}
|
|
if value, ok := _u.mutation.ErrorMessage(); ok {
|
|
_spec.SetField(mcptoolcall.FieldErrorMessage, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.UpstreamRequestID(); ok {
|
|
_spec.SetField(mcptoolcall.FieldUpstreamRequestID, field.TypeString, value)
|
|
}
|
|
if _u.mutation.UpstreamRequestIDCleared() {
|
|
_spec.ClearField(mcptoolcall.FieldUpstreamRequestID, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.StartedAt(); ok {
|
|
_spec.SetField(mcptoolcall.FieldStartedAt, field.TypeTime, value)
|
|
}
|
|
if value, ok := _u.mutation.FinishedAt(); ok {
|
|
_spec.SetField(mcptoolcall.FieldFinishedAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.FinishedAtCleared() {
|
|
_spec.ClearField(mcptoolcall.FieldFinishedAt, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.CreatedAt(); ok {
|
|
_spec.SetField(mcptoolcall.FieldCreatedAt, field.TypeTime, value)
|
|
}
|
|
if value, ok := _u.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(mcptoolcall.FieldUpdatedAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.UpstreamCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: false,
|
|
Table: mcptoolcall.UpstreamTable,
|
|
Columns: []string{mcptoolcall.UpstreamColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(mcpupstream.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.UpstreamIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: false,
|
|
Table: mcptoolcall.UpstreamTable,
|
|
Columns: []string{mcptoolcall.UpstreamColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(mcpupstream.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.ToolCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: false,
|
|
Table: mcptoolcall.ToolTable,
|
|
Columns: []string{mcptoolcall.ToolColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(mcptool.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.ToolIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: false,
|
|
Table: mcptoolcall.ToolTable,
|
|
Columns: []string{mcptoolcall.ToolColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(mcptool.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
_spec.AddModifiers(_u.modifiers...)
|
|
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{mcptoolcall.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return 0, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
// MCPToolCallUpdateOne is the builder for updating a single MCPToolCall entity.
|
|
type MCPToolCallUpdateOne struct {
|
|
config
|
|
fields []string
|
|
hooks []Hook
|
|
mutation *MCPToolCallMutation
|
|
modifiers []func(*sql.UpdateBuilder)
|
|
}
|
|
|
|
// SetRequestID sets the "request_id" field.
|
|
func (_u *MCPToolCallUpdateOne) SetRequestID(v string) *MCPToolCallUpdateOne {
|
|
_u.mutation.SetRequestID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableRequestID sets the "request_id" field if the given value is not nil.
|
|
func (_u *MCPToolCallUpdateOne) SetNillableRequestID(v *string) *MCPToolCallUpdateOne {
|
|
if v != nil {
|
|
_u.SetRequestID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetTaskID sets the "task_id" field.
|
|
func (_u *MCPToolCallUpdateOne) SetTaskID(v uuid.UUID) *MCPToolCallUpdateOne {
|
|
_u.mutation.SetTaskID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableTaskID sets the "task_id" field if the given value is not nil.
|
|
func (_u *MCPToolCallUpdateOne) SetNillableTaskID(v *uuid.UUID) *MCPToolCallUpdateOne {
|
|
if v != nil {
|
|
_u.SetTaskID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetUserID sets the "user_id" field.
|
|
func (_u *MCPToolCallUpdateOne) SetUserID(v uuid.UUID) *MCPToolCallUpdateOne {
|
|
_u.mutation.SetUserID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUserID sets the "user_id" field if the given value is not nil.
|
|
func (_u *MCPToolCallUpdateOne) SetNillableUserID(v *uuid.UUID) *MCPToolCallUpdateOne {
|
|
if v != nil {
|
|
_u.SetUserID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetUpstreamID sets the "upstream_id" field.
|
|
func (_u *MCPToolCallUpdateOne) SetUpstreamID(v uuid.UUID) *MCPToolCallUpdateOne {
|
|
_u.mutation.SetUpstreamID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUpstreamID sets the "upstream_id" field if the given value is not nil.
|
|
func (_u *MCPToolCallUpdateOne) SetNillableUpstreamID(v *uuid.UUID) *MCPToolCallUpdateOne {
|
|
if v != nil {
|
|
_u.SetUpstreamID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetToolID sets the "tool_id" field.
|
|
func (_u *MCPToolCallUpdateOne) SetToolID(v uuid.UUID) *MCPToolCallUpdateOne {
|
|
_u.mutation.SetToolID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableToolID sets the "tool_id" field if the given value is not nil.
|
|
func (_u *MCPToolCallUpdateOne) SetNillableToolID(v *uuid.UUID) *MCPToolCallUpdateOne {
|
|
if v != nil {
|
|
_u.SetToolID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetToolNameSnapshot sets the "tool_name_snapshot" field.
|
|
func (_u *MCPToolCallUpdateOne) SetToolNameSnapshot(v string) *MCPToolCallUpdateOne {
|
|
_u.mutation.SetToolNameSnapshot(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableToolNameSnapshot sets the "tool_name_snapshot" field if the given value is not nil.
|
|
func (_u *MCPToolCallUpdateOne) SetNillableToolNameSnapshot(v *string) *MCPToolCallUpdateOne {
|
|
if v != nil {
|
|
_u.SetToolNameSnapshot(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetToolScopeSnapshot sets the "tool_scope_snapshot" field.
|
|
func (_u *MCPToolCallUpdateOne) SetToolScopeSnapshot(v mcptoolcall.ToolScopeSnapshot) *MCPToolCallUpdateOne {
|
|
_u.mutation.SetToolScopeSnapshot(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableToolScopeSnapshot sets the "tool_scope_snapshot" field if the given value is not nil.
|
|
func (_u *MCPToolCallUpdateOne) SetNillableToolScopeSnapshot(v *mcptoolcall.ToolScopeSnapshot) *MCPToolCallUpdateOne {
|
|
if v != nil {
|
|
_u.SetToolScopeSnapshot(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetPriceSnapshot sets the "price_snapshot" field.
|
|
func (_u *MCPToolCallUpdateOne) SetPriceSnapshot(v int64) *MCPToolCallUpdateOne {
|
|
_u.mutation.ResetPriceSnapshot()
|
|
_u.mutation.SetPriceSnapshot(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillablePriceSnapshot sets the "price_snapshot" field if the given value is not nil.
|
|
func (_u *MCPToolCallUpdateOne) SetNillablePriceSnapshot(v *int64) *MCPToolCallUpdateOne {
|
|
if v != nil {
|
|
_u.SetPriceSnapshot(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddPriceSnapshot adds value to the "price_snapshot" field.
|
|
func (_u *MCPToolCallUpdateOne) AddPriceSnapshot(v int64) *MCPToolCallUpdateOne {
|
|
_u.mutation.AddPriceSnapshot(v)
|
|
return _u
|
|
}
|
|
|
|
// SetStatus sets the "status" field.
|
|
func (_u *MCPToolCallUpdateOne) SetStatus(v mcptoolcall.Status) *MCPToolCallUpdateOne {
|
|
_u.mutation.SetStatus(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableStatus sets the "status" field if the given value is not nil.
|
|
func (_u *MCPToolCallUpdateOne) SetNillableStatus(v *mcptoolcall.Status) *MCPToolCallUpdateOne {
|
|
if v != nil {
|
|
_u.SetStatus(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetArgsJSON sets the "args_json" field.
|
|
func (_u *MCPToolCallUpdateOne) SetArgsJSON(v map[string]interface{}) *MCPToolCallUpdateOne {
|
|
_u.mutation.SetArgsJSON(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearArgsJSON clears the value of the "args_json" field.
|
|
func (_u *MCPToolCallUpdateOne) ClearArgsJSON() *MCPToolCallUpdateOne {
|
|
_u.mutation.ClearArgsJSON()
|
|
return _u
|
|
}
|
|
|
|
// SetResultJSON sets the "result_json" field.
|
|
func (_u *MCPToolCallUpdateOne) SetResultJSON(v map[string]interface{}) *MCPToolCallUpdateOne {
|
|
_u.mutation.SetResultJSON(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearResultJSON clears the value of the "result_json" field.
|
|
func (_u *MCPToolCallUpdateOne) ClearResultJSON() *MCPToolCallUpdateOne {
|
|
_u.mutation.ClearResultJSON()
|
|
return _u
|
|
}
|
|
|
|
// SetErrorMessage sets the "error_message" field.
|
|
func (_u *MCPToolCallUpdateOne) SetErrorMessage(v string) *MCPToolCallUpdateOne {
|
|
_u.mutation.SetErrorMessage(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableErrorMessage sets the "error_message" field if the given value is not nil.
|
|
func (_u *MCPToolCallUpdateOne) SetNillableErrorMessage(v *string) *MCPToolCallUpdateOne {
|
|
if v != nil {
|
|
_u.SetErrorMessage(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetUpstreamRequestID sets the "upstream_request_id" field.
|
|
func (_u *MCPToolCallUpdateOne) SetUpstreamRequestID(v string) *MCPToolCallUpdateOne {
|
|
_u.mutation.SetUpstreamRequestID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUpstreamRequestID sets the "upstream_request_id" field if the given value is not nil.
|
|
func (_u *MCPToolCallUpdateOne) SetNillableUpstreamRequestID(v *string) *MCPToolCallUpdateOne {
|
|
if v != nil {
|
|
_u.SetUpstreamRequestID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearUpstreamRequestID clears the value of the "upstream_request_id" field.
|
|
func (_u *MCPToolCallUpdateOne) ClearUpstreamRequestID() *MCPToolCallUpdateOne {
|
|
_u.mutation.ClearUpstreamRequestID()
|
|
return _u
|
|
}
|
|
|
|
// SetStartedAt sets the "started_at" field.
|
|
func (_u *MCPToolCallUpdateOne) SetStartedAt(v time.Time) *MCPToolCallUpdateOne {
|
|
_u.mutation.SetStartedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableStartedAt sets the "started_at" field if the given value is not nil.
|
|
func (_u *MCPToolCallUpdateOne) SetNillableStartedAt(v *time.Time) *MCPToolCallUpdateOne {
|
|
if v != nil {
|
|
_u.SetStartedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetFinishedAt sets the "finished_at" field.
|
|
func (_u *MCPToolCallUpdateOne) SetFinishedAt(v time.Time) *MCPToolCallUpdateOne {
|
|
_u.mutation.SetFinishedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableFinishedAt sets the "finished_at" field if the given value is not nil.
|
|
func (_u *MCPToolCallUpdateOne) SetNillableFinishedAt(v *time.Time) *MCPToolCallUpdateOne {
|
|
if v != nil {
|
|
_u.SetFinishedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearFinishedAt clears the value of the "finished_at" field.
|
|
func (_u *MCPToolCallUpdateOne) ClearFinishedAt() *MCPToolCallUpdateOne {
|
|
_u.mutation.ClearFinishedAt()
|
|
return _u
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (_u *MCPToolCallUpdateOne) SetCreatedAt(v time.Time) *MCPToolCallUpdateOne {
|
|
_u.mutation.SetCreatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (_u *MCPToolCallUpdateOne) SetNillableCreatedAt(v *time.Time) *MCPToolCallUpdateOne {
|
|
if v != nil {
|
|
_u.SetCreatedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (_u *MCPToolCallUpdateOne) SetUpdatedAt(v time.Time) *MCPToolCallUpdateOne {
|
|
_u.mutation.SetUpdatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetUpstream sets the "upstream" edge to the MCPUpstream entity.
|
|
func (_u *MCPToolCallUpdateOne) SetUpstream(v *MCPUpstream) *MCPToolCallUpdateOne {
|
|
return _u.SetUpstreamID(v.ID)
|
|
}
|
|
|
|
// SetTool sets the "tool" edge to the MCPTool entity.
|
|
func (_u *MCPToolCallUpdateOne) SetTool(v *MCPTool) *MCPToolCallUpdateOne {
|
|
return _u.SetToolID(v.ID)
|
|
}
|
|
|
|
// Mutation returns the MCPToolCallMutation object of the builder.
|
|
func (_u *MCPToolCallUpdateOne) Mutation() *MCPToolCallMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// ClearUpstream clears the "upstream" edge to the MCPUpstream entity.
|
|
func (_u *MCPToolCallUpdateOne) ClearUpstream() *MCPToolCallUpdateOne {
|
|
_u.mutation.ClearUpstream()
|
|
return _u
|
|
}
|
|
|
|
// ClearTool clears the "tool" edge to the MCPTool entity.
|
|
func (_u *MCPToolCallUpdateOne) ClearTool() *MCPToolCallUpdateOne {
|
|
_u.mutation.ClearTool()
|
|
return _u
|
|
}
|
|
|
|
// Where appends a list predicates to the MCPToolCallUpdate builder.
|
|
func (_u *MCPToolCallUpdateOne) Where(ps ...predicate.MCPToolCall) *MCPToolCallUpdateOne {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// Select allows selecting one or more fields (columns) of the returned entity.
|
|
// The default is selecting all fields defined in the entity schema.
|
|
func (_u *MCPToolCallUpdateOne) Select(field string, fields ...string) *MCPToolCallUpdateOne {
|
|
_u.fields = append([]string{field}, fields...)
|
|
return _u
|
|
}
|
|
|
|
// Save executes the query and returns the updated MCPToolCall entity.
|
|
func (_u *MCPToolCallUpdateOne) Save(ctx context.Context) (*MCPToolCall, error) {
|
|
_u.defaults()
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *MCPToolCallUpdateOne) SaveX(ctx context.Context) *MCPToolCall {
|
|
node, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// Exec executes the query on the entity.
|
|
func (_u *MCPToolCallUpdateOne) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *MCPToolCallUpdateOne) ExecX(ctx context.Context) {
|
|
if err := _u.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (_u *MCPToolCallUpdateOne) defaults() {
|
|
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
|
v := mcptoolcall.UpdateDefaultUpdatedAt()
|
|
_u.mutation.SetUpdatedAt(v)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_u *MCPToolCallUpdateOne) check() error {
|
|
if v, ok := _u.mutation.RequestID(); ok {
|
|
if err := mcptoolcall.RequestIDValidator(v); err != nil {
|
|
return &ValidationError{Name: "request_id", err: fmt.Errorf(`db: validator failed for field "MCPToolCall.request_id": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.ToolNameSnapshot(); ok {
|
|
if err := mcptoolcall.ToolNameSnapshotValidator(v); err != nil {
|
|
return &ValidationError{Name: "tool_name_snapshot", err: fmt.Errorf(`db: validator failed for field "MCPToolCall.tool_name_snapshot": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.ToolScopeSnapshot(); ok {
|
|
if err := mcptoolcall.ToolScopeSnapshotValidator(v); err != nil {
|
|
return &ValidationError{Name: "tool_scope_snapshot", err: fmt.Errorf(`db: validator failed for field "MCPToolCall.tool_scope_snapshot": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Status(); ok {
|
|
if err := mcptoolcall.StatusValidator(v); err != nil {
|
|
return &ValidationError{Name: "status", err: fmt.Errorf(`db: validator failed for field "MCPToolCall.status": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.UpstreamRequestID(); ok {
|
|
if err := mcptoolcall.UpstreamRequestIDValidator(v); err != nil {
|
|
return &ValidationError{Name: "upstream_request_id", err: fmt.Errorf(`db: validator failed for field "MCPToolCall.upstream_request_id": %w`, err)}
|
|
}
|
|
}
|
|
if _u.mutation.UpstreamCleared() && len(_u.mutation.UpstreamIDs()) > 0 {
|
|
return errors.New(`db: clearing a required unique edge "MCPToolCall.upstream"`)
|
|
}
|
|
if _u.mutation.ToolCleared() && len(_u.mutation.ToolIDs()) > 0 {
|
|
return errors.New(`db: clearing a required unique edge "MCPToolCall.tool"`)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
|
func (_u *MCPToolCallUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *MCPToolCallUpdateOne {
|
|
_u.modifiers = append(_u.modifiers, modifiers...)
|
|
return _u
|
|
}
|
|
|
|
func (_u *MCPToolCallUpdateOne) sqlSave(ctx context.Context) (_node *MCPToolCall, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(mcptoolcall.Table, mcptoolcall.Columns, sqlgraph.NewFieldSpec(mcptoolcall.FieldID, field.TypeUUID))
|
|
id, ok := _u.mutation.ID()
|
|
if !ok {
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`db: missing "MCPToolCall.id" for update`)}
|
|
}
|
|
_spec.Node.ID.Value = id
|
|
if fields := _u.fields; len(fields) > 0 {
|
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
|
_spec.Node.Columns = append(_spec.Node.Columns, mcptoolcall.FieldID)
|
|
for _, f := range fields {
|
|
if !mcptoolcall.ValidColumn(f) {
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)}
|
|
}
|
|
if f != mcptoolcall.FieldID {
|
|
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
|
}
|
|
}
|
|
}
|
|
if ps := _u.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := _u.mutation.RequestID(); ok {
|
|
_spec.SetField(mcptoolcall.FieldRequestID, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.TaskID(); ok {
|
|
_spec.SetField(mcptoolcall.FieldTaskID, field.TypeUUID, value)
|
|
}
|
|
if value, ok := _u.mutation.UserID(); ok {
|
|
_spec.SetField(mcptoolcall.FieldUserID, field.TypeUUID, value)
|
|
}
|
|
if value, ok := _u.mutation.ToolNameSnapshot(); ok {
|
|
_spec.SetField(mcptoolcall.FieldToolNameSnapshot, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.ToolScopeSnapshot(); ok {
|
|
_spec.SetField(mcptoolcall.FieldToolScopeSnapshot, field.TypeEnum, value)
|
|
}
|
|
if value, ok := _u.mutation.PriceSnapshot(); ok {
|
|
_spec.SetField(mcptoolcall.FieldPriceSnapshot, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedPriceSnapshot(); ok {
|
|
_spec.AddField(mcptoolcall.FieldPriceSnapshot, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.Status(); ok {
|
|
_spec.SetField(mcptoolcall.FieldStatus, field.TypeEnum, value)
|
|
}
|
|
if value, ok := _u.mutation.ArgsJSON(); ok {
|
|
_spec.SetField(mcptoolcall.FieldArgsJSON, field.TypeJSON, value)
|
|
}
|
|
if _u.mutation.ArgsJSONCleared() {
|
|
_spec.ClearField(mcptoolcall.FieldArgsJSON, field.TypeJSON)
|
|
}
|
|
if value, ok := _u.mutation.ResultJSON(); ok {
|
|
_spec.SetField(mcptoolcall.FieldResultJSON, field.TypeJSON, value)
|
|
}
|
|
if _u.mutation.ResultJSONCleared() {
|
|
_spec.ClearField(mcptoolcall.FieldResultJSON, field.TypeJSON)
|
|
}
|
|
if value, ok := _u.mutation.ErrorMessage(); ok {
|
|
_spec.SetField(mcptoolcall.FieldErrorMessage, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.UpstreamRequestID(); ok {
|
|
_spec.SetField(mcptoolcall.FieldUpstreamRequestID, field.TypeString, value)
|
|
}
|
|
if _u.mutation.UpstreamRequestIDCleared() {
|
|
_spec.ClearField(mcptoolcall.FieldUpstreamRequestID, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.StartedAt(); ok {
|
|
_spec.SetField(mcptoolcall.FieldStartedAt, field.TypeTime, value)
|
|
}
|
|
if value, ok := _u.mutation.FinishedAt(); ok {
|
|
_spec.SetField(mcptoolcall.FieldFinishedAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.FinishedAtCleared() {
|
|
_spec.ClearField(mcptoolcall.FieldFinishedAt, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.CreatedAt(); ok {
|
|
_spec.SetField(mcptoolcall.FieldCreatedAt, field.TypeTime, value)
|
|
}
|
|
if value, ok := _u.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(mcptoolcall.FieldUpdatedAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.UpstreamCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: false,
|
|
Table: mcptoolcall.UpstreamTable,
|
|
Columns: []string{mcptoolcall.UpstreamColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(mcpupstream.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.UpstreamIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: false,
|
|
Table: mcptoolcall.UpstreamTable,
|
|
Columns: []string{mcptoolcall.UpstreamColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(mcpupstream.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.ToolCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: false,
|
|
Table: mcptoolcall.ToolTable,
|
|
Columns: []string{mcptoolcall.ToolColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(mcptool.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.ToolIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: false,
|
|
Table: mcptoolcall.ToolTable,
|
|
Columns: []string{mcptoolcall.ToolColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(mcptool.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
_spec.AddModifiers(_u.modifiers...)
|
|
_node = &MCPToolCall{config: _u.config}
|
|
_spec.Assign = _node.assignValues
|
|
_spec.ScanValues = _node.scanValues
|
|
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{mcptoolcall.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|