2021-01-01 20:34:47 +00:00
|
|
|
// Code generated by entc, DO NOT EDIT.
|
|
|
|
|
|
|
|
package db
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2022-03-07 09:15:01 +00:00
|
|
|
"errors"
|
2021-01-01 20:34:47 +00:00
|
|
|
"fmt"
|
|
|
|
"time"
|
|
|
|
|
2021-03-24 06:37:51 +00:00
|
|
|
"entgo.io/ent/dialect/sql"
|
|
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
|
|
"entgo.io/ent/schema/field"
|
2021-01-01 20:34:47 +00:00
|
|
|
"github.com/dexidp/dex/storage/ent/db/devicerequest"
|
|
|
|
"github.com/dexidp/dex/storage/ent/db/predicate"
|
|
|
|
)
|
|
|
|
|
|
|
|
// DeviceRequestUpdate is the builder for updating DeviceRequest entities.
|
|
|
|
type DeviceRequestUpdate struct {
|
|
|
|
config
|
|
|
|
hooks []Hook
|
|
|
|
mutation *DeviceRequestMutation
|
|
|
|
}
|
|
|
|
|
2021-09-13 13:48:02 +00:00
|
|
|
// Where appends a list predicates to the DeviceRequestUpdate builder.
|
2021-01-01 20:34:47 +00:00
|
|
|
func (dru *DeviceRequestUpdate) Where(ps ...predicate.DeviceRequest) *DeviceRequestUpdate {
|
2021-09-13 13:48:02 +00:00
|
|
|
dru.mutation.Where(ps...)
|
2021-01-01 20:34:47 +00:00
|
|
|
return dru
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetUserCode sets the "user_code" field.
|
|
|
|
func (dru *DeviceRequestUpdate) SetUserCode(s string) *DeviceRequestUpdate {
|
|
|
|
dru.mutation.SetUserCode(s)
|
|
|
|
return dru
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetDeviceCode sets the "device_code" field.
|
|
|
|
func (dru *DeviceRequestUpdate) SetDeviceCode(s string) *DeviceRequestUpdate {
|
|
|
|
dru.mutation.SetDeviceCode(s)
|
|
|
|
return dru
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetClientID sets the "client_id" field.
|
|
|
|
func (dru *DeviceRequestUpdate) SetClientID(s string) *DeviceRequestUpdate {
|
|
|
|
dru.mutation.SetClientID(s)
|
|
|
|
return dru
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetClientSecret sets the "client_secret" field.
|
|
|
|
func (dru *DeviceRequestUpdate) SetClientSecret(s string) *DeviceRequestUpdate {
|
|
|
|
dru.mutation.SetClientSecret(s)
|
|
|
|
return dru
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetScopes sets the "scopes" field.
|
|
|
|
func (dru *DeviceRequestUpdate) SetScopes(s []string) *DeviceRequestUpdate {
|
|
|
|
dru.mutation.SetScopes(s)
|
|
|
|
return dru
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClearScopes clears the value of the "scopes" field.
|
|
|
|
func (dru *DeviceRequestUpdate) ClearScopes() *DeviceRequestUpdate {
|
|
|
|
dru.mutation.ClearScopes()
|
|
|
|
return dru
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetExpiry sets the "expiry" field.
|
|
|
|
func (dru *DeviceRequestUpdate) SetExpiry(t time.Time) *DeviceRequestUpdate {
|
|
|
|
dru.mutation.SetExpiry(t)
|
|
|
|
return dru
|
|
|
|
}
|
|
|
|
|
|
|
|
// Mutation returns the DeviceRequestMutation object of the builder.
|
|
|
|
func (dru *DeviceRequestUpdate) Mutation() *DeviceRequestMutation {
|
|
|
|
return dru.mutation
|
|
|
|
}
|
|
|
|
|
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
|
|
func (dru *DeviceRequestUpdate) Save(ctx context.Context) (int, error) {
|
|
|
|
var (
|
|
|
|
err error
|
|
|
|
affected int
|
|
|
|
)
|
|
|
|
if len(dru.hooks) == 0 {
|
|
|
|
if err = dru.check(); err != nil {
|
|
|
|
return 0, err
|
|
|
|
}
|
|
|
|
affected, err = dru.sqlSave(ctx)
|
|
|
|
} else {
|
|
|
|
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
|
|
|
mutation, ok := m.(*DeviceRequestMutation)
|
|
|
|
if !ok {
|
|
|
|
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
|
|
|
}
|
|
|
|
if err = dru.check(); err != nil {
|
|
|
|
return 0, err
|
|
|
|
}
|
|
|
|
dru.mutation = mutation
|
|
|
|
affected, err = dru.sqlSave(ctx)
|
|
|
|
mutation.done = true
|
|
|
|
return affected, err
|
|
|
|
})
|
|
|
|
for i := len(dru.hooks) - 1; i >= 0; i-- {
|
2021-09-13 13:48:02 +00:00
|
|
|
if dru.hooks[i] == nil {
|
|
|
|
return 0, fmt.Errorf("db: uninitialized hook (forgotten import db/runtime?)")
|
|
|
|
}
|
2021-01-01 20:34:47 +00:00
|
|
|
mut = dru.hooks[i](mut)
|
|
|
|
}
|
|
|
|
if _, err := mut.Mutate(ctx, dru.mutation); err != nil {
|
|
|
|
return 0, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return affected, err
|
|
|
|
}
|
|
|
|
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
|
|
func (dru *DeviceRequestUpdate) SaveX(ctx context.Context) int {
|
|
|
|
affected, err := dru.Save(ctx)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return affected
|
|
|
|
}
|
|
|
|
|
|
|
|
// Exec executes the query.
|
|
|
|
func (dru *DeviceRequestUpdate) Exec(ctx context.Context) error {
|
|
|
|
_, err := dru.Save(ctx)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
|
|
func (dru *DeviceRequestUpdate) ExecX(ctx context.Context) {
|
|
|
|
if err := dru.Exec(ctx); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
|
|
func (dru *DeviceRequestUpdate) check() error {
|
|
|
|
if v, ok := dru.mutation.UserCode(); ok {
|
|
|
|
if err := devicerequest.UserCodeValidator(v); err != nil {
|
2022-03-07 09:15:01 +00:00
|
|
|
return &ValidationError{Name: "user_code", err: fmt.Errorf(`db: validator failed for field "DeviceRequest.user_code": %w`, err)}
|
2021-01-01 20:34:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if v, ok := dru.mutation.DeviceCode(); ok {
|
|
|
|
if err := devicerequest.DeviceCodeValidator(v); err != nil {
|
2022-03-07 09:15:01 +00:00
|
|
|
return &ValidationError{Name: "device_code", err: fmt.Errorf(`db: validator failed for field "DeviceRequest.device_code": %w`, err)}
|
2021-01-01 20:34:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if v, ok := dru.mutation.ClientID(); ok {
|
|
|
|
if err := devicerequest.ClientIDValidator(v); err != nil {
|
2022-03-07 09:15:01 +00:00
|
|
|
return &ValidationError{Name: "client_id", err: fmt.Errorf(`db: validator failed for field "DeviceRequest.client_id": %w`, err)}
|
2021-01-01 20:34:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if v, ok := dru.mutation.ClientSecret(); ok {
|
|
|
|
if err := devicerequest.ClientSecretValidator(v); err != nil {
|
2022-03-07 09:15:01 +00:00
|
|
|
return &ValidationError{Name: "client_secret", err: fmt.Errorf(`db: validator failed for field "DeviceRequest.client_secret": %w`, err)}
|
2021-01-01 20:34:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (dru *DeviceRequestUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
|
|
|
_spec := &sqlgraph.UpdateSpec{
|
|
|
|
Node: &sqlgraph.NodeSpec{
|
|
|
|
Table: devicerequest.Table,
|
|
|
|
Columns: devicerequest.Columns,
|
|
|
|
ID: &sqlgraph.FieldSpec{
|
|
|
|
Type: field.TypeInt,
|
|
|
|
Column: devicerequest.FieldID,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
if ps := dru.mutation.predicates; len(ps) > 0 {
|
|
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
|
|
for i := range ps {
|
|
|
|
ps[i](selector)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if value, ok := dru.mutation.UserCode(); ok {
|
|
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
|
|
Type: field.TypeString,
|
|
|
|
Value: value,
|
|
|
|
Column: devicerequest.FieldUserCode,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
if value, ok := dru.mutation.DeviceCode(); ok {
|
|
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
|
|
Type: field.TypeString,
|
|
|
|
Value: value,
|
|
|
|
Column: devicerequest.FieldDeviceCode,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
if value, ok := dru.mutation.ClientID(); ok {
|
|
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
|
|
Type: field.TypeString,
|
|
|
|
Value: value,
|
|
|
|
Column: devicerequest.FieldClientID,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
if value, ok := dru.mutation.ClientSecret(); ok {
|
|
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
|
|
Type: field.TypeString,
|
|
|
|
Value: value,
|
|
|
|
Column: devicerequest.FieldClientSecret,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
if value, ok := dru.mutation.Scopes(); ok {
|
|
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
|
|
Type: field.TypeJSON,
|
|
|
|
Value: value,
|
|
|
|
Column: devicerequest.FieldScopes,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
if dru.mutation.ScopesCleared() {
|
|
|
|
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
|
|
|
Type: field.TypeJSON,
|
|
|
|
Column: devicerequest.FieldScopes,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
if value, ok := dru.mutation.Expiry(); ok {
|
|
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
|
|
Type: field.TypeTime,
|
|
|
|
Value: value,
|
|
|
|
Column: devicerequest.FieldExpiry,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
if n, err = sqlgraph.UpdateNodes(ctx, dru.driver, _spec); err != nil {
|
|
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
|
|
err = &NotFoundError{devicerequest.Label}
|
2021-09-13 13:48:02 +00:00
|
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
|
|
err = &ConstraintError{err.Error(), err}
|
2021-01-01 20:34:47 +00:00
|
|
|
}
|
|
|
|
return 0, err
|
|
|
|
}
|
|
|
|
return n, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeviceRequestUpdateOne is the builder for updating a single DeviceRequest entity.
|
|
|
|
type DeviceRequestUpdateOne struct {
|
|
|
|
config
|
2021-04-30 14:31:49 +00:00
|
|
|
fields []string
|
2021-01-01 20:34:47 +00:00
|
|
|
hooks []Hook
|
|
|
|
mutation *DeviceRequestMutation
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetUserCode sets the "user_code" field.
|
|
|
|
func (druo *DeviceRequestUpdateOne) SetUserCode(s string) *DeviceRequestUpdateOne {
|
|
|
|
druo.mutation.SetUserCode(s)
|
|
|
|
return druo
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetDeviceCode sets the "device_code" field.
|
|
|
|
func (druo *DeviceRequestUpdateOne) SetDeviceCode(s string) *DeviceRequestUpdateOne {
|
|
|
|
druo.mutation.SetDeviceCode(s)
|
|
|
|
return druo
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetClientID sets the "client_id" field.
|
|
|
|
func (druo *DeviceRequestUpdateOne) SetClientID(s string) *DeviceRequestUpdateOne {
|
|
|
|
druo.mutation.SetClientID(s)
|
|
|
|
return druo
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetClientSecret sets the "client_secret" field.
|
|
|
|
func (druo *DeviceRequestUpdateOne) SetClientSecret(s string) *DeviceRequestUpdateOne {
|
|
|
|
druo.mutation.SetClientSecret(s)
|
|
|
|
return druo
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetScopes sets the "scopes" field.
|
|
|
|
func (druo *DeviceRequestUpdateOne) SetScopes(s []string) *DeviceRequestUpdateOne {
|
|
|
|
druo.mutation.SetScopes(s)
|
|
|
|
return druo
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClearScopes clears the value of the "scopes" field.
|
|
|
|
func (druo *DeviceRequestUpdateOne) ClearScopes() *DeviceRequestUpdateOne {
|
|
|
|
druo.mutation.ClearScopes()
|
|
|
|
return druo
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetExpiry sets the "expiry" field.
|
|
|
|
func (druo *DeviceRequestUpdateOne) SetExpiry(t time.Time) *DeviceRequestUpdateOne {
|
|
|
|
druo.mutation.SetExpiry(t)
|
|
|
|
return druo
|
|
|
|
}
|
|
|
|
|
|
|
|
// Mutation returns the DeviceRequestMutation object of the builder.
|
|
|
|
func (druo *DeviceRequestUpdateOne) Mutation() *DeviceRequestMutation {
|
|
|
|
return druo.mutation
|
|
|
|
}
|
|
|
|
|
2021-04-30 14:31:49 +00:00
|
|
|
// Select allows selecting one or more fields (columns) of the returned entity.
|
|
|
|
// The default is selecting all fields defined in the entity schema.
|
|
|
|
func (druo *DeviceRequestUpdateOne) Select(field string, fields ...string) *DeviceRequestUpdateOne {
|
|
|
|
druo.fields = append([]string{field}, fields...)
|
|
|
|
return druo
|
|
|
|
}
|
|
|
|
|
2021-01-01 20:34:47 +00:00
|
|
|
// Save executes the query and returns the updated DeviceRequest entity.
|
|
|
|
func (druo *DeviceRequestUpdateOne) Save(ctx context.Context) (*DeviceRequest, error) {
|
|
|
|
var (
|
|
|
|
err error
|
|
|
|
node *DeviceRequest
|
|
|
|
)
|
|
|
|
if len(druo.hooks) == 0 {
|
|
|
|
if err = druo.check(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
node, err = druo.sqlSave(ctx)
|
|
|
|
} else {
|
|
|
|
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
|
|
|
mutation, ok := m.(*DeviceRequestMutation)
|
|
|
|
if !ok {
|
|
|
|
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
|
|
|
}
|
|
|
|
if err = druo.check(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
druo.mutation = mutation
|
|
|
|
node, err = druo.sqlSave(ctx)
|
|
|
|
mutation.done = true
|
|
|
|
return node, err
|
|
|
|
})
|
|
|
|
for i := len(druo.hooks) - 1; i >= 0; i-- {
|
2021-09-13 13:48:02 +00:00
|
|
|
if druo.hooks[i] == nil {
|
|
|
|
return nil, fmt.Errorf("db: uninitialized hook (forgotten import db/runtime?)")
|
|
|
|
}
|
2021-01-01 20:34:47 +00:00
|
|
|
mut = druo.hooks[i](mut)
|
|
|
|
}
|
|
|
|
if _, err := mut.Mutate(ctx, druo.mutation); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return node, err
|
|
|
|
}
|
|
|
|
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
|
|
func (druo *DeviceRequestUpdateOne) SaveX(ctx context.Context) *DeviceRequest {
|
|
|
|
node, err := druo.Save(ctx)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return node
|
|
|
|
}
|
|
|
|
|
|
|
|
// Exec executes the query on the entity.
|
|
|
|
func (druo *DeviceRequestUpdateOne) Exec(ctx context.Context) error {
|
|
|
|
_, err := druo.Save(ctx)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
|
|
func (druo *DeviceRequestUpdateOne) ExecX(ctx context.Context) {
|
|
|
|
if err := druo.Exec(ctx); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
|
|
func (druo *DeviceRequestUpdateOne) check() error {
|
|
|
|
if v, ok := druo.mutation.UserCode(); ok {
|
|
|
|
if err := devicerequest.UserCodeValidator(v); err != nil {
|
2022-03-07 09:15:01 +00:00
|
|
|
return &ValidationError{Name: "user_code", err: fmt.Errorf(`db: validator failed for field "DeviceRequest.user_code": %w`, err)}
|
2021-01-01 20:34:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if v, ok := druo.mutation.DeviceCode(); ok {
|
|
|
|
if err := devicerequest.DeviceCodeValidator(v); err != nil {
|
2022-03-07 09:15:01 +00:00
|
|
|
return &ValidationError{Name: "device_code", err: fmt.Errorf(`db: validator failed for field "DeviceRequest.device_code": %w`, err)}
|
2021-01-01 20:34:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if v, ok := druo.mutation.ClientID(); ok {
|
|
|
|
if err := devicerequest.ClientIDValidator(v); err != nil {
|
2022-03-07 09:15:01 +00:00
|
|
|
return &ValidationError{Name: "client_id", err: fmt.Errorf(`db: validator failed for field "DeviceRequest.client_id": %w`, err)}
|
2021-01-01 20:34:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if v, ok := druo.mutation.ClientSecret(); ok {
|
|
|
|
if err := devicerequest.ClientSecretValidator(v); err != nil {
|
2022-03-07 09:15:01 +00:00
|
|
|
return &ValidationError{Name: "client_secret", err: fmt.Errorf(`db: validator failed for field "DeviceRequest.client_secret": %w`, err)}
|
2021-01-01 20:34:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (druo *DeviceRequestUpdateOne) sqlSave(ctx context.Context) (_node *DeviceRequest, err error) {
|
|
|
|
_spec := &sqlgraph.UpdateSpec{
|
|
|
|
Node: &sqlgraph.NodeSpec{
|
|
|
|
Table: devicerequest.Table,
|
|
|
|
Columns: devicerequest.Columns,
|
|
|
|
ID: &sqlgraph.FieldSpec{
|
|
|
|
Type: field.TypeInt,
|
|
|
|
Column: devicerequest.FieldID,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
id, ok := druo.mutation.ID()
|
|
|
|
if !ok {
|
2022-03-07 09:15:01 +00:00
|
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`db: missing "DeviceRequest.id" for update`)}
|
2021-01-01 20:34:47 +00:00
|
|
|
}
|
|
|
|
_spec.Node.ID.Value = id
|
2021-04-30 14:31:49 +00:00
|
|
|
if fields := druo.fields; len(fields) > 0 {
|
|
|
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
|
|
|
_spec.Node.Columns = append(_spec.Node.Columns, devicerequest.FieldID)
|
|
|
|
for _, f := range fields {
|
|
|
|
if !devicerequest.ValidColumn(f) {
|
|
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)}
|
|
|
|
}
|
|
|
|
if f != devicerequest.FieldID {
|
|
|
|
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-03-24 06:37:51 +00:00
|
|
|
if ps := druo.mutation.predicates; len(ps) > 0 {
|
|
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
|
|
for i := range ps {
|
|
|
|
ps[i](selector)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-01-01 20:34:47 +00:00
|
|
|
if value, ok := druo.mutation.UserCode(); ok {
|
|
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
|
|
Type: field.TypeString,
|
|
|
|
Value: value,
|
|
|
|
Column: devicerequest.FieldUserCode,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
if value, ok := druo.mutation.DeviceCode(); ok {
|
|
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
|
|
Type: field.TypeString,
|
|
|
|
Value: value,
|
|
|
|
Column: devicerequest.FieldDeviceCode,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
if value, ok := druo.mutation.ClientID(); ok {
|
|
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
|
|
Type: field.TypeString,
|
|
|
|
Value: value,
|
|
|
|
Column: devicerequest.FieldClientID,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
if value, ok := druo.mutation.ClientSecret(); ok {
|
|
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
|
|
Type: field.TypeString,
|
|
|
|
Value: value,
|
|
|
|
Column: devicerequest.FieldClientSecret,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
if value, ok := druo.mutation.Scopes(); ok {
|
|
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
|
|
Type: field.TypeJSON,
|
|
|
|
Value: value,
|
|
|
|
Column: devicerequest.FieldScopes,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
if druo.mutation.ScopesCleared() {
|
|
|
|
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
|
|
|
Type: field.TypeJSON,
|
|
|
|
Column: devicerequest.FieldScopes,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
if value, ok := druo.mutation.Expiry(); ok {
|
|
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
|
|
Type: field.TypeTime,
|
|
|
|
Value: value,
|
|
|
|
Column: devicerequest.FieldExpiry,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
_node = &DeviceRequest{config: druo.config}
|
|
|
|
_spec.Assign = _node.assignValues
|
|
|
|
_spec.ScanValues = _node.scanValues
|
|
|
|
if err = sqlgraph.UpdateNode(ctx, druo.driver, _spec); err != nil {
|
|
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
|
|
err = &NotFoundError{devicerequest.Label}
|
2021-09-13 13:48:02 +00:00
|
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
|
|
err = &ConstraintError{err.Error(), err}
|
2021-01-01 20:34:47 +00:00
|
|
|
}
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return _node, nil
|
|
|
|
}
|