entc/gen: allow using 'client' and 'tx' as schema field names (#2919)

This commit is contained in:
Ariel Mashraki
2022-09-09 10:38:25 +03:00
committed by GitHub
parent 366aaaad7a
commit ac937f8a6e
16 changed files with 633 additions and 10 deletions

View File

@@ -80,6 +80,20 @@ func (cc *CommentCreate) SetNillableDir(s *schemadir.Dir) *CommentCreate {
return cc
}
// SetClient sets the "client" field.
func (cc *CommentCreate) SetClient(s string) *CommentCreate {
cc.mutation.SetClient(s)
return cc
}
// SetNillableClient sets the "client" field if the given value is not nil.
func (cc *CommentCreate) SetNillableClient(s *string) *CommentCreate {
if s != nil {
cc.SetClient(*s)
}
return cc
}
// Mutation returns the CommentMutation object of the builder.
func (cc *CommentCreate) Mutation() *CommentMutation {
return cc.mutation
@@ -230,6 +244,14 @@ func (cc *CommentCreate) createSpec() (*Comment, *sqlgraph.CreateSpec) {
})
_node.Dir = value
}
if value, ok := cc.mutation.GetClient(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: comment.FieldClient,
})
_node.Client = value
}
return _node, _spec
}
@@ -378,6 +400,24 @@ func (u *CommentUpsert) ClearDir() *CommentUpsert {
return u
}
// SetClient sets the "client" field.
func (u *CommentUpsert) SetClient(v string) *CommentUpsert {
u.Set(comment.FieldClient, v)
return u
}
// UpdateClient sets the "client" field to the value that was provided on create.
func (u *CommentUpsert) UpdateClient() *CommentUpsert {
u.SetExcluded(comment.FieldClient)
return u
}
// ClearClient clears the value of the "client" field.
func (u *CommentUpsert) ClearClient() *CommentUpsert {
u.SetNull(comment.FieldClient)
return u
}
// UpdateNewValues updates the mutable fields using the new values that were set on create.
// Using this option is equivalent to using:
//
@@ -530,6 +570,27 @@ func (u *CommentUpsertOne) ClearDir() *CommentUpsertOne {
})
}
// SetClient sets the "client" field.
func (u *CommentUpsertOne) SetClient(v string) *CommentUpsertOne {
return u.Update(func(s *CommentUpsert) {
s.SetClient(v)
})
}
// UpdateClient sets the "client" field to the value that was provided on create.
func (u *CommentUpsertOne) UpdateClient() *CommentUpsertOne {
return u.Update(func(s *CommentUpsert) {
s.UpdateClient()
})
}
// ClearClient clears the value of the "client" field.
func (u *CommentUpsertOne) ClearClient() *CommentUpsertOne {
return u.Update(func(s *CommentUpsert) {
s.ClearClient()
})
}
// Exec executes the query.
func (u *CommentUpsertOne) Exec(ctx context.Context) error {
if len(u.create.conflict) == 0 {
@@ -841,6 +902,27 @@ func (u *CommentUpsertBulk) ClearDir() *CommentUpsertBulk {
})
}
// SetClient sets the "client" field.
func (u *CommentUpsertBulk) SetClient(v string) *CommentUpsertBulk {
return u.Update(func(s *CommentUpsert) {
s.SetClient(v)
})
}
// UpdateClient sets the "client" field to the value that was provided on create.
func (u *CommentUpsertBulk) UpdateClient() *CommentUpsertBulk {
return u.Update(func(s *CommentUpsert) {
s.UpdateClient()
})
}
// ClearClient clears the value of the "client" field.
func (u *CommentUpsertBulk) ClearClient() *CommentUpsertBulk {
return u.Update(func(s *CommentUpsert) {
s.ClearClient()
})
}
// Exec executes the query.
func (u *CommentUpsertBulk) Exec(ctx context.Context) error {
for i, b := range u.create.builders {