mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-11-25 13:48:18 +08:00
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1117 lines
34 KiB
Go
1117 lines
34 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/dialect/sql/sqljson"
|
|
"entgo.io/ent/schema/field"
|
|
"github.com/chaitin/MonkeyCode/backend/db/agentskill"
|
|
"github.com/chaitin/MonkeyCode/backend/db/agentskillrepo"
|
|
"github.com/chaitin/MonkeyCode/backend/db/agentskillversion"
|
|
"github.com/chaitin/MonkeyCode/backend/db/predicate"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// AgentSkillUpdate is the builder for updating AgentSkill entities.
|
|
type AgentSkillUpdate struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *AgentSkillMutation
|
|
modifiers []func(*sql.UpdateBuilder)
|
|
}
|
|
|
|
// Where appends a list predicates to the AgentSkillUpdate builder.
|
|
func (_u *AgentSkillUpdate) Where(ps ...predicate.AgentSkill) *AgentSkillUpdate {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// SetRepoID sets the "repo_id" field.
|
|
func (_u *AgentSkillUpdate) SetRepoID(v uuid.UUID) *AgentSkillUpdate {
|
|
_u.mutation.SetRepoID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableRepoID sets the "repo_id" field if the given value is not nil.
|
|
func (_u *AgentSkillUpdate) SetNillableRepoID(v *uuid.UUID) *AgentSkillUpdate {
|
|
if v != nil {
|
|
_u.SetRepoID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (_u *AgentSkillUpdate) SetName(v string) *AgentSkillUpdate {
|
|
_u.mutation.SetName(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableName sets the "name" field if the given value is not nil.
|
|
func (_u *AgentSkillUpdate) SetNillableName(v *string) *AgentSkillUpdate {
|
|
if v != nil {
|
|
_u.SetName(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetDescription sets the "description" field.
|
|
func (_u *AgentSkillUpdate) SetDescription(v string) *AgentSkillUpdate {
|
|
_u.mutation.SetDescription(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableDescription sets the "description" field if the given value is not nil.
|
|
func (_u *AgentSkillUpdate) SetNillableDescription(v *string) *AgentSkillUpdate {
|
|
if v != nil {
|
|
_u.SetDescription(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearDescription clears the value of the "description" field.
|
|
func (_u *AgentSkillUpdate) ClearDescription() *AgentSkillUpdate {
|
|
_u.mutation.ClearDescription()
|
|
return _u
|
|
}
|
|
|
|
// SetScopeType sets the "scope_type" field.
|
|
func (_u *AgentSkillUpdate) SetScopeType(v agentskill.ScopeType) *AgentSkillUpdate {
|
|
_u.mutation.SetScopeType(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableScopeType sets the "scope_type" field if the given value is not nil.
|
|
func (_u *AgentSkillUpdate) SetNillableScopeType(v *agentskill.ScopeType) *AgentSkillUpdate {
|
|
if v != nil {
|
|
_u.SetScopeType(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetScopeID sets the "scope_id" field.
|
|
func (_u *AgentSkillUpdate) SetScopeID(v string) *AgentSkillUpdate {
|
|
_u.mutation.SetScopeID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableScopeID sets the "scope_id" field if the given value is not nil.
|
|
func (_u *AgentSkillUpdate) SetNillableScopeID(v *string) *AgentSkillUpdate {
|
|
if v != nil {
|
|
_u.SetScopeID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetCreatedBy sets the "created_by" field.
|
|
func (_u *AgentSkillUpdate) SetCreatedBy(v uuid.UUID) *AgentSkillUpdate {
|
|
_u.mutation.SetCreatedBy(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCreatedBy sets the "created_by" field if the given value is not nil.
|
|
func (_u *AgentSkillUpdate) SetNillableCreatedBy(v *uuid.UUID) *AgentSkillUpdate {
|
|
if v != nil {
|
|
_u.SetCreatedBy(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetActiveVersionID sets the "active_version_id" field.
|
|
func (_u *AgentSkillUpdate) SetActiveVersionID(v uuid.UUID) *AgentSkillUpdate {
|
|
_u.mutation.SetActiveVersionID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableActiveVersionID sets the "active_version_id" field if the given value is not nil.
|
|
func (_u *AgentSkillUpdate) SetNillableActiveVersionID(v *uuid.UUID) *AgentSkillUpdate {
|
|
if v != nil {
|
|
_u.SetActiveVersionID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearActiveVersionID clears the value of the "active_version_id" field.
|
|
func (_u *AgentSkillUpdate) ClearActiveVersionID() *AgentSkillUpdate {
|
|
_u.mutation.ClearActiveVersionID()
|
|
return _u
|
|
}
|
|
|
|
// SetIsForceDelivery sets the "is_force_delivery" field.
|
|
func (_u *AgentSkillUpdate) SetIsForceDelivery(v bool) *AgentSkillUpdate {
|
|
_u.mutation.SetIsForceDelivery(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableIsForceDelivery sets the "is_force_delivery" field if the given value is not nil.
|
|
func (_u *AgentSkillUpdate) SetNillableIsForceDelivery(v *bool) *AgentSkillUpdate {
|
|
if v != nil {
|
|
_u.SetIsForceDelivery(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetIsOrphan sets the "is_orphan" field.
|
|
func (_u *AgentSkillUpdate) SetIsOrphan(v bool) *AgentSkillUpdate {
|
|
_u.mutation.SetIsOrphan(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableIsOrphan sets the "is_orphan" field if the given value is not nil.
|
|
func (_u *AgentSkillUpdate) SetNillableIsOrphan(v *bool) *AgentSkillUpdate {
|
|
if v != nil {
|
|
_u.SetIsOrphan(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetIsDeleted sets the "is_deleted" field.
|
|
func (_u *AgentSkillUpdate) SetIsDeleted(v bool) *AgentSkillUpdate {
|
|
_u.mutation.SetIsDeleted(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableIsDeleted sets the "is_deleted" field if the given value is not nil.
|
|
func (_u *AgentSkillUpdate) SetNillableIsDeleted(v *bool) *AgentSkillUpdate {
|
|
if v != nil {
|
|
_u.SetIsDeleted(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetEnabled sets the "enabled" field.
|
|
func (_u *AgentSkillUpdate) SetEnabled(v bool) *AgentSkillUpdate {
|
|
_u.mutation.SetEnabled(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableEnabled sets the "enabled" field if the given value is not nil.
|
|
func (_u *AgentSkillUpdate) SetNillableEnabled(v *bool) *AgentSkillUpdate {
|
|
if v != nil {
|
|
_u.SetEnabled(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetExtensionPackageID sets the "extension_package_id" field.
|
|
func (_u *AgentSkillUpdate) SetExtensionPackageID(v string) *AgentSkillUpdate {
|
|
_u.mutation.SetExtensionPackageID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableExtensionPackageID sets the "extension_package_id" field if the given value is not nil.
|
|
func (_u *AgentSkillUpdate) SetNillableExtensionPackageID(v *string) *AgentSkillUpdate {
|
|
if v != nil {
|
|
_u.SetExtensionPackageID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearExtensionPackageID clears the value of the "extension_package_id" field.
|
|
func (_u *AgentSkillUpdate) ClearExtensionPackageID() *AgentSkillUpdate {
|
|
_u.mutation.ClearExtensionPackageID()
|
|
return _u
|
|
}
|
|
|
|
// SetAdminDescription sets the "admin_description" field.
|
|
func (_u *AgentSkillUpdate) SetAdminDescription(v string) *AgentSkillUpdate {
|
|
_u.mutation.SetAdminDescription(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableAdminDescription sets the "admin_description" field if the given value is not nil.
|
|
func (_u *AgentSkillUpdate) SetNillableAdminDescription(v *string) *AgentSkillUpdate {
|
|
if v != nil {
|
|
_u.SetAdminDescription(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearAdminDescription clears the value of the "admin_description" field.
|
|
func (_u *AgentSkillUpdate) ClearAdminDescription() *AgentSkillUpdate {
|
|
_u.mutation.ClearAdminDescription()
|
|
return _u
|
|
}
|
|
|
|
// SetAdminTags sets the "admin_tags" field.
|
|
func (_u *AgentSkillUpdate) SetAdminTags(v []string) *AgentSkillUpdate {
|
|
_u.mutation.SetAdminTags(v)
|
|
return _u
|
|
}
|
|
|
|
// AppendAdminTags appends value to the "admin_tags" field.
|
|
func (_u *AgentSkillUpdate) AppendAdminTags(v []string) *AgentSkillUpdate {
|
|
_u.mutation.AppendAdminTags(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearAdminTags clears the value of the "admin_tags" field.
|
|
func (_u *AgentSkillUpdate) ClearAdminTags() *AgentSkillUpdate {
|
|
_u.mutation.ClearAdminTags()
|
|
return _u
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (_u *AgentSkillUpdate) SetCreatedAt(v time.Time) *AgentSkillUpdate {
|
|
_u.mutation.SetCreatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (_u *AgentSkillUpdate) SetNillableCreatedAt(v *time.Time) *AgentSkillUpdate {
|
|
if v != nil {
|
|
_u.SetCreatedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (_u *AgentSkillUpdate) SetUpdatedAt(v time.Time) *AgentSkillUpdate {
|
|
_u.mutation.SetUpdatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetRepo sets the "repo" edge to the AgentSkillRepo entity.
|
|
func (_u *AgentSkillUpdate) SetRepo(v *AgentSkillRepo) *AgentSkillUpdate {
|
|
return _u.SetRepoID(v.ID)
|
|
}
|
|
|
|
// AddVersionIDs adds the "versions" edge to the AgentSkillVersion entity by IDs.
|
|
func (_u *AgentSkillUpdate) AddVersionIDs(ids ...uuid.UUID) *AgentSkillUpdate {
|
|
_u.mutation.AddVersionIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddVersions adds the "versions" edges to the AgentSkillVersion entity.
|
|
func (_u *AgentSkillUpdate) AddVersions(v ...*AgentSkillVersion) *AgentSkillUpdate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddVersionIDs(ids...)
|
|
}
|
|
|
|
// Mutation returns the AgentSkillMutation object of the builder.
|
|
func (_u *AgentSkillUpdate) Mutation() *AgentSkillMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// ClearRepo clears the "repo" edge to the AgentSkillRepo entity.
|
|
func (_u *AgentSkillUpdate) ClearRepo() *AgentSkillUpdate {
|
|
_u.mutation.ClearRepo()
|
|
return _u
|
|
}
|
|
|
|
// ClearVersions clears all "versions" edges to the AgentSkillVersion entity.
|
|
func (_u *AgentSkillUpdate) ClearVersions() *AgentSkillUpdate {
|
|
_u.mutation.ClearVersions()
|
|
return _u
|
|
}
|
|
|
|
// RemoveVersionIDs removes the "versions" edge to AgentSkillVersion entities by IDs.
|
|
func (_u *AgentSkillUpdate) RemoveVersionIDs(ids ...uuid.UUID) *AgentSkillUpdate {
|
|
_u.mutation.RemoveVersionIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveVersions removes "versions" edges to AgentSkillVersion entities.
|
|
func (_u *AgentSkillUpdate) RemoveVersions(v ...*AgentSkillVersion) *AgentSkillUpdate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveVersionIDs(ids...)
|
|
}
|
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
func (_u *AgentSkillUpdate) 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 *AgentSkillUpdate) SaveX(ctx context.Context) int {
|
|
affected, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return affected
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_u *AgentSkillUpdate) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *AgentSkillUpdate) 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 *AgentSkillUpdate) defaults() {
|
|
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
|
v := agentskill.UpdateDefaultUpdatedAt()
|
|
_u.mutation.SetUpdatedAt(v)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_u *AgentSkillUpdate) check() error {
|
|
if v, ok := _u.mutation.Name(); ok {
|
|
if err := agentskill.NameValidator(v); err != nil {
|
|
return &ValidationError{Name: "name", err: fmt.Errorf(`db: validator failed for field "AgentSkill.name": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.ScopeType(); ok {
|
|
if err := agentskill.ScopeTypeValidator(v); err != nil {
|
|
return &ValidationError{Name: "scope_type", err: fmt.Errorf(`db: validator failed for field "AgentSkill.scope_type": %w`, err)}
|
|
}
|
|
}
|
|
if _u.mutation.RepoCleared() && len(_u.mutation.RepoIDs()) > 0 {
|
|
return errors.New(`db: clearing a required unique edge "AgentSkill.repo"`)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
|
func (_u *AgentSkillUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *AgentSkillUpdate {
|
|
_u.modifiers = append(_u.modifiers, modifiers...)
|
|
return _u
|
|
}
|
|
|
|
func (_u *AgentSkillUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(agentskill.Table, agentskill.Columns, sqlgraph.NewFieldSpec(agentskill.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.Name(); ok {
|
|
_spec.SetField(agentskill.FieldName, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Description(); ok {
|
|
_spec.SetField(agentskill.FieldDescription, field.TypeString, value)
|
|
}
|
|
if _u.mutation.DescriptionCleared() {
|
|
_spec.ClearField(agentskill.FieldDescription, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.ScopeType(); ok {
|
|
_spec.SetField(agentskill.FieldScopeType, field.TypeEnum, value)
|
|
}
|
|
if value, ok := _u.mutation.ScopeID(); ok {
|
|
_spec.SetField(agentskill.FieldScopeID, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.CreatedBy(); ok {
|
|
_spec.SetField(agentskill.FieldCreatedBy, field.TypeUUID, value)
|
|
}
|
|
if value, ok := _u.mutation.ActiveVersionID(); ok {
|
|
_spec.SetField(agentskill.FieldActiveVersionID, field.TypeUUID, value)
|
|
}
|
|
if _u.mutation.ActiveVersionIDCleared() {
|
|
_spec.ClearField(agentskill.FieldActiveVersionID, field.TypeUUID)
|
|
}
|
|
if value, ok := _u.mutation.IsForceDelivery(); ok {
|
|
_spec.SetField(agentskill.FieldIsForceDelivery, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.IsOrphan(); ok {
|
|
_spec.SetField(agentskill.FieldIsOrphan, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.IsDeleted(); ok {
|
|
_spec.SetField(agentskill.FieldIsDeleted, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.Enabled(); ok {
|
|
_spec.SetField(agentskill.FieldEnabled, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.ExtensionPackageID(); ok {
|
|
_spec.SetField(agentskill.FieldExtensionPackageID, field.TypeString, value)
|
|
}
|
|
if _u.mutation.ExtensionPackageIDCleared() {
|
|
_spec.ClearField(agentskill.FieldExtensionPackageID, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.AdminDescription(); ok {
|
|
_spec.SetField(agentskill.FieldAdminDescription, field.TypeString, value)
|
|
}
|
|
if _u.mutation.AdminDescriptionCleared() {
|
|
_spec.ClearField(agentskill.FieldAdminDescription, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.AdminTags(); ok {
|
|
_spec.SetField(agentskill.FieldAdminTags, field.TypeJSON, value)
|
|
}
|
|
if value, ok := _u.mutation.AppendedAdminTags(); ok {
|
|
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
|
sqljson.Append(u, agentskill.FieldAdminTags, value)
|
|
})
|
|
}
|
|
if _u.mutation.AdminTagsCleared() {
|
|
_spec.ClearField(agentskill.FieldAdminTags, field.TypeJSON)
|
|
}
|
|
if value, ok := _u.mutation.CreatedAt(); ok {
|
|
_spec.SetField(agentskill.FieldCreatedAt, field.TypeTime, value)
|
|
}
|
|
if value, ok := _u.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(agentskill.FieldUpdatedAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.RepoCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: agentskill.RepoTable,
|
|
Columns: []string{agentskill.RepoColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(agentskillrepo.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.RepoIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: agentskill.RepoTable,
|
|
Columns: []string{agentskill.RepoColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(agentskillrepo.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.VersionsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: agentskill.VersionsTable,
|
|
Columns: []string{agentskill.VersionsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(agentskillversion.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.RemovedVersionsIDs(); len(nodes) > 0 && !_u.mutation.VersionsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: agentskill.VersionsTable,
|
|
Columns: []string{agentskill.VersionsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(agentskillversion.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.VersionsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: agentskill.VersionsTable,
|
|
Columns: []string{agentskill.VersionsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(agentskillversion.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{agentskill.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return 0, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
// AgentSkillUpdateOne is the builder for updating a single AgentSkill entity.
|
|
type AgentSkillUpdateOne struct {
|
|
config
|
|
fields []string
|
|
hooks []Hook
|
|
mutation *AgentSkillMutation
|
|
modifiers []func(*sql.UpdateBuilder)
|
|
}
|
|
|
|
// SetRepoID sets the "repo_id" field.
|
|
func (_u *AgentSkillUpdateOne) SetRepoID(v uuid.UUID) *AgentSkillUpdateOne {
|
|
_u.mutation.SetRepoID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableRepoID sets the "repo_id" field if the given value is not nil.
|
|
func (_u *AgentSkillUpdateOne) SetNillableRepoID(v *uuid.UUID) *AgentSkillUpdateOne {
|
|
if v != nil {
|
|
_u.SetRepoID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (_u *AgentSkillUpdateOne) SetName(v string) *AgentSkillUpdateOne {
|
|
_u.mutation.SetName(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableName sets the "name" field if the given value is not nil.
|
|
func (_u *AgentSkillUpdateOne) SetNillableName(v *string) *AgentSkillUpdateOne {
|
|
if v != nil {
|
|
_u.SetName(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetDescription sets the "description" field.
|
|
func (_u *AgentSkillUpdateOne) SetDescription(v string) *AgentSkillUpdateOne {
|
|
_u.mutation.SetDescription(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableDescription sets the "description" field if the given value is not nil.
|
|
func (_u *AgentSkillUpdateOne) SetNillableDescription(v *string) *AgentSkillUpdateOne {
|
|
if v != nil {
|
|
_u.SetDescription(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearDescription clears the value of the "description" field.
|
|
func (_u *AgentSkillUpdateOne) ClearDescription() *AgentSkillUpdateOne {
|
|
_u.mutation.ClearDescription()
|
|
return _u
|
|
}
|
|
|
|
// SetScopeType sets the "scope_type" field.
|
|
func (_u *AgentSkillUpdateOne) SetScopeType(v agentskill.ScopeType) *AgentSkillUpdateOne {
|
|
_u.mutation.SetScopeType(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableScopeType sets the "scope_type" field if the given value is not nil.
|
|
func (_u *AgentSkillUpdateOne) SetNillableScopeType(v *agentskill.ScopeType) *AgentSkillUpdateOne {
|
|
if v != nil {
|
|
_u.SetScopeType(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetScopeID sets the "scope_id" field.
|
|
func (_u *AgentSkillUpdateOne) SetScopeID(v string) *AgentSkillUpdateOne {
|
|
_u.mutation.SetScopeID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableScopeID sets the "scope_id" field if the given value is not nil.
|
|
func (_u *AgentSkillUpdateOne) SetNillableScopeID(v *string) *AgentSkillUpdateOne {
|
|
if v != nil {
|
|
_u.SetScopeID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetCreatedBy sets the "created_by" field.
|
|
func (_u *AgentSkillUpdateOne) SetCreatedBy(v uuid.UUID) *AgentSkillUpdateOne {
|
|
_u.mutation.SetCreatedBy(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCreatedBy sets the "created_by" field if the given value is not nil.
|
|
func (_u *AgentSkillUpdateOne) SetNillableCreatedBy(v *uuid.UUID) *AgentSkillUpdateOne {
|
|
if v != nil {
|
|
_u.SetCreatedBy(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetActiveVersionID sets the "active_version_id" field.
|
|
func (_u *AgentSkillUpdateOne) SetActiveVersionID(v uuid.UUID) *AgentSkillUpdateOne {
|
|
_u.mutation.SetActiveVersionID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableActiveVersionID sets the "active_version_id" field if the given value is not nil.
|
|
func (_u *AgentSkillUpdateOne) SetNillableActiveVersionID(v *uuid.UUID) *AgentSkillUpdateOne {
|
|
if v != nil {
|
|
_u.SetActiveVersionID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearActiveVersionID clears the value of the "active_version_id" field.
|
|
func (_u *AgentSkillUpdateOne) ClearActiveVersionID() *AgentSkillUpdateOne {
|
|
_u.mutation.ClearActiveVersionID()
|
|
return _u
|
|
}
|
|
|
|
// SetIsForceDelivery sets the "is_force_delivery" field.
|
|
func (_u *AgentSkillUpdateOne) SetIsForceDelivery(v bool) *AgentSkillUpdateOne {
|
|
_u.mutation.SetIsForceDelivery(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableIsForceDelivery sets the "is_force_delivery" field if the given value is not nil.
|
|
func (_u *AgentSkillUpdateOne) SetNillableIsForceDelivery(v *bool) *AgentSkillUpdateOne {
|
|
if v != nil {
|
|
_u.SetIsForceDelivery(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetIsOrphan sets the "is_orphan" field.
|
|
func (_u *AgentSkillUpdateOne) SetIsOrphan(v bool) *AgentSkillUpdateOne {
|
|
_u.mutation.SetIsOrphan(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableIsOrphan sets the "is_orphan" field if the given value is not nil.
|
|
func (_u *AgentSkillUpdateOne) SetNillableIsOrphan(v *bool) *AgentSkillUpdateOne {
|
|
if v != nil {
|
|
_u.SetIsOrphan(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetIsDeleted sets the "is_deleted" field.
|
|
func (_u *AgentSkillUpdateOne) SetIsDeleted(v bool) *AgentSkillUpdateOne {
|
|
_u.mutation.SetIsDeleted(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableIsDeleted sets the "is_deleted" field if the given value is not nil.
|
|
func (_u *AgentSkillUpdateOne) SetNillableIsDeleted(v *bool) *AgentSkillUpdateOne {
|
|
if v != nil {
|
|
_u.SetIsDeleted(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetEnabled sets the "enabled" field.
|
|
func (_u *AgentSkillUpdateOne) SetEnabled(v bool) *AgentSkillUpdateOne {
|
|
_u.mutation.SetEnabled(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableEnabled sets the "enabled" field if the given value is not nil.
|
|
func (_u *AgentSkillUpdateOne) SetNillableEnabled(v *bool) *AgentSkillUpdateOne {
|
|
if v != nil {
|
|
_u.SetEnabled(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetExtensionPackageID sets the "extension_package_id" field.
|
|
func (_u *AgentSkillUpdateOne) SetExtensionPackageID(v string) *AgentSkillUpdateOne {
|
|
_u.mutation.SetExtensionPackageID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableExtensionPackageID sets the "extension_package_id" field if the given value is not nil.
|
|
func (_u *AgentSkillUpdateOne) SetNillableExtensionPackageID(v *string) *AgentSkillUpdateOne {
|
|
if v != nil {
|
|
_u.SetExtensionPackageID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearExtensionPackageID clears the value of the "extension_package_id" field.
|
|
func (_u *AgentSkillUpdateOne) ClearExtensionPackageID() *AgentSkillUpdateOne {
|
|
_u.mutation.ClearExtensionPackageID()
|
|
return _u
|
|
}
|
|
|
|
// SetAdminDescription sets the "admin_description" field.
|
|
func (_u *AgentSkillUpdateOne) SetAdminDescription(v string) *AgentSkillUpdateOne {
|
|
_u.mutation.SetAdminDescription(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableAdminDescription sets the "admin_description" field if the given value is not nil.
|
|
func (_u *AgentSkillUpdateOne) SetNillableAdminDescription(v *string) *AgentSkillUpdateOne {
|
|
if v != nil {
|
|
_u.SetAdminDescription(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearAdminDescription clears the value of the "admin_description" field.
|
|
func (_u *AgentSkillUpdateOne) ClearAdminDescription() *AgentSkillUpdateOne {
|
|
_u.mutation.ClearAdminDescription()
|
|
return _u
|
|
}
|
|
|
|
// SetAdminTags sets the "admin_tags" field.
|
|
func (_u *AgentSkillUpdateOne) SetAdminTags(v []string) *AgentSkillUpdateOne {
|
|
_u.mutation.SetAdminTags(v)
|
|
return _u
|
|
}
|
|
|
|
// AppendAdminTags appends value to the "admin_tags" field.
|
|
func (_u *AgentSkillUpdateOne) AppendAdminTags(v []string) *AgentSkillUpdateOne {
|
|
_u.mutation.AppendAdminTags(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearAdminTags clears the value of the "admin_tags" field.
|
|
func (_u *AgentSkillUpdateOne) ClearAdminTags() *AgentSkillUpdateOne {
|
|
_u.mutation.ClearAdminTags()
|
|
return _u
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (_u *AgentSkillUpdateOne) SetCreatedAt(v time.Time) *AgentSkillUpdateOne {
|
|
_u.mutation.SetCreatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (_u *AgentSkillUpdateOne) SetNillableCreatedAt(v *time.Time) *AgentSkillUpdateOne {
|
|
if v != nil {
|
|
_u.SetCreatedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (_u *AgentSkillUpdateOne) SetUpdatedAt(v time.Time) *AgentSkillUpdateOne {
|
|
_u.mutation.SetUpdatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetRepo sets the "repo" edge to the AgentSkillRepo entity.
|
|
func (_u *AgentSkillUpdateOne) SetRepo(v *AgentSkillRepo) *AgentSkillUpdateOne {
|
|
return _u.SetRepoID(v.ID)
|
|
}
|
|
|
|
// AddVersionIDs adds the "versions" edge to the AgentSkillVersion entity by IDs.
|
|
func (_u *AgentSkillUpdateOne) AddVersionIDs(ids ...uuid.UUID) *AgentSkillUpdateOne {
|
|
_u.mutation.AddVersionIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddVersions adds the "versions" edges to the AgentSkillVersion entity.
|
|
func (_u *AgentSkillUpdateOne) AddVersions(v ...*AgentSkillVersion) *AgentSkillUpdateOne {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddVersionIDs(ids...)
|
|
}
|
|
|
|
// Mutation returns the AgentSkillMutation object of the builder.
|
|
func (_u *AgentSkillUpdateOne) Mutation() *AgentSkillMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// ClearRepo clears the "repo" edge to the AgentSkillRepo entity.
|
|
func (_u *AgentSkillUpdateOne) ClearRepo() *AgentSkillUpdateOne {
|
|
_u.mutation.ClearRepo()
|
|
return _u
|
|
}
|
|
|
|
// ClearVersions clears all "versions" edges to the AgentSkillVersion entity.
|
|
func (_u *AgentSkillUpdateOne) ClearVersions() *AgentSkillUpdateOne {
|
|
_u.mutation.ClearVersions()
|
|
return _u
|
|
}
|
|
|
|
// RemoveVersionIDs removes the "versions" edge to AgentSkillVersion entities by IDs.
|
|
func (_u *AgentSkillUpdateOne) RemoveVersionIDs(ids ...uuid.UUID) *AgentSkillUpdateOne {
|
|
_u.mutation.RemoveVersionIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveVersions removes "versions" edges to AgentSkillVersion entities.
|
|
func (_u *AgentSkillUpdateOne) RemoveVersions(v ...*AgentSkillVersion) *AgentSkillUpdateOne {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveVersionIDs(ids...)
|
|
}
|
|
|
|
// Where appends a list predicates to the AgentSkillUpdate builder.
|
|
func (_u *AgentSkillUpdateOne) Where(ps ...predicate.AgentSkill) *AgentSkillUpdateOne {
|
|
_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 *AgentSkillUpdateOne) Select(field string, fields ...string) *AgentSkillUpdateOne {
|
|
_u.fields = append([]string{field}, fields...)
|
|
return _u
|
|
}
|
|
|
|
// Save executes the query and returns the updated AgentSkill entity.
|
|
func (_u *AgentSkillUpdateOne) Save(ctx context.Context) (*AgentSkill, error) {
|
|
_u.defaults()
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *AgentSkillUpdateOne) SaveX(ctx context.Context) *AgentSkill {
|
|
node, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// Exec executes the query on the entity.
|
|
func (_u *AgentSkillUpdateOne) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *AgentSkillUpdateOne) 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 *AgentSkillUpdateOne) defaults() {
|
|
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
|
v := agentskill.UpdateDefaultUpdatedAt()
|
|
_u.mutation.SetUpdatedAt(v)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_u *AgentSkillUpdateOne) check() error {
|
|
if v, ok := _u.mutation.Name(); ok {
|
|
if err := agentskill.NameValidator(v); err != nil {
|
|
return &ValidationError{Name: "name", err: fmt.Errorf(`db: validator failed for field "AgentSkill.name": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.ScopeType(); ok {
|
|
if err := agentskill.ScopeTypeValidator(v); err != nil {
|
|
return &ValidationError{Name: "scope_type", err: fmt.Errorf(`db: validator failed for field "AgentSkill.scope_type": %w`, err)}
|
|
}
|
|
}
|
|
if _u.mutation.RepoCleared() && len(_u.mutation.RepoIDs()) > 0 {
|
|
return errors.New(`db: clearing a required unique edge "AgentSkill.repo"`)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
|
func (_u *AgentSkillUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *AgentSkillUpdateOne {
|
|
_u.modifiers = append(_u.modifiers, modifiers...)
|
|
return _u
|
|
}
|
|
|
|
func (_u *AgentSkillUpdateOne) sqlSave(ctx context.Context) (_node *AgentSkill, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(agentskill.Table, agentskill.Columns, sqlgraph.NewFieldSpec(agentskill.FieldID, field.TypeUUID))
|
|
id, ok := _u.mutation.ID()
|
|
if !ok {
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`db: missing "AgentSkill.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, agentskill.FieldID)
|
|
for _, f := range fields {
|
|
if !agentskill.ValidColumn(f) {
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)}
|
|
}
|
|
if f != agentskill.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.Name(); ok {
|
|
_spec.SetField(agentskill.FieldName, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Description(); ok {
|
|
_spec.SetField(agentskill.FieldDescription, field.TypeString, value)
|
|
}
|
|
if _u.mutation.DescriptionCleared() {
|
|
_spec.ClearField(agentskill.FieldDescription, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.ScopeType(); ok {
|
|
_spec.SetField(agentskill.FieldScopeType, field.TypeEnum, value)
|
|
}
|
|
if value, ok := _u.mutation.ScopeID(); ok {
|
|
_spec.SetField(agentskill.FieldScopeID, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.CreatedBy(); ok {
|
|
_spec.SetField(agentskill.FieldCreatedBy, field.TypeUUID, value)
|
|
}
|
|
if value, ok := _u.mutation.ActiveVersionID(); ok {
|
|
_spec.SetField(agentskill.FieldActiveVersionID, field.TypeUUID, value)
|
|
}
|
|
if _u.mutation.ActiveVersionIDCleared() {
|
|
_spec.ClearField(agentskill.FieldActiveVersionID, field.TypeUUID)
|
|
}
|
|
if value, ok := _u.mutation.IsForceDelivery(); ok {
|
|
_spec.SetField(agentskill.FieldIsForceDelivery, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.IsOrphan(); ok {
|
|
_spec.SetField(agentskill.FieldIsOrphan, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.IsDeleted(); ok {
|
|
_spec.SetField(agentskill.FieldIsDeleted, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.Enabled(); ok {
|
|
_spec.SetField(agentskill.FieldEnabled, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.ExtensionPackageID(); ok {
|
|
_spec.SetField(agentskill.FieldExtensionPackageID, field.TypeString, value)
|
|
}
|
|
if _u.mutation.ExtensionPackageIDCleared() {
|
|
_spec.ClearField(agentskill.FieldExtensionPackageID, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.AdminDescription(); ok {
|
|
_spec.SetField(agentskill.FieldAdminDescription, field.TypeString, value)
|
|
}
|
|
if _u.mutation.AdminDescriptionCleared() {
|
|
_spec.ClearField(agentskill.FieldAdminDescription, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.AdminTags(); ok {
|
|
_spec.SetField(agentskill.FieldAdminTags, field.TypeJSON, value)
|
|
}
|
|
if value, ok := _u.mutation.AppendedAdminTags(); ok {
|
|
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
|
sqljson.Append(u, agentskill.FieldAdminTags, value)
|
|
})
|
|
}
|
|
if _u.mutation.AdminTagsCleared() {
|
|
_spec.ClearField(agentskill.FieldAdminTags, field.TypeJSON)
|
|
}
|
|
if value, ok := _u.mutation.CreatedAt(); ok {
|
|
_spec.SetField(agentskill.FieldCreatedAt, field.TypeTime, value)
|
|
}
|
|
if value, ok := _u.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(agentskill.FieldUpdatedAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.RepoCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: agentskill.RepoTable,
|
|
Columns: []string{agentskill.RepoColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(agentskillrepo.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.RepoIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: agentskill.RepoTable,
|
|
Columns: []string{agentskill.RepoColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(agentskillrepo.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.VersionsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: agentskill.VersionsTable,
|
|
Columns: []string{agentskill.VersionsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(agentskillversion.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.RemovedVersionsIDs(); len(nodes) > 0 && !_u.mutation.VersionsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: agentskill.VersionsTable,
|
|
Columns: []string{agentskill.VersionsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(agentskillversion.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.VersionsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: agentskill.VersionsTable,
|
|
Columns: []string{agentskill.VersionsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(agentskillversion.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 = &AgentSkill{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{agentskill.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|