mirror of
https://github.com/simon-ding/polaris.git
synced 2026-02-06 23:21:00 +08:00
612 lines
19 KiB
Go
612 lines
19 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"polaris/ent/downloadclients"
|
|
"polaris/ent/predicate"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
)
|
|
|
|
// DownloadClientsUpdate is the builder for updating DownloadClients entities.
|
|
type DownloadClientsUpdate struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *DownloadClientsMutation
|
|
}
|
|
|
|
// Where appends a list predicates to the DownloadClientsUpdate builder.
|
|
func (dcu *DownloadClientsUpdate) Where(ps ...predicate.DownloadClients) *DownloadClientsUpdate {
|
|
dcu.mutation.Where(ps...)
|
|
return dcu
|
|
}
|
|
|
|
// SetEnable sets the "enable" field.
|
|
func (dcu *DownloadClientsUpdate) SetEnable(b bool) *DownloadClientsUpdate {
|
|
dcu.mutation.SetEnable(b)
|
|
return dcu
|
|
}
|
|
|
|
// SetNillableEnable sets the "enable" field if the given value is not nil.
|
|
func (dcu *DownloadClientsUpdate) SetNillableEnable(b *bool) *DownloadClientsUpdate {
|
|
if b != nil {
|
|
dcu.SetEnable(*b)
|
|
}
|
|
return dcu
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (dcu *DownloadClientsUpdate) SetName(s string) *DownloadClientsUpdate {
|
|
dcu.mutation.SetName(s)
|
|
return dcu
|
|
}
|
|
|
|
// SetNillableName sets the "name" field if the given value is not nil.
|
|
func (dcu *DownloadClientsUpdate) SetNillableName(s *string) *DownloadClientsUpdate {
|
|
if s != nil {
|
|
dcu.SetName(*s)
|
|
}
|
|
return dcu
|
|
}
|
|
|
|
// SetImplementation sets the "implementation" field.
|
|
func (dcu *DownloadClientsUpdate) SetImplementation(d downloadclients.Implementation) *DownloadClientsUpdate {
|
|
dcu.mutation.SetImplementation(d)
|
|
return dcu
|
|
}
|
|
|
|
// SetNillableImplementation sets the "implementation" field if the given value is not nil.
|
|
func (dcu *DownloadClientsUpdate) SetNillableImplementation(d *downloadclients.Implementation) *DownloadClientsUpdate {
|
|
if d != nil {
|
|
dcu.SetImplementation(*d)
|
|
}
|
|
return dcu
|
|
}
|
|
|
|
// SetURL sets the "url" field.
|
|
func (dcu *DownloadClientsUpdate) SetURL(s string) *DownloadClientsUpdate {
|
|
dcu.mutation.SetURL(s)
|
|
return dcu
|
|
}
|
|
|
|
// SetNillableURL sets the "url" field if the given value is not nil.
|
|
func (dcu *DownloadClientsUpdate) SetNillableURL(s *string) *DownloadClientsUpdate {
|
|
if s != nil {
|
|
dcu.SetURL(*s)
|
|
}
|
|
return dcu
|
|
}
|
|
|
|
// SetUser sets the "user" field.
|
|
func (dcu *DownloadClientsUpdate) SetUser(s string) *DownloadClientsUpdate {
|
|
dcu.mutation.SetUser(s)
|
|
return dcu
|
|
}
|
|
|
|
// SetNillableUser sets the "user" field if the given value is not nil.
|
|
func (dcu *DownloadClientsUpdate) SetNillableUser(s *string) *DownloadClientsUpdate {
|
|
if s != nil {
|
|
dcu.SetUser(*s)
|
|
}
|
|
return dcu
|
|
}
|
|
|
|
// SetPassword sets the "password" field.
|
|
func (dcu *DownloadClientsUpdate) SetPassword(s string) *DownloadClientsUpdate {
|
|
dcu.mutation.SetPassword(s)
|
|
return dcu
|
|
}
|
|
|
|
// SetNillablePassword sets the "password" field if the given value is not nil.
|
|
func (dcu *DownloadClientsUpdate) SetNillablePassword(s *string) *DownloadClientsUpdate {
|
|
if s != nil {
|
|
dcu.SetPassword(*s)
|
|
}
|
|
return dcu
|
|
}
|
|
|
|
// SetSettings sets the "settings" field.
|
|
func (dcu *DownloadClientsUpdate) SetSettings(s string) *DownloadClientsUpdate {
|
|
dcu.mutation.SetSettings(s)
|
|
return dcu
|
|
}
|
|
|
|
// SetNillableSettings sets the "settings" field if the given value is not nil.
|
|
func (dcu *DownloadClientsUpdate) SetNillableSettings(s *string) *DownloadClientsUpdate {
|
|
if s != nil {
|
|
dcu.SetSettings(*s)
|
|
}
|
|
return dcu
|
|
}
|
|
|
|
// SetPriority1 sets the "priority1" field.
|
|
func (dcu *DownloadClientsUpdate) SetPriority1(i int) *DownloadClientsUpdate {
|
|
dcu.mutation.ResetPriority1()
|
|
dcu.mutation.SetPriority1(i)
|
|
return dcu
|
|
}
|
|
|
|
// SetNillablePriority1 sets the "priority1" field if the given value is not nil.
|
|
func (dcu *DownloadClientsUpdate) SetNillablePriority1(i *int) *DownloadClientsUpdate {
|
|
if i != nil {
|
|
dcu.SetPriority1(*i)
|
|
}
|
|
return dcu
|
|
}
|
|
|
|
// AddPriority1 adds i to the "priority1" field.
|
|
func (dcu *DownloadClientsUpdate) AddPriority1(i int) *DownloadClientsUpdate {
|
|
dcu.mutation.AddPriority1(i)
|
|
return dcu
|
|
}
|
|
|
|
// SetRemoveCompletedDownloads sets the "remove_completed_downloads" field.
|
|
func (dcu *DownloadClientsUpdate) SetRemoveCompletedDownloads(b bool) *DownloadClientsUpdate {
|
|
dcu.mutation.SetRemoveCompletedDownloads(b)
|
|
return dcu
|
|
}
|
|
|
|
// SetNillableRemoveCompletedDownloads sets the "remove_completed_downloads" field if the given value is not nil.
|
|
func (dcu *DownloadClientsUpdate) SetNillableRemoveCompletedDownloads(b *bool) *DownloadClientsUpdate {
|
|
if b != nil {
|
|
dcu.SetRemoveCompletedDownloads(*b)
|
|
}
|
|
return dcu
|
|
}
|
|
|
|
// SetRemoveFailedDownloads sets the "remove_failed_downloads" field.
|
|
func (dcu *DownloadClientsUpdate) SetRemoveFailedDownloads(b bool) *DownloadClientsUpdate {
|
|
dcu.mutation.SetRemoveFailedDownloads(b)
|
|
return dcu
|
|
}
|
|
|
|
// SetNillableRemoveFailedDownloads sets the "remove_failed_downloads" field if the given value is not nil.
|
|
func (dcu *DownloadClientsUpdate) SetNillableRemoveFailedDownloads(b *bool) *DownloadClientsUpdate {
|
|
if b != nil {
|
|
dcu.SetRemoveFailedDownloads(*b)
|
|
}
|
|
return dcu
|
|
}
|
|
|
|
// SetTags sets the "tags" field.
|
|
func (dcu *DownloadClientsUpdate) SetTags(s string) *DownloadClientsUpdate {
|
|
dcu.mutation.SetTags(s)
|
|
return dcu
|
|
}
|
|
|
|
// SetNillableTags sets the "tags" field if the given value is not nil.
|
|
func (dcu *DownloadClientsUpdate) SetNillableTags(s *string) *DownloadClientsUpdate {
|
|
if s != nil {
|
|
dcu.SetTags(*s)
|
|
}
|
|
return dcu
|
|
}
|
|
|
|
// Mutation returns the DownloadClientsMutation object of the builder.
|
|
func (dcu *DownloadClientsUpdate) Mutation() *DownloadClientsMutation {
|
|
return dcu.mutation
|
|
}
|
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
func (dcu *DownloadClientsUpdate) Save(ctx context.Context) (int, error) {
|
|
return withHooks(ctx, dcu.sqlSave, dcu.mutation, dcu.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (dcu *DownloadClientsUpdate) SaveX(ctx context.Context) int {
|
|
affected, err := dcu.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return affected
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (dcu *DownloadClientsUpdate) Exec(ctx context.Context) error {
|
|
_, err := dcu.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (dcu *DownloadClientsUpdate) ExecX(ctx context.Context) {
|
|
if err := dcu.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (dcu *DownloadClientsUpdate) check() error {
|
|
if v, ok := dcu.mutation.Implementation(); ok {
|
|
if err := downloadclients.ImplementationValidator(v); err != nil {
|
|
return &ValidationError{Name: "implementation", err: fmt.Errorf(`ent: validator failed for field "DownloadClients.implementation": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := dcu.mutation.Priority1(); ok {
|
|
if err := downloadclients.Priority1Validator(v); err != nil {
|
|
return &ValidationError{Name: "priority1", err: fmt.Errorf(`ent: validator failed for field "DownloadClients.priority1": %w`, err)}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (dcu *DownloadClientsUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
|
if err := dcu.check(); err != nil {
|
|
return n, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(downloadclients.Table, downloadclients.Columns, sqlgraph.NewFieldSpec(downloadclients.FieldID, field.TypeInt))
|
|
if ps := dcu.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := dcu.mutation.Enable(); ok {
|
|
_spec.SetField(downloadclients.FieldEnable, field.TypeBool, value)
|
|
}
|
|
if value, ok := dcu.mutation.Name(); ok {
|
|
_spec.SetField(downloadclients.FieldName, field.TypeString, value)
|
|
}
|
|
if value, ok := dcu.mutation.Implementation(); ok {
|
|
_spec.SetField(downloadclients.FieldImplementation, field.TypeEnum, value)
|
|
}
|
|
if value, ok := dcu.mutation.URL(); ok {
|
|
_spec.SetField(downloadclients.FieldURL, field.TypeString, value)
|
|
}
|
|
if value, ok := dcu.mutation.User(); ok {
|
|
_spec.SetField(downloadclients.FieldUser, field.TypeString, value)
|
|
}
|
|
if value, ok := dcu.mutation.Password(); ok {
|
|
_spec.SetField(downloadclients.FieldPassword, field.TypeString, value)
|
|
}
|
|
if value, ok := dcu.mutation.Settings(); ok {
|
|
_spec.SetField(downloadclients.FieldSettings, field.TypeString, value)
|
|
}
|
|
if value, ok := dcu.mutation.Priority1(); ok {
|
|
_spec.SetField(downloadclients.FieldPriority1, field.TypeInt, value)
|
|
}
|
|
if value, ok := dcu.mutation.AddedPriority1(); ok {
|
|
_spec.AddField(downloadclients.FieldPriority1, field.TypeInt, value)
|
|
}
|
|
if value, ok := dcu.mutation.RemoveCompletedDownloads(); ok {
|
|
_spec.SetField(downloadclients.FieldRemoveCompletedDownloads, field.TypeBool, value)
|
|
}
|
|
if value, ok := dcu.mutation.RemoveFailedDownloads(); ok {
|
|
_spec.SetField(downloadclients.FieldRemoveFailedDownloads, field.TypeBool, value)
|
|
}
|
|
if value, ok := dcu.mutation.Tags(); ok {
|
|
_spec.SetField(downloadclients.FieldTags, field.TypeString, value)
|
|
}
|
|
if dcu.mutation.CreateTimeCleared() {
|
|
_spec.ClearField(downloadclients.FieldCreateTime, field.TypeTime)
|
|
}
|
|
if n, err = sqlgraph.UpdateNodes(ctx, dcu.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{downloadclients.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return 0, err
|
|
}
|
|
dcu.mutation.done = true
|
|
return n, nil
|
|
}
|
|
|
|
// DownloadClientsUpdateOne is the builder for updating a single DownloadClients entity.
|
|
type DownloadClientsUpdateOne struct {
|
|
config
|
|
fields []string
|
|
hooks []Hook
|
|
mutation *DownloadClientsMutation
|
|
}
|
|
|
|
// SetEnable sets the "enable" field.
|
|
func (dcuo *DownloadClientsUpdateOne) SetEnable(b bool) *DownloadClientsUpdateOne {
|
|
dcuo.mutation.SetEnable(b)
|
|
return dcuo
|
|
}
|
|
|
|
// SetNillableEnable sets the "enable" field if the given value is not nil.
|
|
func (dcuo *DownloadClientsUpdateOne) SetNillableEnable(b *bool) *DownloadClientsUpdateOne {
|
|
if b != nil {
|
|
dcuo.SetEnable(*b)
|
|
}
|
|
return dcuo
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (dcuo *DownloadClientsUpdateOne) SetName(s string) *DownloadClientsUpdateOne {
|
|
dcuo.mutation.SetName(s)
|
|
return dcuo
|
|
}
|
|
|
|
// SetNillableName sets the "name" field if the given value is not nil.
|
|
func (dcuo *DownloadClientsUpdateOne) SetNillableName(s *string) *DownloadClientsUpdateOne {
|
|
if s != nil {
|
|
dcuo.SetName(*s)
|
|
}
|
|
return dcuo
|
|
}
|
|
|
|
// SetImplementation sets the "implementation" field.
|
|
func (dcuo *DownloadClientsUpdateOne) SetImplementation(d downloadclients.Implementation) *DownloadClientsUpdateOne {
|
|
dcuo.mutation.SetImplementation(d)
|
|
return dcuo
|
|
}
|
|
|
|
// SetNillableImplementation sets the "implementation" field if the given value is not nil.
|
|
func (dcuo *DownloadClientsUpdateOne) SetNillableImplementation(d *downloadclients.Implementation) *DownloadClientsUpdateOne {
|
|
if d != nil {
|
|
dcuo.SetImplementation(*d)
|
|
}
|
|
return dcuo
|
|
}
|
|
|
|
// SetURL sets the "url" field.
|
|
func (dcuo *DownloadClientsUpdateOne) SetURL(s string) *DownloadClientsUpdateOne {
|
|
dcuo.mutation.SetURL(s)
|
|
return dcuo
|
|
}
|
|
|
|
// SetNillableURL sets the "url" field if the given value is not nil.
|
|
func (dcuo *DownloadClientsUpdateOne) SetNillableURL(s *string) *DownloadClientsUpdateOne {
|
|
if s != nil {
|
|
dcuo.SetURL(*s)
|
|
}
|
|
return dcuo
|
|
}
|
|
|
|
// SetUser sets the "user" field.
|
|
func (dcuo *DownloadClientsUpdateOne) SetUser(s string) *DownloadClientsUpdateOne {
|
|
dcuo.mutation.SetUser(s)
|
|
return dcuo
|
|
}
|
|
|
|
// SetNillableUser sets the "user" field if the given value is not nil.
|
|
func (dcuo *DownloadClientsUpdateOne) SetNillableUser(s *string) *DownloadClientsUpdateOne {
|
|
if s != nil {
|
|
dcuo.SetUser(*s)
|
|
}
|
|
return dcuo
|
|
}
|
|
|
|
// SetPassword sets the "password" field.
|
|
func (dcuo *DownloadClientsUpdateOne) SetPassword(s string) *DownloadClientsUpdateOne {
|
|
dcuo.mutation.SetPassword(s)
|
|
return dcuo
|
|
}
|
|
|
|
// SetNillablePassword sets the "password" field if the given value is not nil.
|
|
func (dcuo *DownloadClientsUpdateOne) SetNillablePassword(s *string) *DownloadClientsUpdateOne {
|
|
if s != nil {
|
|
dcuo.SetPassword(*s)
|
|
}
|
|
return dcuo
|
|
}
|
|
|
|
// SetSettings sets the "settings" field.
|
|
func (dcuo *DownloadClientsUpdateOne) SetSettings(s string) *DownloadClientsUpdateOne {
|
|
dcuo.mutation.SetSettings(s)
|
|
return dcuo
|
|
}
|
|
|
|
// SetNillableSettings sets the "settings" field if the given value is not nil.
|
|
func (dcuo *DownloadClientsUpdateOne) SetNillableSettings(s *string) *DownloadClientsUpdateOne {
|
|
if s != nil {
|
|
dcuo.SetSettings(*s)
|
|
}
|
|
return dcuo
|
|
}
|
|
|
|
// SetPriority1 sets the "priority1" field.
|
|
func (dcuo *DownloadClientsUpdateOne) SetPriority1(i int) *DownloadClientsUpdateOne {
|
|
dcuo.mutation.ResetPriority1()
|
|
dcuo.mutation.SetPriority1(i)
|
|
return dcuo
|
|
}
|
|
|
|
// SetNillablePriority1 sets the "priority1" field if the given value is not nil.
|
|
func (dcuo *DownloadClientsUpdateOne) SetNillablePriority1(i *int) *DownloadClientsUpdateOne {
|
|
if i != nil {
|
|
dcuo.SetPriority1(*i)
|
|
}
|
|
return dcuo
|
|
}
|
|
|
|
// AddPriority1 adds i to the "priority1" field.
|
|
func (dcuo *DownloadClientsUpdateOne) AddPriority1(i int) *DownloadClientsUpdateOne {
|
|
dcuo.mutation.AddPriority1(i)
|
|
return dcuo
|
|
}
|
|
|
|
// SetRemoveCompletedDownloads sets the "remove_completed_downloads" field.
|
|
func (dcuo *DownloadClientsUpdateOne) SetRemoveCompletedDownloads(b bool) *DownloadClientsUpdateOne {
|
|
dcuo.mutation.SetRemoveCompletedDownloads(b)
|
|
return dcuo
|
|
}
|
|
|
|
// SetNillableRemoveCompletedDownloads sets the "remove_completed_downloads" field if the given value is not nil.
|
|
func (dcuo *DownloadClientsUpdateOne) SetNillableRemoveCompletedDownloads(b *bool) *DownloadClientsUpdateOne {
|
|
if b != nil {
|
|
dcuo.SetRemoveCompletedDownloads(*b)
|
|
}
|
|
return dcuo
|
|
}
|
|
|
|
// SetRemoveFailedDownloads sets the "remove_failed_downloads" field.
|
|
func (dcuo *DownloadClientsUpdateOne) SetRemoveFailedDownloads(b bool) *DownloadClientsUpdateOne {
|
|
dcuo.mutation.SetRemoveFailedDownloads(b)
|
|
return dcuo
|
|
}
|
|
|
|
// SetNillableRemoveFailedDownloads sets the "remove_failed_downloads" field if the given value is not nil.
|
|
func (dcuo *DownloadClientsUpdateOne) SetNillableRemoveFailedDownloads(b *bool) *DownloadClientsUpdateOne {
|
|
if b != nil {
|
|
dcuo.SetRemoveFailedDownloads(*b)
|
|
}
|
|
return dcuo
|
|
}
|
|
|
|
// SetTags sets the "tags" field.
|
|
func (dcuo *DownloadClientsUpdateOne) SetTags(s string) *DownloadClientsUpdateOne {
|
|
dcuo.mutation.SetTags(s)
|
|
return dcuo
|
|
}
|
|
|
|
// SetNillableTags sets the "tags" field if the given value is not nil.
|
|
func (dcuo *DownloadClientsUpdateOne) SetNillableTags(s *string) *DownloadClientsUpdateOne {
|
|
if s != nil {
|
|
dcuo.SetTags(*s)
|
|
}
|
|
return dcuo
|
|
}
|
|
|
|
// Mutation returns the DownloadClientsMutation object of the builder.
|
|
func (dcuo *DownloadClientsUpdateOne) Mutation() *DownloadClientsMutation {
|
|
return dcuo.mutation
|
|
}
|
|
|
|
// Where appends a list predicates to the DownloadClientsUpdate builder.
|
|
func (dcuo *DownloadClientsUpdateOne) Where(ps ...predicate.DownloadClients) *DownloadClientsUpdateOne {
|
|
dcuo.mutation.Where(ps...)
|
|
return dcuo
|
|
}
|
|
|
|
// Select allows selecting one or more fields (columns) of the returned entity.
|
|
// The default is selecting all fields defined in the entity schema.
|
|
func (dcuo *DownloadClientsUpdateOne) Select(field string, fields ...string) *DownloadClientsUpdateOne {
|
|
dcuo.fields = append([]string{field}, fields...)
|
|
return dcuo
|
|
}
|
|
|
|
// Save executes the query and returns the updated DownloadClients entity.
|
|
func (dcuo *DownloadClientsUpdateOne) Save(ctx context.Context) (*DownloadClients, error) {
|
|
return withHooks(ctx, dcuo.sqlSave, dcuo.mutation, dcuo.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (dcuo *DownloadClientsUpdateOne) SaveX(ctx context.Context) *DownloadClients {
|
|
node, err := dcuo.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// Exec executes the query on the entity.
|
|
func (dcuo *DownloadClientsUpdateOne) Exec(ctx context.Context) error {
|
|
_, err := dcuo.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (dcuo *DownloadClientsUpdateOne) ExecX(ctx context.Context) {
|
|
if err := dcuo.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (dcuo *DownloadClientsUpdateOne) check() error {
|
|
if v, ok := dcuo.mutation.Implementation(); ok {
|
|
if err := downloadclients.ImplementationValidator(v); err != nil {
|
|
return &ValidationError{Name: "implementation", err: fmt.Errorf(`ent: validator failed for field "DownloadClients.implementation": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := dcuo.mutation.Priority1(); ok {
|
|
if err := downloadclients.Priority1Validator(v); err != nil {
|
|
return &ValidationError{Name: "priority1", err: fmt.Errorf(`ent: validator failed for field "DownloadClients.priority1": %w`, err)}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (dcuo *DownloadClientsUpdateOne) sqlSave(ctx context.Context) (_node *DownloadClients, err error) {
|
|
if err := dcuo.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(downloadclients.Table, downloadclients.Columns, sqlgraph.NewFieldSpec(downloadclients.FieldID, field.TypeInt))
|
|
id, ok := dcuo.mutation.ID()
|
|
if !ok {
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "DownloadClients.id" for update`)}
|
|
}
|
|
_spec.Node.ID.Value = id
|
|
if fields := dcuo.fields; len(fields) > 0 {
|
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
|
_spec.Node.Columns = append(_spec.Node.Columns, downloadclients.FieldID)
|
|
for _, f := range fields {
|
|
if !downloadclients.ValidColumn(f) {
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
|
}
|
|
if f != downloadclients.FieldID {
|
|
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
|
}
|
|
}
|
|
}
|
|
if ps := dcuo.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := dcuo.mutation.Enable(); ok {
|
|
_spec.SetField(downloadclients.FieldEnable, field.TypeBool, value)
|
|
}
|
|
if value, ok := dcuo.mutation.Name(); ok {
|
|
_spec.SetField(downloadclients.FieldName, field.TypeString, value)
|
|
}
|
|
if value, ok := dcuo.mutation.Implementation(); ok {
|
|
_spec.SetField(downloadclients.FieldImplementation, field.TypeEnum, value)
|
|
}
|
|
if value, ok := dcuo.mutation.URL(); ok {
|
|
_spec.SetField(downloadclients.FieldURL, field.TypeString, value)
|
|
}
|
|
if value, ok := dcuo.mutation.User(); ok {
|
|
_spec.SetField(downloadclients.FieldUser, field.TypeString, value)
|
|
}
|
|
if value, ok := dcuo.mutation.Password(); ok {
|
|
_spec.SetField(downloadclients.FieldPassword, field.TypeString, value)
|
|
}
|
|
if value, ok := dcuo.mutation.Settings(); ok {
|
|
_spec.SetField(downloadclients.FieldSettings, field.TypeString, value)
|
|
}
|
|
if value, ok := dcuo.mutation.Priority1(); ok {
|
|
_spec.SetField(downloadclients.FieldPriority1, field.TypeInt, value)
|
|
}
|
|
if value, ok := dcuo.mutation.AddedPriority1(); ok {
|
|
_spec.AddField(downloadclients.FieldPriority1, field.TypeInt, value)
|
|
}
|
|
if value, ok := dcuo.mutation.RemoveCompletedDownloads(); ok {
|
|
_spec.SetField(downloadclients.FieldRemoveCompletedDownloads, field.TypeBool, value)
|
|
}
|
|
if value, ok := dcuo.mutation.RemoveFailedDownloads(); ok {
|
|
_spec.SetField(downloadclients.FieldRemoveFailedDownloads, field.TypeBool, value)
|
|
}
|
|
if value, ok := dcuo.mutation.Tags(); ok {
|
|
_spec.SetField(downloadclients.FieldTags, field.TypeString, value)
|
|
}
|
|
if dcuo.mutation.CreateTimeCleared() {
|
|
_spec.ClearField(downloadclients.FieldCreateTime, field.TypeTime)
|
|
}
|
|
_node = &DownloadClients{config: dcuo.config}
|
|
_spec.Assign = _node.assignValues
|
|
_spec.ScanValues = _node.scanValues
|
|
if err = sqlgraph.UpdateNode(ctx, dcuo.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{downloadclients.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
dcuo.mutation.done = true
|
|
return _node, nil
|
|
}
|