fixes 45 - cant generate
This commit is contained in:
parent
ed327dc066
commit
ff82ba532a
29 changed files with 1605 additions and 2481 deletions
|
|
@ -1,4 +1,4 @@
|
|||
// Code generated by entc, DO NOT EDIT.
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
|
|
@ -35,6 +35,14 @@ func (ptu *PasswordTokenUpdate) SetHash(s string) *PasswordTokenUpdate {
|
|||
return ptu
|
||||
}
|
||||
|
||||
// SetNillableHash sets the "hash" field if the given value is not nil.
|
||||
func (ptu *PasswordTokenUpdate) SetNillableHash(s *string) *PasswordTokenUpdate {
|
||||
if s != nil {
|
||||
ptu.SetHash(*s)
|
||||
}
|
||||
return ptu
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (ptu *PasswordTokenUpdate) SetCreatedAt(t time.Time) *PasswordTokenUpdate {
|
||||
ptu.mutation.SetCreatedAt(t)
|
||||
|
|
@ -73,40 +81,7 @@ func (ptu *PasswordTokenUpdate) ClearUser() *PasswordTokenUpdate {
|
|||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (ptu *PasswordTokenUpdate) Save(ctx context.Context) (int, error) {
|
||||
var (
|
||||
err error
|
||||
affected int
|
||||
)
|
||||
if len(ptu.hooks) == 0 {
|
||||
if err = ptu.check(); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
affected, err = ptu.sqlSave(ctx)
|
||||
} else {
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*PasswordTokenMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
if err = ptu.check(); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
ptu.mutation = mutation
|
||||
affected, err = ptu.sqlSave(ctx)
|
||||
mutation.done = true
|
||||
return affected, err
|
||||
})
|
||||
for i := len(ptu.hooks) - 1; i >= 0; i-- {
|
||||
if ptu.hooks[i] == nil {
|
||||
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
|
||||
}
|
||||
mut = ptu.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, ptu.mutation); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
return affected, err
|
||||
return withHooks(ctx, ptu.sqlSave, ptu.mutation, ptu.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
|
|
@ -145,16 +120,10 @@ func (ptu *PasswordTokenUpdate) check() error {
|
|||
}
|
||||
|
||||
func (ptu *PasswordTokenUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
_spec := &sqlgraph.UpdateSpec{
|
||||
Node: &sqlgraph.NodeSpec{
|
||||
Table: passwordtoken.Table,
|
||||
Columns: passwordtoken.Columns,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: passwordtoken.FieldID,
|
||||
},
|
||||
},
|
||||
if err := ptu.check(); err != nil {
|
||||
return n, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(passwordtoken.Table, passwordtoken.Columns, sqlgraph.NewFieldSpec(passwordtoken.FieldID, field.TypeInt))
|
||||
if ps := ptu.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
|
|
@ -163,18 +132,10 @@ func (ptu *PasswordTokenUpdate) sqlSave(ctx context.Context) (n int, err error)
|
|||
}
|
||||
}
|
||||
if value, ok := ptu.mutation.Hash(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: passwordtoken.FieldHash,
|
||||
})
|
||||
_spec.SetField(passwordtoken.FieldHash, field.TypeString, value)
|
||||
}
|
||||
if value, ok := ptu.mutation.CreatedAt(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: passwordtoken.FieldCreatedAt,
|
||||
})
|
||||
_spec.SetField(passwordtoken.FieldCreatedAt, field.TypeTime, value)
|
||||
}
|
||||
if ptu.mutation.UserCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
|
|
@ -184,10 +145,7 @@ func (ptu *PasswordTokenUpdate) sqlSave(ctx context.Context) (n int, err error)
|
|||
Columns: []string{passwordtoken.UserColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: user.FieldID,
|
||||
},
|
||||
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
|
|
@ -200,10 +158,7 @@ func (ptu *PasswordTokenUpdate) sqlSave(ctx context.Context) (n int, err error)
|
|||
Columns: []string{passwordtoken.UserColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: user.FieldID,
|
||||
},
|
||||
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
|
|
@ -215,10 +170,11 @@ func (ptu *PasswordTokenUpdate) sqlSave(ctx context.Context) (n int, err error)
|
|||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{passwordtoken.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{err.Error(), err}
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
ptu.mutation.done = true
|
||||
return n, nil
|
||||
}
|
||||
|
||||
|
|
@ -236,6 +192,14 @@ func (ptuo *PasswordTokenUpdateOne) SetHash(s string) *PasswordTokenUpdateOne {
|
|||
return ptuo
|
||||
}
|
||||
|
||||
// SetNillableHash sets the "hash" field if the given value is not nil.
|
||||
func (ptuo *PasswordTokenUpdateOne) SetNillableHash(s *string) *PasswordTokenUpdateOne {
|
||||
if s != nil {
|
||||
ptuo.SetHash(*s)
|
||||
}
|
||||
return ptuo
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (ptuo *PasswordTokenUpdateOne) SetCreatedAt(t time.Time) *PasswordTokenUpdateOne {
|
||||
ptuo.mutation.SetCreatedAt(t)
|
||||
|
|
@ -272,6 +236,12 @@ func (ptuo *PasswordTokenUpdateOne) ClearUser() *PasswordTokenUpdateOne {
|
|||
return ptuo
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the PasswordTokenUpdate builder.
|
||||
func (ptuo *PasswordTokenUpdateOne) Where(ps ...predicate.PasswordToken) *PasswordTokenUpdateOne {
|
||||
ptuo.mutation.Where(ps...)
|
||||
return ptuo
|
||||
}
|
||||
|
||||
// Select allows selecting one or more fields (columns) of the returned entity.
|
||||
// The default is selecting all fields defined in the entity schema.
|
||||
func (ptuo *PasswordTokenUpdateOne) Select(field string, fields ...string) *PasswordTokenUpdateOne {
|
||||
|
|
@ -281,40 +251,7 @@ func (ptuo *PasswordTokenUpdateOne) Select(field string, fields ...string) *Pass
|
|||
|
||||
// Save executes the query and returns the updated PasswordToken entity.
|
||||
func (ptuo *PasswordTokenUpdateOne) Save(ctx context.Context) (*PasswordToken, error) {
|
||||
var (
|
||||
err error
|
||||
node *PasswordToken
|
||||
)
|
||||
if len(ptuo.hooks) == 0 {
|
||||
if err = ptuo.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
node, err = ptuo.sqlSave(ctx)
|
||||
} else {
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*PasswordTokenMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
if err = ptuo.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ptuo.mutation = mutation
|
||||
node, err = ptuo.sqlSave(ctx)
|
||||
mutation.done = true
|
||||
return node, err
|
||||
})
|
||||
for i := len(ptuo.hooks) - 1; i >= 0; i-- {
|
||||
if ptuo.hooks[i] == nil {
|
||||
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
|
||||
}
|
||||
mut = ptuo.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, ptuo.mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return node, err
|
||||
return withHooks(ctx, ptuo.sqlSave, ptuo.mutation, ptuo.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
|
|
@ -353,16 +290,10 @@ func (ptuo *PasswordTokenUpdateOne) check() error {
|
|||
}
|
||||
|
||||
func (ptuo *PasswordTokenUpdateOne) sqlSave(ctx context.Context) (_node *PasswordToken, err error) {
|
||||
_spec := &sqlgraph.UpdateSpec{
|
||||
Node: &sqlgraph.NodeSpec{
|
||||
Table: passwordtoken.Table,
|
||||
Columns: passwordtoken.Columns,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: passwordtoken.FieldID,
|
||||
},
|
||||
},
|
||||
if err := ptuo.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(passwordtoken.Table, passwordtoken.Columns, sqlgraph.NewFieldSpec(passwordtoken.FieldID, field.TypeInt))
|
||||
id, ok := ptuo.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "PasswordToken.id" for update`)}
|
||||
|
|
@ -388,18 +319,10 @@ func (ptuo *PasswordTokenUpdateOne) sqlSave(ctx context.Context) (_node *Passwor
|
|||
}
|
||||
}
|
||||
if value, ok := ptuo.mutation.Hash(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: passwordtoken.FieldHash,
|
||||
})
|
||||
_spec.SetField(passwordtoken.FieldHash, field.TypeString, value)
|
||||
}
|
||||
if value, ok := ptuo.mutation.CreatedAt(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: passwordtoken.FieldCreatedAt,
|
||||
})
|
||||
_spec.SetField(passwordtoken.FieldCreatedAt, field.TypeTime, value)
|
||||
}
|
||||
if ptuo.mutation.UserCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
|
|
@ -409,10 +332,7 @@ func (ptuo *PasswordTokenUpdateOne) sqlSave(ctx context.Context) (_node *Passwor
|
|||
Columns: []string{passwordtoken.UserColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: user.FieldID,
|
||||
},
|
||||
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
|
|
@ -425,10 +345,7 @@ func (ptuo *PasswordTokenUpdateOne) sqlSave(ctx context.Context) (_node *Passwor
|
|||
Columns: []string{passwordtoken.UserColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: user.FieldID,
|
||||
},
|
||||
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
|
|
@ -443,9 +360,10 @@ func (ptuo *PasswordTokenUpdateOne) sqlSave(ctx context.Context) (_node *Passwor
|
|||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{passwordtoken.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{err.Error(), err}
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
ptuo.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue