entc/gen: use gotypw pkgname as alias in case it does not match pkgpath (#2686)

This commit is contained in:
Ariel Mashraki
2022-06-25 11:05:15 +03:00
committed by GitHub
parent b44d593861
commit 6ddeb93649
20 changed files with 473 additions and 15 deletions

View File

@@ -14,6 +14,7 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/entc/integration/ent/comment"
schemadir "entgo.io/ent/entc/integration/ent/schema/dir"
"entgo.io/ent/schema/field"
)
@@ -65,6 +66,20 @@ func (cc *CommentCreate) SetNillableTable(s *string) *CommentCreate {
return cc
}
// SetDir sets the "dir" field.
func (cc *CommentCreate) SetDir(s schemadir.Dir) *CommentCreate {
cc.mutation.SetDir(s)
return cc
}
// SetNillableDir sets the "dir" field if the given value is not nil.
func (cc *CommentCreate) SetNillableDir(s *schemadir.Dir) *CommentCreate {
if s != nil {
cc.SetDir(*s)
}
return cc
}
// Mutation returns the CommentMutation object of the builder.
func (cc *CommentCreate) Mutation() *CommentMutation {
return cc.mutation
@@ -207,6 +222,14 @@ func (cc *CommentCreate) createSpec() (*Comment, *sqlgraph.CreateSpec) {
})
_node.Table = value
}
if value, ok := cc.mutation.Dir(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeJSON,
Value: value,
Column: comment.FieldDir,
})
_node.Dir = value
}
return _node, _spec
}
@@ -339,6 +362,24 @@ func (u *CommentUpsert) ClearTable() *CommentUpsert {
return u
}
// SetDir sets the "dir" field.
func (u *CommentUpsert) SetDir(v schemadir.Dir) *CommentUpsert {
u.Set(comment.FieldDir, v)
return u
}
// UpdateDir sets the "dir" field to the value that was provided on create.
func (u *CommentUpsert) UpdateDir() *CommentUpsert {
u.SetExcluded(comment.FieldDir)
return u
}
// ClearDir clears the value of the "dir" field.
func (u *CommentUpsert) ClearDir() *CommentUpsert {
u.SetNull(comment.FieldDir)
return u
}
// UpdateNewValues updates the mutable fields using the new values that were set on create.
// Using this option is equivalent to using:
//
@@ -472,6 +513,27 @@ func (u *CommentUpsertOne) ClearTable() *CommentUpsertOne {
})
}
// SetDir sets the "dir" field.
func (u *CommentUpsertOne) SetDir(v schemadir.Dir) *CommentUpsertOne {
return u.Update(func(s *CommentUpsert) {
s.SetDir(v)
})
}
// UpdateDir sets the "dir" field to the value that was provided on create.
func (u *CommentUpsertOne) UpdateDir() *CommentUpsertOne {
return u.Update(func(s *CommentUpsert) {
s.UpdateDir()
})
}
// ClearDir clears the value of the "dir" field.
func (u *CommentUpsertOne) ClearDir() *CommentUpsertOne {
return u.Update(func(s *CommentUpsert) {
s.ClearDir()
})
}
// Exec executes the query.
func (u *CommentUpsertOne) Exec(ctx context.Context) error {
if len(u.create.conflict) == 0 {
@@ -766,6 +828,27 @@ func (u *CommentUpsertBulk) ClearTable() *CommentUpsertBulk {
})
}
// SetDir sets the "dir" field.
func (u *CommentUpsertBulk) SetDir(v schemadir.Dir) *CommentUpsertBulk {
return u.Update(func(s *CommentUpsert) {
s.SetDir(v)
})
}
// UpdateDir sets the "dir" field to the value that was provided on create.
func (u *CommentUpsertBulk) UpdateDir() *CommentUpsertBulk {
return u.Update(func(s *CommentUpsert) {
s.UpdateDir()
})
}
// ClearDir clears the value of the "dir" field.
func (u *CommentUpsertBulk) ClearDir() *CommentUpsertBulk {
return u.Update(func(s *CommentUpsert) {
s.ClearDir()
})
}
// Exec executes the query.
func (u *CommentUpsertBulk) Exec(ctx context.Context) error {
for i, b := range u.create.builders {