mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-11-22 19:39:31 +08:00
1419 lines
43 KiB
Go
1419 lines
43 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/consts"
|
|
"github.com/chaitin/MonkeyCode/backend/db/gitidentity"
|
|
"github.com/chaitin/MonkeyCode/backend/db/predicate"
|
|
"github.com/chaitin/MonkeyCode/backend/db/project"
|
|
"github.com/chaitin/MonkeyCode/backend/db/projecttask"
|
|
"github.com/chaitin/MonkeyCode/backend/db/user"
|
|
"github.com/chaitin/MonkeyCode/backend/db/virtualmachine"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// GitIdentityUpdate is the builder for updating GitIdentity entities.
|
|
type GitIdentityUpdate struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *GitIdentityMutation
|
|
modifiers []func(*sql.UpdateBuilder)
|
|
}
|
|
|
|
// Where appends a list predicates to the GitIdentityUpdate builder.
|
|
func (_u *GitIdentityUpdate) Where(ps ...predicate.GitIdentity) *GitIdentityUpdate {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (_u *GitIdentityUpdate) SetDeletedAt(v time.Time) *GitIdentityUpdate {
|
|
_u.mutation.SetDeletedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
|
|
func (_u *GitIdentityUpdate) SetNillableDeletedAt(v *time.Time) *GitIdentityUpdate {
|
|
if v != nil {
|
|
_u.SetDeletedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
func (_u *GitIdentityUpdate) ClearDeletedAt() *GitIdentityUpdate {
|
|
_u.mutation.ClearDeletedAt()
|
|
return _u
|
|
}
|
|
|
|
// SetUserID sets the "user_id" field.
|
|
func (_u *GitIdentityUpdate) SetUserID(v uuid.UUID) *GitIdentityUpdate {
|
|
_u.mutation.SetUserID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUserID sets the "user_id" field if the given value is not nil.
|
|
func (_u *GitIdentityUpdate) SetNillableUserID(v *uuid.UUID) *GitIdentityUpdate {
|
|
if v != nil {
|
|
_u.SetUserID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetPlatform sets the "platform" field.
|
|
func (_u *GitIdentityUpdate) SetPlatform(v consts.GitPlatform) *GitIdentityUpdate {
|
|
_u.mutation.SetPlatform(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillablePlatform sets the "platform" field if the given value is not nil.
|
|
func (_u *GitIdentityUpdate) SetNillablePlatform(v *consts.GitPlatform) *GitIdentityUpdate {
|
|
if v != nil {
|
|
_u.SetPlatform(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetBaseURL sets the "base_url" field.
|
|
func (_u *GitIdentityUpdate) SetBaseURL(v string) *GitIdentityUpdate {
|
|
_u.mutation.SetBaseURL(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableBaseURL sets the "base_url" field if the given value is not nil.
|
|
func (_u *GitIdentityUpdate) SetNillableBaseURL(v *string) *GitIdentityUpdate {
|
|
if v != nil {
|
|
_u.SetBaseURL(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearBaseURL clears the value of the "base_url" field.
|
|
func (_u *GitIdentityUpdate) ClearBaseURL() *GitIdentityUpdate {
|
|
_u.mutation.ClearBaseURL()
|
|
return _u
|
|
}
|
|
|
|
// SetAccessToken sets the "access_token" field.
|
|
func (_u *GitIdentityUpdate) SetAccessToken(v string) *GitIdentityUpdate {
|
|
_u.mutation.SetAccessToken(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableAccessToken sets the "access_token" field if the given value is not nil.
|
|
func (_u *GitIdentityUpdate) SetNillableAccessToken(v *string) *GitIdentityUpdate {
|
|
if v != nil {
|
|
_u.SetAccessToken(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearAccessToken clears the value of the "access_token" field.
|
|
func (_u *GitIdentityUpdate) ClearAccessToken() *GitIdentityUpdate {
|
|
_u.mutation.ClearAccessToken()
|
|
return _u
|
|
}
|
|
|
|
// SetUsername sets the "username" field.
|
|
func (_u *GitIdentityUpdate) SetUsername(v string) *GitIdentityUpdate {
|
|
_u.mutation.SetUsername(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUsername sets the "username" field if the given value is not nil.
|
|
func (_u *GitIdentityUpdate) SetNillableUsername(v *string) *GitIdentityUpdate {
|
|
if v != nil {
|
|
_u.SetUsername(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearUsername clears the value of the "username" field.
|
|
func (_u *GitIdentityUpdate) ClearUsername() *GitIdentityUpdate {
|
|
_u.mutation.ClearUsername()
|
|
return _u
|
|
}
|
|
|
|
// SetEmail sets the "email" field.
|
|
func (_u *GitIdentityUpdate) SetEmail(v string) *GitIdentityUpdate {
|
|
_u.mutation.SetEmail(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableEmail sets the "email" field if the given value is not nil.
|
|
func (_u *GitIdentityUpdate) SetNillableEmail(v *string) *GitIdentityUpdate {
|
|
if v != nil {
|
|
_u.SetEmail(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearEmail clears the value of the "email" field.
|
|
func (_u *GitIdentityUpdate) ClearEmail() *GitIdentityUpdate {
|
|
_u.mutation.ClearEmail()
|
|
return _u
|
|
}
|
|
|
|
// SetInstallationID sets the "installation_id" field.
|
|
func (_u *GitIdentityUpdate) SetInstallationID(v int64) *GitIdentityUpdate {
|
|
_u.mutation.ResetInstallationID()
|
|
_u.mutation.SetInstallationID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableInstallationID sets the "installation_id" field if the given value is not nil.
|
|
func (_u *GitIdentityUpdate) SetNillableInstallationID(v *int64) *GitIdentityUpdate {
|
|
if v != nil {
|
|
_u.SetInstallationID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddInstallationID adds value to the "installation_id" field.
|
|
func (_u *GitIdentityUpdate) AddInstallationID(v int64) *GitIdentityUpdate {
|
|
_u.mutation.AddInstallationID(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearInstallationID clears the value of the "installation_id" field.
|
|
func (_u *GitIdentityUpdate) ClearInstallationID() *GitIdentityUpdate {
|
|
_u.mutation.ClearInstallationID()
|
|
return _u
|
|
}
|
|
|
|
// SetRemark sets the "remark" field.
|
|
func (_u *GitIdentityUpdate) SetRemark(v string) *GitIdentityUpdate {
|
|
_u.mutation.SetRemark(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableRemark sets the "remark" field if the given value is not nil.
|
|
func (_u *GitIdentityUpdate) SetNillableRemark(v *string) *GitIdentityUpdate {
|
|
if v != nil {
|
|
_u.SetRemark(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearRemark clears the value of the "remark" field.
|
|
func (_u *GitIdentityUpdate) ClearRemark() *GitIdentityUpdate {
|
|
_u.mutation.ClearRemark()
|
|
return _u
|
|
}
|
|
|
|
// SetOauthRefreshToken sets the "oauth_refresh_token" field.
|
|
func (_u *GitIdentityUpdate) SetOauthRefreshToken(v string) *GitIdentityUpdate {
|
|
_u.mutation.SetOauthRefreshToken(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableOauthRefreshToken sets the "oauth_refresh_token" field if the given value is not nil.
|
|
func (_u *GitIdentityUpdate) SetNillableOauthRefreshToken(v *string) *GitIdentityUpdate {
|
|
if v != nil {
|
|
_u.SetOauthRefreshToken(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearOauthRefreshToken clears the value of the "oauth_refresh_token" field.
|
|
func (_u *GitIdentityUpdate) ClearOauthRefreshToken() *GitIdentityUpdate {
|
|
_u.mutation.ClearOauthRefreshToken()
|
|
return _u
|
|
}
|
|
|
|
// SetOauthExpiresAt sets the "oauth_expires_at" field.
|
|
func (_u *GitIdentityUpdate) SetOauthExpiresAt(v time.Time) *GitIdentityUpdate {
|
|
_u.mutation.SetOauthExpiresAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableOauthExpiresAt sets the "oauth_expires_at" field if the given value is not nil.
|
|
func (_u *GitIdentityUpdate) SetNillableOauthExpiresAt(v *time.Time) *GitIdentityUpdate {
|
|
if v != nil {
|
|
_u.SetOauthExpiresAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearOauthExpiresAt clears the value of the "oauth_expires_at" field.
|
|
func (_u *GitIdentityUpdate) ClearOauthExpiresAt() *GitIdentityUpdate {
|
|
_u.mutation.ClearOauthExpiresAt()
|
|
return _u
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (_u *GitIdentityUpdate) SetCreatedAt(v time.Time) *GitIdentityUpdate {
|
|
_u.mutation.SetCreatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (_u *GitIdentityUpdate) SetNillableCreatedAt(v *time.Time) *GitIdentityUpdate {
|
|
if v != nil {
|
|
_u.SetCreatedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (_u *GitIdentityUpdate) SetUpdatedAt(v time.Time) *GitIdentityUpdate {
|
|
_u.mutation.SetUpdatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetUser sets the "user" edge to the User entity.
|
|
func (_u *GitIdentityUpdate) SetUser(v *User) *GitIdentityUpdate {
|
|
return _u.SetUserID(v.ID)
|
|
}
|
|
|
|
// AddProjectIDs adds the "projects" edge to the Project entity by IDs.
|
|
func (_u *GitIdentityUpdate) AddProjectIDs(ids ...uuid.UUID) *GitIdentityUpdate {
|
|
_u.mutation.AddProjectIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddProjects adds the "projects" edges to the Project entity.
|
|
func (_u *GitIdentityUpdate) AddProjects(v ...*Project) *GitIdentityUpdate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddProjectIDs(ids...)
|
|
}
|
|
|
|
// AddProjectTaskIDs adds the "project_tasks" edge to the ProjectTask entity by IDs.
|
|
func (_u *GitIdentityUpdate) AddProjectTaskIDs(ids ...uuid.UUID) *GitIdentityUpdate {
|
|
_u.mutation.AddProjectTaskIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddProjectTasks adds the "project_tasks" edges to the ProjectTask entity.
|
|
func (_u *GitIdentityUpdate) AddProjectTasks(v ...*ProjectTask) *GitIdentityUpdate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddProjectTaskIDs(ids...)
|
|
}
|
|
|
|
// AddVMIDs adds the "vms" edge to the VirtualMachine entity by IDs.
|
|
func (_u *GitIdentityUpdate) AddVMIDs(ids ...string) *GitIdentityUpdate {
|
|
_u.mutation.AddVMIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddVms adds the "vms" edges to the VirtualMachine entity.
|
|
func (_u *GitIdentityUpdate) AddVms(v ...*VirtualMachine) *GitIdentityUpdate {
|
|
ids := make([]string, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddVMIDs(ids...)
|
|
}
|
|
|
|
// Mutation returns the GitIdentityMutation object of the builder.
|
|
func (_u *GitIdentityUpdate) Mutation() *GitIdentityMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// ClearUser clears the "user" edge to the User entity.
|
|
func (_u *GitIdentityUpdate) ClearUser() *GitIdentityUpdate {
|
|
_u.mutation.ClearUser()
|
|
return _u
|
|
}
|
|
|
|
// ClearProjects clears all "projects" edges to the Project entity.
|
|
func (_u *GitIdentityUpdate) ClearProjects() *GitIdentityUpdate {
|
|
_u.mutation.ClearProjects()
|
|
return _u
|
|
}
|
|
|
|
// RemoveProjectIDs removes the "projects" edge to Project entities by IDs.
|
|
func (_u *GitIdentityUpdate) RemoveProjectIDs(ids ...uuid.UUID) *GitIdentityUpdate {
|
|
_u.mutation.RemoveProjectIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveProjects removes "projects" edges to Project entities.
|
|
func (_u *GitIdentityUpdate) RemoveProjects(v ...*Project) *GitIdentityUpdate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveProjectIDs(ids...)
|
|
}
|
|
|
|
// ClearProjectTasks clears all "project_tasks" edges to the ProjectTask entity.
|
|
func (_u *GitIdentityUpdate) ClearProjectTasks() *GitIdentityUpdate {
|
|
_u.mutation.ClearProjectTasks()
|
|
return _u
|
|
}
|
|
|
|
// RemoveProjectTaskIDs removes the "project_tasks" edge to ProjectTask entities by IDs.
|
|
func (_u *GitIdentityUpdate) RemoveProjectTaskIDs(ids ...uuid.UUID) *GitIdentityUpdate {
|
|
_u.mutation.RemoveProjectTaskIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveProjectTasks removes "project_tasks" edges to ProjectTask entities.
|
|
func (_u *GitIdentityUpdate) RemoveProjectTasks(v ...*ProjectTask) *GitIdentityUpdate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveProjectTaskIDs(ids...)
|
|
}
|
|
|
|
// ClearVms clears all "vms" edges to the VirtualMachine entity.
|
|
func (_u *GitIdentityUpdate) ClearVms() *GitIdentityUpdate {
|
|
_u.mutation.ClearVms()
|
|
return _u
|
|
}
|
|
|
|
// RemoveVMIDs removes the "vms" edge to VirtualMachine entities by IDs.
|
|
func (_u *GitIdentityUpdate) RemoveVMIDs(ids ...string) *GitIdentityUpdate {
|
|
_u.mutation.RemoveVMIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveVms removes "vms" edges to VirtualMachine entities.
|
|
func (_u *GitIdentityUpdate) RemoveVms(v ...*VirtualMachine) *GitIdentityUpdate {
|
|
ids := make([]string, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveVMIDs(ids...)
|
|
}
|
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
func (_u *GitIdentityUpdate) Save(ctx context.Context) (int, error) {
|
|
if err := _u.defaults(); err != nil {
|
|
return 0, err
|
|
}
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *GitIdentityUpdate) SaveX(ctx context.Context) int {
|
|
affected, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return affected
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_u *GitIdentityUpdate) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *GitIdentityUpdate) 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 *GitIdentityUpdate) defaults() error {
|
|
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
|
if gitidentity.UpdateDefaultUpdatedAt == nil {
|
|
return fmt.Errorf("db: uninitialized gitidentity.UpdateDefaultUpdatedAt (forgotten import db/runtime?)")
|
|
}
|
|
v := gitidentity.UpdateDefaultUpdatedAt()
|
|
_u.mutation.SetUpdatedAt(v)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_u *GitIdentityUpdate) check() error {
|
|
if _u.mutation.UserCleared() && len(_u.mutation.UserIDs()) > 0 {
|
|
return errors.New(`db: clearing a required unique edge "GitIdentity.user"`)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
|
func (_u *GitIdentityUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *GitIdentityUpdate {
|
|
_u.modifiers = append(_u.modifiers, modifiers...)
|
|
return _u
|
|
}
|
|
|
|
func (_u *GitIdentityUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(gitidentity.Table, gitidentity.Columns, sqlgraph.NewFieldSpec(gitidentity.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.DeletedAt(); ok {
|
|
_spec.SetField(gitidentity.FieldDeletedAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.DeletedAtCleared() {
|
|
_spec.ClearField(gitidentity.FieldDeletedAt, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.Platform(); ok {
|
|
_spec.SetField(gitidentity.FieldPlatform, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.BaseURL(); ok {
|
|
_spec.SetField(gitidentity.FieldBaseURL, field.TypeString, value)
|
|
}
|
|
if _u.mutation.BaseURLCleared() {
|
|
_spec.ClearField(gitidentity.FieldBaseURL, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.AccessToken(); ok {
|
|
_spec.SetField(gitidentity.FieldAccessToken, field.TypeString, value)
|
|
}
|
|
if _u.mutation.AccessTokenCleared() {
|
|
_spec.ClearField(gitidentity.FieldAccessToken, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.Username(); ok {
|
|
_spec.SetField(gitidentity.FieldUsername, field.TypeString, value)
|
|
}
|
|
if _u.mutation.UsernameCleared() {
|
|
_spec.ClearField(gitidentity.FieldUsername, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.Email(); ok {
|
|
_spec.SetField(gitidentity.FieldEmail, field.TypeString, value)
|
|
}
|
|
if _u.mutation.EmailCleared() {
|
|
_spec.ClearField(gitidentity.FieldEmail, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.InstallationID(); ok {
|
|
_spec.SetField(gitidentity.FieldInstallationID, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedInstallationID(); ok {
|
|
_spec.AddField(gitidentity.FieldInstallationID, field.TypeInt64, value)
|
|
}
|
|
if _u.mutation.InstallationIDCleared() {
|
|
_spec.ClearField(gitidentity.FieldInstallationID, field.TypeInt64)
|
|
}
|
|
if value, ok := _u.mutation.Remark(); ok {
|
|
_spec.SetField(gitidentity.FieldRemark, field.TypeString, value)
|
|
}
|
|
if _u.mutation.RemarkCleared() {
|
|
_spec.ClearField(gitidentity.FieldRemark, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.OauthRefreshToken(); ok {
|
|
_spec.SetField(gitidentity.FieldOauthRefreshToken, field.TypeString, value)
|
|
}
|
|
if _u.mutation.OauthRefreshTokenCleared() {
|
|
_spec.ClearField(gitidentity.FieldOauthRefreshToken, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.OauthExpiresAt(); ok {
|
|
_spec.SetField(gitidentity.FieldOauthExpiresAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.OauthExpiresAtCleared() {
|
|
_spec.ClearField(gitidentity.FieldOauthExpiresAt, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.CreatedAt(); ok {
|
|
_spec.SetField(gitidentity.FieldCreatedAt, field.TypeTime, value)
|
|
}
|
|
if value, ok := _u.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(gitidentity.FieldUpdatedAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.UserCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: gitidentity.UserTable,
|
|
Columns: []string{gitidentity.UserColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.UserIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: gitidentity.UserTable,
|
|
Columns: []string{gitidentity.UserColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(user.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.ProjectsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: gitidentity.ProjectsTable,
|
|
Columns: []string{gitidentity.ProjectsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(project.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.RemovedProjectsIDs(); len(nodes) > 0 && !_u.mutation.ProjectsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: gitidentity.ProjectsTable,
|
|
Columns: []string{gitidentity.ProjectsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(project.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.ProjectsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: gitidentity.ProjectsTable,
|
|
Columns: []string{gitidentity.ProjectsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(project.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.ProjectTasksCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: gitidentity.ProjectTasksTable,
|
|
Columns: []string{gitidentity.ProjectTasksColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(projecttask.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.RemovedProjectTasksIDs(); len(nodes) > 0 && !_u.mutation.ProjectTasksCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: gitidentity.ProjectTasksTable,
|
|
Columns: []string{gitidentity.ProjectTasksColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(projecttask.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.ProjectTasksIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: gitidentity.ProjectTasksTable,
|
|
Columns: []string{gitidentity.ProjectTasksColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(projecttask.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.VmsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: gitidentity.VmsTable,
|
|
Columns: []string{gitidentity.VmsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(virtualmachine.FieldID, field.TypeString),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.RemovedVmsIDs(); len(nodes) > 0 && !_u.mutation.VmsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: gitidentity.VmsTable,
|
|
Columns: []string{gitidentity.VmsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(virtualmachine.FieldID, field.TypeString),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.VmsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: gitidentity.VmsTable,
|
|
Columns: []string{gitidentity.VmsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(virtualmachine.FieldID, field.TypeString),
|
|
},
|
|
}
|
|
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{gitidentity.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return 0, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
// GitIdentityUpdateOne is the builder for updating a single GitIdentity entity.
|
|
type GitIdentityUpdateOne struct {
|
|
config
|
|
fields []string
|
|
hooks []Hook
|
|
mutation *GitIdentityMutation
|
|
modifiers []func(*sql.UpdateBuilder)
|
|
}
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (_u *GitIdentityUpdateOne) SetDeletedAt(v time.Time) *GitIdentityUpdateOne {
|
|
_u.mutation.SetDeletedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
|
|
func (_u *GitIdentityUpdateOne) SetNillableDeletedAt(v *time.Time) *GitIdentityUpdateOne {
|
|
if v != nil {
|
|
_u.SetDeletedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
func (_u *GitIdentityUpdateOne) ClearDeletedAt() *GitIdentityUpdateOne {
|
|
_u.mutation.ClearDeletedAt()
|
|
return _u
|
|
}
|
|
|
|
// SetUserID sets the "user_id" field.
|
|
func (_u *GitIdentityUpdateOne) SetUserID(v uuid.UUID) *GitIdentityUpdateOne {
|
|
_u.mutation.SetUserID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUserID sets the "user_id" field if the given value is not nil.
|
|
func (_u *GitIdentityUpdateOne) SetNillableUserID(v *uuid.UUID) *GitIdentityUpdateOne {
|
|
if v != nil {
|
|
_u.SetUserID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetPlatform sets the "platform" field.
|
|
func (_u *GitIdentityUpdateOne) SetPlatform(v consts.GitPlatform) *GitIdentityUpdateOne {
|
|
_u.mutation.SetPlatform(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillablePlatform sets the "platform" field if the given value is not nil.
|
|
func (_u *GitIdentityUpdateOne) SetNillablePlatform(v *consts.GitPlatform) *GitIdentityUpdateOne {
|
|
if v != nil {
|
|
_u.SetPlatform(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetBaseURL sets the "base_url" field.
|
|
func (_u *GitIdentityUpdateOne) SetBaseURL(v string) *GitIdentityUpdateOne {
|
|
_u.mutation.SetBaseURL(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableBaseURL sets the "base_url" field if the given value is not nil.
|
|
func (_u *GitIdentityUpdateOne) SetNillableBaseURL(v *string) *GitIdentityUpdateOne {
|
|
if v != nil {
|
|
_u.SetBaseURL(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearBaseURL clears the value of the "base_url" field.
|
|
func (_u *GitIdentityUpdateOne) ClearBaseURL() *GitIdentityUpdateOne {
|
|
_u.mutation.ClearBaseURL()
|
|
return _u
|
|
}
|
|
|
|
// SetAccessToken sets the "access_token" field.
|
|
func (_u *GitIdentityUpdateOne) SetAccessToken(v string) *GitIdentityUpdateOne {
|
|
_u.mutation.SetAccessToken(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableAccessToken sets the "access_token" field if the given value is not nil.
|
|
func (_u *GitIdentityUpdateOne) SetNillableAccessToken(v *string) *GitIdentityUpdateOne {
|
|
if v != nil {
|
|
_u.SetAccessToken(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearAccessToken clears the value of the "access_token" field.
|
|
func (_u *GitIdentityUpdateOne) ClearAccessToken() *GitIdentityUpdateOne {
|
|
_u.mutation.ClearAccessToken()
|
|
return _u
|
|
}
|
|
|
|
// SetUsername sets the "username" field.
|
|
func (_u *GitIdentityUpdateOne) SetUsername(v string) *GitIdentityUpdateOne {
|
|
_u.mutation.SetUsername(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUsername sets the "username" field if the given value is not nil.
|
|
func (_u *GitIdentityUpdateOne) SetNillableUsername(v *string) *GitIdentityUpdateOne {
|
|
if v != nil {
|
|
_u.SetUsername(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearUsername clears the value of the "username" field.
|
|
func (_u *GitIdentityUpdateOne) ClearUsername() *GitIdentityUpdateOne {
|
|
_u.mutation.ClearUsername()
|
|
return _u
|
|
}
|
|
|
|
// SetEmail sets the "email" field.
|
|
func (_u *GitIdentityUpdateOne) SetEmail(v string) *GitIdentityUpdateOne {
|
|
_u.mutation.SetEmail(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableEmail sets the "email" field if the given value is not nil.
|
|
func (_u *GitIdentityUpdateOne) SetNillableEmail(v *string) *GitIdentityUpdateOne {
|
|
if v != nil {
|
|
_u.SetEmail(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearEmail clears the value of the "email" field.
|
|
func (_u *GitIdentityUpdateOne) ClearEmail() *GitIdentityUpdateOne {
|
|
_u.mutation.ClearEmail()
|
|
return _u
|
|
}
|
|
|
|
// SetInstallationID sets the "installation_id" field.
|
|
func (_u *GitIdentityUpdateOne) SetInstallationID(v int64) *GitIdentityUpdateOne {
|
|
_u.mutation.ResetInstallationID()
|
|
_u.mutation.SetInstallationID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableInstallationID sets the "installation_id" field if the given value is not nil.
|
|
func (_u *GitIdentityUpdateOne) SetNillableInstallationID(v *int64) *GitIdentityUpdateOne {
|
|
if v != nil {
|
|
_u.SetInstallationID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddInstallationID adds value to the "installation_id" field.
|
|
func (_u *GitIdentityUpdateOne) AddInstallationID(v int64) *GitIdentityUpdateOne {
|
|
_u.mutation.AddInstallationID(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearInstallationID clears the value of the "installation_id" field.
|
|
func (_u *GitIdentityUpdateOne) ClearInstallationID() *GitIdentityUpdateOne {
|
|
_u.mutation.ClearInstallationID()
|
|
return _u
|
|
}
|
|
|
|
// SetRemark sets the "remark" field.
|
|
func (_u *GitIdentityUpdateOne) SetRemark(v string) *GitIdentityUpdateOne {
|
|
_u.mutation.SetRemark(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableRemark sets the "remark" field if the given value is not nil.
|
|
func (_u *GitIdentityUpdateOne) SetNillableRemark(v *string) *GitIdentityUpdateOne {
|
|
if v != nil {
|
|
_u.SetRemark(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearRemark clears the value of the "remark" field.
|
|
func (_u *GitIdentityUpdateOne) ClearRemark() *GitIdentityUpdateOne {
|
|
_u.mutation.ClearRemark()
|
|
return _u
|
|
}
|
|
|
|
// SetOauthRefreshToken sets the "oauth_refresh_token" field.
|
|
func (_u *GitIdentityUpdateOne) SetOauthRefreshToken(v string) *GitIdentityUpdateOne {
|
|
_u.mutation.SetOauthRefreshToken(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableOauthRefreshToken sets the "oauth_refresh_token" field if the given value is not nil.
|
|
func (_u *GitIdentityUpdateOne) SetNillableOauthRefreshToken(v *string) *GitIdentityUpdateOne {
|
|
if v != nil {
|
|
_u.SetOauthRefreshToken(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearOauthRefreshToken clears the value of the "oauth_refresh_token" field.
|
|
func (_u *GitIdentityUpdateOne) ClearOauthRefreshToken() *GitIdentityUpdateOne {
|
|
_u.mutation.ClearOauthRefreshToken()
|
|
return _u
|
|
}
|
|
|
|
// SetOauthExpiresAt sets the "oauth_expires_at" field.
|
|
func (_u *GitIdentityUpdateOne) SetOauthExpiresAt(v time.Time) *GitIdentityUpdateOne {
|
|
_u.mutation.SetOauthExpiresAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableOauthExpiresAt sets the "oauth_expires_at" field if the given value is not nil.
|
|
func (_u *GitIdentityUpdateOne) SetNillableOauthExpiresAt(v *time.Time) *GitIdentityUpdateOne {
|
|
if v != nil {
|
|
_u.SetOauthExpiresAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearOauthExpiresAt clears the value of the "oauth_expires_at" field.
|
|
func (_u *GitIdentityUpdateOne) ClearOauthExpiresAt() *GitIdentityUpdateOne {
|
|
_u.mutation.ClearOauthExpiresAt()
|
|
return _u
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (_u *GitIdentityUpdateOne) SetCreatedAt(v time.Time) *GitIdentityUpdateOne {
|
|
_u.mutation.SetCreatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (_u *GitIdentityUpdateOne) SetNillableCreatedAt(v *time.Time) *GitIdentityUpdateOne {
|
|
if v != nil {
|
|
_u.SetCreatedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (_u *GitIdentityUpdateOne) SetUpdatedAt(v time.Time) *GitIdentityUpdateOne {
|
|
_u.mutation.SetUpdatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetUser sets the "user" edge to the User entity.
|
|
func (_u *GitIdentityUpdateOne) SetUser(v *User) *GitIdentityUpdateOne {
|
|
return _u.SetUserID(v.ID)
|
|
}
|
|
|
|
// AddProjectIDs adds the "projects" edge to the Project entity by IDs.
|
|
func (_u *GitIdentityUpdateOne) AddProjectIDs(ids ...uuid.UUID) *GitIdentityUpdateOne {
|
|
_u.mutation.AddProjectIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddProjects adds the "projects" edges to the Project entity.
|
|
func (_u *GitIdentityUpdateOne) AddProjects(v ...*Project) *GitIdentityUpdateOne {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddProjectIDs(ids...)
|
|
}
|
|
|
|
// AddProjectTaskIDs adds the "project_tasks" edge to the ProjectTask entity by IDs.
|
|
func (_u *GitIdentityUpdateOne) AddProjectTaskIDs(ids ...uuid.UUID) *GitIdentityUpdateOne {
|
|
_u.mutation.AddProjectTaskIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddProjectTasks adds the "project_tasks" edges to the ProjectTask entity.
|
|
func (_u *GitIdentityUpdateOne) AddProjectTasks(v ...*ProjectTask) *GitIdentityUpdateOne {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddProjectTaskIDs(ids...)
|
|
}
|
|
|
|
// AddVMIDs adds the "vms" edge to the VirtualMachine entity by IDs.
|
|
func (_u *GitIdentityUpdateOne) AddVMIDs(ids ...string) *GitIdentityUpdateOne {
|
|
_u.mutation.AddVMIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddVms adds the "vms" edges to the VirtualMachine entity.
|
|
func (_u *GitIdentityUpdateOne) AddVms(v ...*VirtualMachine) *GitIdentityUpdateOne {
|
|
ids := make([]string, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddVMIDs(ids...)
|
|
}
|
|
|
|
// Mutation returns the GitIdentityMutation object of the builder.
|
|
func (_u *GitIdentityUpdateOne) Mutation() *GitIdentityMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// ClearUser clears the "user" edge to the User entity.
|
|
func (_u *GitIdentityUpdateOne) ClearUser() *GitIdentityUpdateOne {
|
|
_u.mutation.ClearUser()
|
|
return _u
|
|
}
|
|
|
|
// ClearProjects clears all "projects" edges to the Project entity.
|
|
func (_u *GitIdentityUpdateOne) ClearProjects() *GitIdentityUpdateOne {
|
|
_u.mutation.ClearProjects()
|
|
return _u
|
|
}
|
|
|
|
// RemoveProjectIDs removes the "projects" edge to Project entities by IDs.
|
|
func (_u *GitIdentityUpdateOne) RemoveProjectIDs(ids ...uuid.UUID) *GitIdentityUpdateOne {
|
|
_u.mutation.RemoveProjectIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveProjects removes "projects" edges to Project entities.
|
|
func (_u *GitIdentityUpdateOne) RemoveProjects(v ...*Project) *GitIdentityUpdateOne {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveProjectIDs(ids...)
|
|
}
|
|
|
|
// ClearProjectTasks clears all "project_tasks" edges to the ProjectTask entity.
|
|
func (_u *GitIdentityUpdateOne) ClearProjectTasks() *GitIdentityUpdateOne {
|
|
_u.mutation.ClearProjectTasks()
|
|
return _u
|
|
}
|
|
|
|
// RemoveProjectTaskIDs removes the "project_tasks" edge to ProjectTask entities by IDs.
|
|
func (_u *GitIdentityUpdateOne) RemoveProjectTaskIDs(ids ...uuid.UUID) *GitIdentityUpdateOne {
|
|
_u.mutation.RemoveProjectTaskIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveProjectTasks removes "project_tasks" edges to ProjectTask entities.
|
|
func (_u *GitIdentityUpdateOne) RemoveProjectTasks(v ...*ProjectTask) *GitIdentityUpdateOne {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveProjectTaskIDs(ids...)
|
|
}
|
|
|
|
// ClearVms clears all "vms" edges to the VirtualMachine entity.
|
|
func (_u *GitIdentityUpdateOne) ClearVms() *GitIdentityUpdateOne {
|
|
_u.mutation.ClearVms()
|
|
return _u
|
|
}
|
|
|
|
// RemoveVMIDs removes the "vms" edge to VirtualMachine entities by IDs.
|
|
func (_u *GitIdentityUpdateOne) RemoveVMIDs(ids ...string) *GitIdentityUpdateOne {
|
|
_u.mutation.RemoveVMIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveVms removes "vms" edges to VirtualMachine entities.
|
|
func (_u *GitIdentityUpdateOne) RemoveVms(v ...*VirtualMachine) *GitIdentityUpdateOne {
|
|
ids := make([]string, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveVMIDs(ids...)
|
|
}
|
|
|
|
// Where appends a list predicates to the GitIdentityUpdate builder.
|
|
func (_u *GitIdentityUpdateOne) Where(ps ...predicate.GitIdentity) *GitIdentityUpdateOne {
|
|
_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 *GitIdentityUpdateOne) Select(field string, fields ...string) *GitIdentityUpdateOne {
|
|
_u.fields = append([]string{field}, fields...)
|
|
return _u
|
|
}
|
|
|
|
// Save executes the query and returns the updated GitIdentity entity.
|
|
func (_u *GitIdentityUpdateOne) Save(ctx context.Context) (*GitIdentity, error) {
|
|
if err := _u.defaults(); err != nil {
|
|
return nil, err
|
|
}
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *GitIdentityUpdateOne) SaveX(ctx context.Context) *GitIdentity {
|
|
node, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// Exec executes the query on the entity.
|
|
func (_u *GitIdentityUpdateOne) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *GitIdentityUpdateOne) 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 *GitIdentityUpdateOne) defaults() error {
|
|
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
|
if gitidentity.UpdateDefaultUpdatedAt == nil {
|
|
return fmt.Errorf("db: uninitialized gitidentity.UpdateDefaultUpdatedAt (forgotten import db/runtime?)")
|
|
}
|
|
v := gitidentity.UpdateDefaultUpdatedAt()
|
|
_u.mutation.SetUpdatedAt(v)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_u *GitIdentityUpdateOne) check() error {
|
|
if _u.mutation.UserCleared() && len(_u.mutation.UserIDs()) > 0 {
|
|
return errors.New(`db: clearing a required unique edge "GitIdentity.user"`)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
|
func (_u *GitIdentityUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *GitIdentityUpdateOne {
|
|
_u.modifiers = append(_u.modifiers, modifiers...)
|
|
return _u
|
|
}
|
|
|
|
func (_u *GitIdentityUpdateOne) sqlSave(ctx context.Context) (_node *GitIdentity, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(gitidentity.Table, gitidentity.Columns, sqlgraph.NewFieldSpec(gitidentity.FieldID, field.TypeUUID))
|
|
id, ok := _u.mutation.ID()
|
|
if !ok {
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`db: missing "GitIdentity.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, gitidentity.FieldID)
|
|
for _, f := range fields {
|
|
if !gitidentity.ValidColumn(f) {
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)}
|
|
}
|
|
if f != gitidentity.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.DeletedAt(); ok {
|
|
_spec.SetField(gitidentity.FieldDeletedAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.DeletedAtCleared() {
|
|
_spec.ClearField(gitidentity.FieldDeletedAt, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.Platform(); ok {
|
|
_spec.SetField(gitidentity.FieldPlatform, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.BaseURL(); ok {
|
|
_spec.SetField(gitidentity.FieldBaseURL, field.TypeString, value)
|
|
}
|
|
if _u.mutation.BaseURLCleared() {
|
|
_spec.ClearField(gitidentity.FieldBaseURL, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.AccessToken(); ok {
|
|
_spec.SetField(gitidentity.FieldAccessToken, field.TypeString, value)
|
|
}
|
|
if _u.mutation.AccessTokenCleared() {
|
|
_spec.ClearField(gitidentity.FieldAccessToken, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.Username(); ok {
|
|
_spec.SetField(gitidentity.FieldUsername, field.TypeString, value)
|
|
}
|
|
if _u.mutation.UsernameCleared() {
|
|
_spec.ClearField(gitidentity.FieldUsername, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.Email(); ok {
|
|
_spec.SetField(gitidentity.FieldEmail, field.TypeString, value)
|
|
}
|
|
if _u.mutation.EmailCleared() {
|
|
_spec.ClearField(gitidentity.FieldEmail, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.InstallationID(); ok {
|
|
_spec.SetField(gitidentity.FieldInstallationID, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedInstallationID(); ok {
|
|
_spec.AddField(gitidentity.FieldInstallationID, field.TypeInt64, value)
|
|
}
|
|
if _u.mutation.InstallationIDCleared() {
|
|
_spec.ClearField(gitidentity.FieldInstallationID, field.TypeInt64)
|
|
}
|
|
if value, ok := _u.mutation.Remark(); ok {
|
|
_spec.SetField(gitidentity.FieldRemark, field.TypeString, value)
|
|
}
|
|
if _u.mutation.RemarkCleared() {
|
|
_spec.ClearField(gitidentity.FieldRemark, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.OauthRefreshToken(); ok {
|
|
_spec.SetField(gitidentity.FieldOauthRefreshToken, field.TypeString, value)
|
|
}
|
|
if _u.mutation.OauthRefreshTokenCleared() {
|
|
_spec.ClearField(gitidentity.FieldOauthRefreshToken, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.OauthExpiresAt(); ok {
|
|
_spec.SetField(gitidentity.FieldOauthExpiresAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.OauthExpiresAtCleared() {
|
|
_spec.ClearField(gitidentity.FieldOauthExpiresAt, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.CreatedAt(); ok {
|
|
_spec.SetField(gitidentity.FieldCreatedAt, field.TypeTime, value)
|
|
}
|
|
if value, ok := _u.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(gitidentity.FieldUpdatedAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.UserCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: gitidentity.UserTable,
|
|
Columns: []string{gitidentity.UserColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.UserIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: gitidentity.UserTable,
|
|
Columns: []string{gitidentity.UserColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(user.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.ProjectsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: gitidentity.ProjectsTable,
|
|
Columns: []string{gitidentity.ProjectsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(project.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.RemovedProjectsIDs(); len(nodes) > 0 && !_u.mutation.ProjectsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: gitidentity.ProjectsTable,
|
|
Columns: []string{gitidentity.ProjectsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(project.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.ProjectsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: gitidentity.ProjectsTable,
|
|
Columns: []string{gitidentity.ProjectsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(project.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.ProjectTasksCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: gitidentity.ProjectTasksTable,
|
|
Columns: []string{gitidentity.ProjectTasksColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(projecttask.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.RemovedProjectTasksIDs(); len(nodes) > 0 && !_u.mutation.ProjectTasksCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: gitidentity.ProjectTasksTable,
|
|
Columns: []string{gitidentity.ProjectTasksColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(projecttask.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.ProjectTasksIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: gitidentity.ProjectTasksTable,
|
|
Columns: []string{gitidentity.ProjectTasksColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(projecttask.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.VmsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: gitidentity.VmsTable,
|
|
Columns: []string{gitidentity.VmsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(virtualmachine.FieldID, field.TypeString),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.RemovedVmsIDs(); len(nodes) > 0 && !_u.mutation.VmsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: gitidentity.VmsTable,
|
|
Columns: []string{gitidentity.VmsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(virtualmachine.FieldID, field.TypeString),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.VmsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: gitidentity.VmsTable,
|
|
Columns: []string{gitidentity.VmsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(virtualmachine.FieldID, field.TypeString),
|
|
},
|
|
}
|
|
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 = &GitIdentity{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{gitidentity.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|