|
@@ -28,12 +28,28 @@ func (mc *MsgCreate) SetCreatedAt(t time.Time) *MsgCreate {
|
|
|
return mc
|
|
|
}
|
|
|
|
|
|
+// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
|
+func (mc *MsgCreate) SetNillableCreatedAt(t *time.Time) *MsgCreate {
|
|
|
+ if t != nil {
|
|
|
+ mc.SetCreatedAt(*t)
|
|
|
+ }
|
|
|
+ return mc
|
|
|
+}
|
|
|
+
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
|
func (mc *MsgCreate) SetUpdatedAt(t time.Time) *MsgCreate {
|
|
|
mc.mutation.SetUpdatedAt(t)
|
|
|
return mc
|
|
|
}
|
|
|
|
|
|
+// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
|
|
+func (mc *MsgCreate) SetNillableUpdatedAt(t *time.Time) *MsgCreate {
|
|
|
+ if t != nil {
|
|
|
+ mc.SetUpdatedAt(*t)
|
|
|
+ }
|
|
|
+ return mc
|
|
|
+}
|
|
|
+
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
|
func (mc *MsgCreate) SetDeletedAt(t time.Time) *MsgCreate {
|
|
|
mc.mutation.SetDeletedAt(t)
|
|
@@ -133,8 +149,8 @@ func (mc *MsgCreate) SetNillableBatchNo(s *string) *MsgCreate {
|
|
|
}
|
|
|
|
|
|
// SetID sets the "id" field.
|
|
|
-func (mc *MsgCreate) SetID(i int) *MsgCreate {
|
|
|
- mc.mutation.SetID(i)
|
|
|
+func (mc *MsgCreate) SetID(u uint64) *MsgCreate {
|
|
|
+ mc.mutation.SetID(u)
|
|
|
return mc
|
|
|
}
|
|
|
|
|
@@ -145,6 +161,9 @@ func (mc *MsgCreate) Mutation() *MsgMutation {
|
|
|
|
|
|
// Save creates the Msg in the database.
|
|
|
func (mc *MsgCreate) Save(ctx context.Context) (*Msg, error) {
|
|
|
+ if err := mc.defaults(); err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
return withHooks(ctx, mc.sqlSave, mc.mutation, mc.hooks)
|
|
|
}
|
|
|
|
|
@@ -170,6 +189,25 @@ func (mc *MsgCreate) ExecX(ctx context.Context) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// defaults sets the default values of the builder before save.
|
|
|
+func (mc *MsgCreate) defaults() error {
|
|
|
+ if _, ok := mc.mutation.CreatedAt(); !ok {
|
|
|
+ if msg.DefaultCreatedAt == nil {
|
|
|
+ return fmt.Errorf("ent: uninitialized msg.DefaultCreatedAt (forgotten import ent/runtime?)")
|
|
|
+ }
|
|
|
+ v := msg.DefaultCreatedAt()
|
|
|
+ mc.mutation.SetCreatedAt(v)
|
|
|
+ }
|
|
|
+ if _, ok := mc.mutation.UpdatedAt(); !ok {
|
|
|
+ if msg.DefaultUpdatedAt == nil {
|
|
|
+ return fmt.Errorf("ent: uninitialized msg.DefaultUpdatedAt (forgotten import ent/runtime?)")
|
|
|
+ }
|
|
|
+ v := msg.DefaultUpdatedAt()
|
|
|
+ mc.mutation.SetUpdatedAt(v)
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
|
func (mc *MsgCreate) check() error {
|
|
|
if _, ok := mc.mutation.CreatedAt(); !ok {
|
|
@@ -194,7 +232,7 @@ func (mc *MsgCreate) sqlSave(ctx context.Context) (*Msg, error) {
|
|
|
}
|
|
|
if _spec.ID.Value != _node.ID {
|
|
|
id := _spec.ID.Value.(int64)
|
|
|
- _node.ID = int(id)
|
|
|
+ _node.ID = uint64(id)
|
|
|
}
|
|
|
mc.mutation.id = &_node.ID
|
|
|
mc.mutation.done = true
|
|
@@ -204,7 +242,7 @@ func (mc *MsgCreate) sqlSave(ctx context.Context) (*Msg, error) {
|
|
|
func (mc *MsgCreate) createSpec() (*Msg, *sqlgraph.CreateSpec) {
|
|
|
var (
|
|
|
_node = &Msg{config: mc.config}
|
|
|
- _spec = sqlgraph.NewCreateSpec(msg.Table, sqlgraph.NewFieldSpec(msg.FieldID, field.TypeInt))
|
|
|
+ _spec = sqlgraph.NewCreateSpec(msg.Table, sqlgraph.NewFieldSpec(msg.FieldID, field.TypeUint64))
|
|
|
)
|
|
|
_spec.OnConflict = mc.conflict
|
|
|
if id, ok := mc.mutation.ID(); ok {
|
|
@@ -299,18 +337,6 @@ type (
|
|
|
}
|
|
|
)
|
|
|
|
|
|
-// SetCreatedAt sets the "created_at" field.
|
|
|
-func (u *MsgUpsert) SetCreatedAt(v time.Time) *MsgUpsert {
|
|
|
- u.Set(msg.FieldCreatedAt, v)
|
|
|
- return u
|
|
|
-}
|
|
|
-
|
|
|
-// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
|
-func (u *MsgUpsert) UpdateCreatedAt() *MsgUpsert {
|
|
|
- u.SetExcluded(msg.FieldCreatedAt)
|
|
|
- return u
|
|
|
-}
|
|
|
-
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
|
func (u *MsgUpsert) SetUpdatedAt(v time.Time) *MsgUpsert {
|
|
|
u.Set(msg.FieldUpdatedAt, v)
|
|
@@ -478,6 +504,9 @@ func (u *MsgUpsertOne) UpdateNewValues() *MsgUpsertOne {
|
|
|
if _, exists := u.create.mutation.ID(); exists {
|
|
|
s.SetIgnore(msg.FieldID)
|
|
|
}
|
|
|
+ if _, exists := u.create.mutation.CreatedAt(); exists {
|
|
|
+ s.SetIgnore(msg.FieldCreatedAt)
|
|
|
+ }
|
|
|
}))
|
|
|
return u
|
|
|
}
|
|
@@ -509,20 +538,6 @@ func (u *MsgUpsertOne) Update(set func(*MsgUpsert)) *MsgUpsertOne {
|
|
|
return u
|
|
|
}
|
|
|
|
|
|
-// SetCreatedAt sets the "created_at" field.
|
|
|
-func (u *MsgUpsertOne) SetCreatedAt(v time.Time) *MsgUpsertOne {
|
|
|
- return u.Update(func(s *MsgUpsert) {
|
|
|
- s.SetCreatedAt(v)
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
|
-func (u *MsgUpsertOne) UpdateCreatedAt() *MsgUpsertOne {
|
|
|
- return u.Update(func(s *MsgUpsert) {
|
|
|
- s.UpdateCreatedAt()
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
|
func (u *MsgUpsertOne) SetUpdatedAt(v time.Time) *MsgUpsertOne {
|
|
|
return u.Update(func(s *MsgUpsert) {
|
|
@@ -714,7 +729,7 @@ func (u *MsgUpsertOne) ExecX(ctx context.Context) {
|
|
|
}
|
|
|
|
|
|
// Exec executes the UPSERT query and returns the inserted/updated ID.
|
|
|
-func (u *MsgUpsertOne) ID(ctx context.Context) (id int, err error) {
|
|
|
+func (u *MsgUpsertOne) ID(ctx context.Context) (id uint64, err error) {
|
|
|
node, err := u.create.Save(ctx)
|
|
|
if err != nil {
|
|
|
return id, err
|
|
@@ -723,7 +738,7 @@ func (u *MsgUpsertOne) ID(ctx context.Context) (id int, err error) {
|
|
|
}
|
|
|
|
|
|
// IDX is like ID, but panics if an error occurs.
|
|
|
-func (u *MsgUpsertOne) IDX(ctx context.Context) int {
|
|
|
+func (u *MsgUpsertOne) IDX(ctx context.Context) uint64 {
|
|
|
id, err := u.ID(ctx)
|
|
|
if err != nil {
|
|
|
panic(err)
|
|
@@ -750,6 +765,7 @@ func (mcb *MsgCreateBulk) Save(ctx context.Context) ([]*Msg, error) {
|
|
|
for i := range mcb.builders {
|
|
|
func(i int, root context.Context) {
|
|
|
builder := mcb.builders[i]
|
|
|
+ builder.defaults()
|
|
|
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
|
|
mutation, ok := m.(*MsgMutation)
|
|
|
if !ok {
|
|
@@ -779,7 +795,7 @@ func (mcb *MsgCreateBulk) Save(ctx context.Context) ([]*Msg, error) {
|
|
|
mutation.id = &nodes[i].ID
|
|
|
if specs[i].ID.Value != nil && nodes[i].ID == 0 {
|
|
|
id := specs[i].ID.Value.(int64)
|
|
|
- nodes[i].ID = int(id)
|
|
|
+ nodes[i].ID = uint64(id)
|
|
|
}
|
|
|
mutation.done = true
|
|
|
return nodes[i], nil
|
|
@@ -879,6 +895,9 @@ func (u *MsgUpsertBulk) UpdateNewValues() *MsgUpsertBulk {
|
|
|
if _, exists := b.mutation.ID(); exists {
|
|
|
s.SetIgnore(msg.FieldID)
|
|
|
}
|
|
|
+ if _, exists := b.mutation.CreatedAt(); exists {
|
|
|
+ s.SetIgnore(msg.FieldCreatedAt)
|
|
|
+ }
|
|
|
}
|
|
|
}))
|
|
|
return u
|
|
@@ -911,20 +930,6 @@ func (u *MsgUpsertBulk) Update(set func(*MsgUpsert)) *MsgUpsertBulk {
|
|
|
return u
|
|
|
}
|
|
|
|
|
|
-// SetCreatedAt sets the "created_at" field.
|
|
|
-func (u *MsgUpsertBulk) SetCreatedAt(v time.Time) *MsgUpsertBulk {
|
|
|
- return u.Update(func(s *MsgUpsert) {
|
|
|
- s.SetCreatedAt(v)
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
|
-func (u *MsgUpsertBulk) UpdateCreatedAt() *MsgUpsertBulk {
|
|
|
- return u.Update(func(s *MsgUpsert) {
|
|
|
- s.UpdateCreatedAt()
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
|
func (u *MsgUpsertBulk) SetUpdatedAt(v time.Time) *MsgUpsertBulk {
|
|
|
return u.Update(func(s *MsgUpsert) {
|