// Code generated by ent, DO NOT EDIT.

package ent

import (
	"context"
	"errors"
	"fmt"
	"galileo/ent/predicate"
	"galileo/ent/project"
	"time"

	"entgo.io/ent/dialect/sql"
	"entgo.io/ent/dialect/sql/sqlgraph"
	"entgo.io/ent/schema/field"
)

// ProjectUpdate is the builder for updating Project entities.
type ProjectUpdate struct {
	config
	hooks    []Hook
	mutation *ProjectMutation
}

// Where appends a list predicates to the ProjectUpdate builder.
func (pu *ProjectUpdate) Where(ps ...predicate.Project) *ProjectUpdate {
	pu.mutation.Where(ps...)
	return pu
}

// SetName sets the "name" field.
func (pu *ProjectUpdate) SetName(s string) *ProjectUpdate {
	pu.mutation.SetName(s)
	return pu
}

// SetIdentifier sets the "identifier" field.
func (pu *ProjectUpdate) SetIdentifier(s string) *ProjectUpdate {
	pu.mutation.SetIdentifier(s)
	return pu
}

// SetUpdatedAt sets the "updated_at" field.
func (pu *ProjectUpdate) SetUpdatedAt(t time.Time) *ProjectUpdate {
	pu.mutation.SetUpdatedAt(t)
	return pu
}

// ClearUpdatedAt clears the value of the "updated_at" field.
func (pu *ProjectUpdate) ClearUpdatedAt() *ProjectUpdate {
	pu.mutation.ClearUpdatedAt()
	return pu
}

// SetUpdatedBy sets the "updated_by" field.
func (pu *ProjectUpdate) SetUpdatedBy(u uint32) *ProjectUpdate {
	pu.mutation.ResetUpdatedBy()
	pu.mutation.SetUpdatedBy(u)
	return pu
}

// SetNillableUpdatedBy sets the "updated_by" field if the given value is not nil.
func (pu *ProjectUpdate) SetNillableUpdatedBy(u *uint32) *ProjectUpdate {
	if u != nil {
		pu.SetUpdatedBy(*u)
	}
	return pu
}

// AddUpdatedBy adds u to the "updated_by" field.
func (pu *ProjectUpdate) AddUpdatedBy(u int32) *ProjectUpdate {
	pu.mutation.AddUpdatedBy(u)
	return pu
}

// ClearUpdatedBy clears the value of the "updated_by" field.
func (pu *ProjectUpdate) ClearUpdatedBy() *ProjectUpdate {
	pu.mutation.ClearUpdatedBy()
	return pu
}

// SetDeletedAt sets the "deleted_at" field.
func (pu *ProjectUpdate) SetDeletedAt(t time.Time) *ProjectUpdate {
	pu.mutation.SetDeletedAt(t)
	return pu
}

// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
func (pu *ProjectUpdate) SetNillableDeletedAt(t *time.Time) *ProjectUpdate {
	if t != nil {
		pu.SetDeletedAt(*t)
	}
	return pu
}

// ClearDeletedAt clears the value of the "deleted_at" field.
func (pu *ProjectUpdate) ClearDeletedAt() *ProjectUpdate {
	pu.mutation.ClearDeletedAt()
	return pu
}

// SetDeletedBy sets the "deleted_by" field.
func (pu *ProjectUpdate) SetDeletedBy(u uint32) *ProjectUpdate {
	pu.mutation.ResetDeletedBy()
	pu.mutation.SetDeletedBy(u)
	return pu
}

// SetNillableDeletedBy sets the "deleted_by" field if the given value is not nil.
func (pu *ProjectUpdate) SetNillableDeletedBy(u *uint32) *ProjectUpdate {
	if u != nil {
		pu.SetDeletedBy(*u)
	}
	return pu
}

// AddDeletedBy adds u to the "deleted_by" field.
func (pu *ProjectUpdate) AddDeletedBy(u int32) *ProjectUpdate {
	pu.mutation.AddDeletedBy(u)
	return pu
}

// ClearDeletedBy clears the value of the "deleted_by" field.
func (pu *ProjectUpdate) ClearDeletedBy() *ProjectUpdate {
	pu.mutation.ClearDeletedBy()
	return pu
}

// SetStatus sets the "status" field.
func (pu *ProjectUpdate) SetStatus(i int8) *ProjectUpdate {
	pu.mutation.ResetStatus()
	pu.mutation.SetStatus(i)
	return pu
}

// SetNillableStatus sets the "status" field if the given value is not nil.
func (pu *ProjectUpdate) SetNillableStatus(i *int8) *ProjectUpdate {
	if i != nil {
		pu.SetStatus(*i)
	}
	return pu
}

// AddStatus adds i to the "status" field.
func (pu *ProjectUpdate) AddStatus(i int8) *ProjectUpdate {
	pu.mutation.AddStatus(i)
	return pu
}

// SetStartTime sets the "start_time" field.
func (pu *ProjectUpdate) SetStartTime(t time.Time) *ProjectUpdate {
	pu.mutation.SetStartTime(t)
	return pu
}

// SetNillableStartTime sets the "start_time" field if the given value is not nil.
func (pu *ProjectUpdate) SetNillableStartTime(t *time.Time) *ProjectUpdate {
	if t != nil {
		pu.SetStartTime(*t)
	}
	return pu
}

// ClearStartTime clears the value of the "start_time" field.
func (pu *ProjectUpdate) ClearStartTime() *ProjectUpdate {
	pu.mutation.ClearStartTime()
	return pu
}

// SetDeadline sets the "deadline" field.
func (pu *ProjectUpdate) SetDeadline(t time.Time) *ProjectUpdate {
	pu.mutation.SetDeadline(t)
	return pu
}

// SetNillableDeadline sets the "deadline" field if the given value is not nil.
func (pu *ProjectUpdate) SetNillableDeadline(t *time.Time) *ProjectUpdate {
	if t != nil {
		pu.SetDeadline(*t)
	}
	return pu
}

// ClearDeadline clears the value of the "deadline" field.
func (pu *ProjectUpdate) ClearDeadline() *ProjectUpdate {
	pu.mutation.ClearDeadline()
	return pu
}

// SetDescription sets the "description" field.
func (pu *ProjectUpdate) SetDescription(s string) *ProjectUpdate {
	pu.mutation.SetDescription(s)
	return pu
}

// SetNillableDescription sets the "description" field if the given value is not nil.
func (pu *ProjectUpdate) SetNillableDescription(s *string) *ProjectUpdate {
	if s != nil {
		pu.SetDescription(*s)
	}
	return pu
}

// ClearDescription clears the value of the "description" field.
func (pu *ProjectUpdate) ClearDescription() *ProjectUpdate {
	pu.mutation.ClearDescription()
	return pu
}

// SetRemark sets the "remark" field.
func (pu *ProjectUpdate) SetRemark(s string) *ProjectUpdate {
	pu.mutation.SetRemark(s)
	return pu
}

// SetNillableRemark sets the "remark" field if the given value is not nil.
func (pu *ProjectUpdate) SetNillableRemark(s *string) *ProjectUpdate {
	if s != nil {
		pu.SetRemark(*s)
	}
	return pu
}

// ClearRemark clears the value of the "remark" field.
func (pu *ProjectUpdate) ClearRemark() *ProjectUpdate {
	pu.mutation.ClearRemark()
	return pu
}

// Mutation returns the ProjectMutation object of the builder.
func (pu *ProjectUpdate) Mutation() *ProjectMutation {
	return pu.mutation
}

// Save executes the query and returns the number of nodes affected by the update operation.
func (pu *ProjectUpdate) Save(ctx context.Context) (int, error) {
	pu.defaults()
	return withHooks[int, ProjectMutation](ctx, pu.sqlSave, pu.mutation, pu.hooks)
}

// SaveX is like Save, but panics if an error occurs.
func (pu *ProjectUpdate) SaveX(ctx context.Context) int {
	affected, err := pu.Save(ctx)
	if err != nil {
		panic(err)
	}
	return affected
}

// Exec executes the query.
func (pu *ProjectUpdate) Exec(ctx context.Context) error {
	_, err := pu.Save(ctx)
	return err
}

// ExecX is like Exec, but panics if an error occurs.
func (pu *ProjectUpdate) ExecX(ctx context.Context) {
	if err := pu.Exec(ctx); err != nil {
		panic(err)
	}
}

// defaults sets the default values of the builder before save.
func (pu *ProjectUpdate) defaults() {
	if _, ok := pu.mutation.UpdatedAt(); !ok && !pu.mutation.UpdatedAtCleared() {
		v := project.UpdateDefaultUpdatedAt()
		pu.mutation.SetUpdatedAt(v)
	}
}

// check runs all checks and user-defined validators on the builder.
func (pu *ProjectUpdate) check() error {
	if v, ok := pu.mutation.Name(); ok {
		if err := project.NameValidator(v); err != nil {
			return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Project.name": %w`, err)}
		}
	}
	if v, ok := pu.mutation.Identifier(); ok {
		if err := project.IdentifierValidator(v); err != nil {
			return &ValidationError{Name: "identifier", err: fmt.Errorf(`ent: validator failed for field "Project.identifier": %w`, err)}
		}
	}
	return nil
}

func (pu *ProjectUpdate) sqlSave(ctx context.Context) (n int, err error) {
	if err := pu.check(); err != nil {
		return n, err
	}
	_spec := sqlgraph.NewUpdateSpec(project.Table, project.Columns, sqlgraph.NewFieldSpec(project.FieldID, field.TypeInt64))
	if ps := pu.mutation.predicates; len(ps) > 0 {
		_spec.Predicate = func(selector *sql.Selector) {
			for i := range ps {
				ps[i](selector)
			}
		}
	}
	if value, ok := pu.mutation.Name(); ok {
		_spec.SetField(project.FieldName, field.TypeString, value)
	}
	if value, ok := pu.mutation.Identifier(); ok {
		_spec.SetField(project.FieldIdentifier, field.TypeString, value)
	}
	if value, ok := pu.mutation.UpdatedAt(); ok {
		_spec.SetField(project.FieldUpdatedAt, field.TypeTime, value)
	}
	if pu.mutation.UpdatedAtCleared() {
		_spec.ClearField(project.FieldUpdatedAt, field.TypeTime)
	}
	if value, ok := pu.mutation.UpdatedBy(); ok {
		_spec.SetField(project.FieldUpdatedBy, field.TypeUint32, value)
	}
	if value, ok := pu.mutation.AddedUpdatedBy(); ok {
		_spec.AddField(project.FieldUpdatedBy, field.TypeUint32, value)
	}
	if pu.mutation.UpdatedByCleared() {
		_spec.ClearField(project.FieldUpdatedBy, field.TypeUint32)
	}
	if value, ok := pu.mutation.DeletedAt(); ok {
		_spec.SetField(project.FieldDeletedAt, field.TypeTime, value)
	}
	if pu.mutation.DeletedAtCleared() {
		_spec.ClearField(project.FieldDeletedAt, field.TypeTime)
	}
	if value, ok := pu.mutation.DeletedBy(); ok {
		_spec.SetField(project.FieldDeletedBy, field.TypeUint32, value)
	}
	if value, ok := pu.mutation.AddedDeletedBy(); ok {
		_spec.AddField(project.FieldDeletedBy, field.TypeUint32, value)
	}
	if pu.mutation.DeletedByCleared() {
		_spec.ClearField(project.FieldDeletedBy, field.TypeUint32)
	}
	if value, ok := pu.mutation.Status(); ok {
		_spec.SetField(project.FieldStatus, field.TypeInt8, value)
	}
	if value, ok := pu.mutation.AddedStatus(); ok {
		_spec.AddField(project.FieldStatus, field.TypeInt8, value)
	}
	if value, ok := pu.mutation.StartTime(); ok {
		_spec.SetField(project.FieldStartTime, field.TypeTime, value)
	}
	if pu.mutation.StartTimeCleared() {
		_spec.ClearField(project.FieldStartTime, field.TypeTime)
	}
	if value, ok := pu.mutation.Deadline(); ok {
		_spec.SetField(project.FieldDeadline, field.TypeTime, value)
	}
	if pu.mutation.DeadlineCleared() {
		_spec.ClearField(project.FieldDeadline, field.TypeTime)
	}
	if value, ok := pu.mutation.Description(); ok {
		_spec.SetField(project.FieldDescription, field.TypeString, value)
	}
	if pu.mutation.DescriptionCleared() {
		_spec.ClearField(project.FieldDescription, field.TypeString)
	}
	if value, ok := pu.mutation.Remark(); ok {
		_spec.SetField(project.FieldRemark, field.TypeString, value)
	}
	if pu.mutation.RemarkCleared() {
		_spec.ClearField(project.FieldRemark, field.TypeString)
	}
	if n, err = sqlgraph.UpdateNodes(ctx, pu.driver, _spec); err != nil {
		if _, ok := err.(*sqlgraph.NotFoundError); ok {
			err = &NotFoundError{project.Label}
		} else if sqlgraph.IsConstraintError(err) {
			err = &ConstraintError{msg: err.Error(), wrap: err}
		}
		return 0, err
	}
	pu.mutation.done = true
	return n, nil
}

// ProjectUpdateOne is the builder for updating a single Project entity.
type ProjectUpdateOne struct {
	config
	fields   []string
	hooks    []Hook
	mutation *ProjectMutation
}

// SetName sets the "name" field.
func (puo *ProjectUpdateOne) SetName(s string) *ProjectUpdateOne {
	puo.mutation.SetName(s)
	return puo
}

// SetIdentifier sets the "identifier" field.
func (puo *ProjectUpdateOne) SetIdentifier(s string) *ProjectUpdateOne {
	puo.mutation.SetIdentifier(s)
	return puo
}

// SetUpdatedAt sets the "updated_at" field.
func (puo *ProjectUpdateOne) SetUpdatedAt(t time.Time) *ProjectUpdateOne {
	puo.mutation.SetUpdatedAt(t)
	return puo
}

// ClearUpdatedAt clears the value of the "updated_at" field.
func (puo *ProjectUpdateOne) ClearUpdatedAt() *ProjectUpdateOne {
	puo.mutation.ClearUpdatedAt()
	return puo
}

// SetUpdatedBy sets the "updated_by" field.
func (puo *ProjectUpdateOne) SetUpdatedBy(u uint32) *ProjectUpdateOne {
	puo.mutation.ResetUpdatedBy()
	puo.mutation.SetUpdatedBy(u)
	return puo
}

// SetNillableUpdatedBy sets the "updated_by" field if the given value is not nil.
func (puo *ProjectUpdateOne) SetNillableUpdatedBy(u *uint32) *ProjectUpdateOne {
	if u != nil {
		puo.SetUpdatedBy(*u)
	}
	return puo
}

// AddUpdatedBy adds u to the "updated_by" field.
func (puo *ProjectUpdateOne) AddUpdatedBy(u int32) *ProjectUpdateOne {
	puo.mutation.AddUpdatedBy(u)
	return puo
}

// ClearUpdatedBy clears the value of the "updated_by" field.
func (puo *ProjectUpdateOne) ClearUpdatedBy() *ProjectUpdateOne {
	puo.mutation.ClearUpdatedBy()
	return puo
}

// SetDeletedAt sets the "deleted_at" field.
func (puo *ProjectUpdateOne) SetDeletedAt(t time.Time) *ProjectUpdateOne {
	puo.mutation.SetDeletedAt(t)
	return puo
}

// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
func (puo *ProjectUpdateOne) SetNillableDeletedAt(t *time.Time) *ProjectUpdateOne {
	if t != nil {
		puo.SetDeletedAt(*t)
	}
	return puo
}

// ClearDeletedAt clears the value of the "deleted_at" field.
func (puo *ProjectUpdateOne) ClearDeletedAt() *ProjectUpdateOne {
	puo.mutation.ClearDeletedAt()
	return puo
}

// SetDeletedBy sets the "deleted_by" field.
func (puo *ProjectUpdateOne) SetDeletedBy(u uint32) *ProjectUpdateOne {
	puo.mutation.ResetDeletedBy()
	puo.mutation.SetDeletedBy(u)
	return puo
}

// SetNillableDeletedBy sets the "deleted_by" field if the given value is not nil.
func (puo *ProjectUpdateOne) SetNillableDeletedBy(u *uint32) *ProjectUpdateOne {
	if u != nil {
		puo.SetDeletedBy(*u)
	}
	return puo
}

// AddDeletedBy adds u to the "deleted_by" field.
func (puo *ProjectUpdateOne) AddDeletedBy(u int32) *ProjectUpdateOne {
	puo.mutation.AddDeletedBy(u)
	return puo
}

// ClearDeletedBy clears the value of the "deleted_by" field.
func (puo *ProjectUpdateOne) ClearDeletedBy() *ProjectUpdateOne {
	puo.mutation.ClearDeletedBy()
	return puo
}

// SetStatus sets the "status" field.
func (puo *ProjectUpdateOne) SetStatus(i int8) *ProjectUpdateOne {
	puo.mutation.ResetStatus()
	puo.mutation.SetStatus(i)
	return puo
}

// SetNillableStatus sets the "status" field if the given value is not nil.
func (puo *ProjectUpdateOne) SetNillableStatus(i *int8) *ProjectUpdateOne {
	if i != nil {
		puo.SetStatus(*i)
	}
	return puo
}

// AddStatus adds i to the "status" field.
func (puo *ProjectUpdateOne) AddStatus(i int8) *ProjectUpdateOne {
	puo.mutation.AddStatus(i)
	return puo
}

// SetStartTime sets the "start_time" field.
func (puo *ProjectUpdateOne) SetStartTime(t time.Time) *ProjectUpdateOne {
	puo.mutation.SetStartTime(t)
	return puo
}

// SetNillableStartTime sets the "start_time" field if the given value is not nil.
func (puo *ProjectUpdateOne) SetNillableStartTime(t *time.Time) *ProjectUpdateOne {
	if t != nil {
		puo.SetStartTime(*t)
	}
	return puo
}

// ClearStartTime clears the value of the "start_time" field.
func (puo *ProjectUpdateOne) ClearStartTime() *ProjectUpdateOne {
	puo.mutation.ClearStartTime()
	return puo
}

// SetDeadline sets the "deadline" field.
func (puo *ProjectUpdateOne) SetDeadline(t time.Time) *ProjectUpdateOne {
	puo.mutation.SetDeadline(t)
	return puo
}

// SetNillableDeadline sets the "deadline" field if the given value is not nil.
func (puo *ProjectUpdateOne) SetNillableDeadline(t *time.Time) *ProjectUpdateOne {
	if t != nil {
		puo.SetDeadline(*t)
	}
	return puo
}

// ClearDeadline clears the value of the "deadline" field.
func (puo *ProjectUpdateOne) ClearDeadline() *ProjectUpdateOne {
	puo.mutation.ClearDeadline()
	return puo
}

// SetDescription sets the "description" field.
func (puo *ProjectUpdateOne) SetDescription(s string) *ProjectUpdateOne {
	puo.mutation.SetDescription(s)
	return puo
}

// SetNillableDescription sets the "description" field if the given value is not nil.
func (puo *ProjectUpdateOne) SetNillableDescription(s *string) *ProjectUpdateOne {
	if s != nil {
		puo.SetDescription(*s)
	}
	return puo
}

// ClearDescription clears the value of the "description" field.
func (puo *ProjectUpdateOne) ClearDescription() *ProjectUpdateOne {
	puo.mutation.ClearDescription()
	return puo
}

// SetRemark sets the "remark" field.
func (puo *ProjectUpdateOne) SetRemark(s string) *ProjectUpdateOne {
	puo.mutation.SetRemark(s)
	return puo
}

// SetNillableRemark sets the "remark" field if the given value is not nil.
func (puo *ProjectUpdateOne) SetNillableRemark(s *string) *ProjectUpdateOne {
	if s != nil {
		puo.SetRemark(*s)
	}
	return puo
}

// ClearRemark clears the value of the "remark" field.
func (puo *ProjectUpdateOne) ClearRemark() *ProjectUpdateOne {
	puo.mutation.ClearRemark()
	return puo
}

// Mutation returns the ProjectMutation object of the builder.
func (puo *ProjectUpdateOne) Mutation() *ProjectMutation {
	return puo.mutation
}

// Where appends a list predicates to the ProjectUpdate builder.
func (puo *ProjectUpdateOne) Where(ps ...predicate.Project) *ProjectUpdateOne {
	puo.mutation.Where(ps...)
	return puo
}

// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func (puo *ProjectUpdateOne) Select(field string, fields ...string) *ProjectUpdateOne {
	puo.fields = append([]string{field}, fields...)
	return puo
}

// Save executes the query and returns the updated Project entity.
func (puo *ProjectUpdateOne) Save(ctx context.Context) (*Project, error) {
	puo.defaults()
	return withHooks[*Project, ProjectMutation](ctx, puo.sqlSave, puo.mutation, puo.hooks)
}

// SaveX is like Save, but panics if an error occurs.
func (puo *ProjectUpdateOne) SaveX(ctx context.Context) *Project {
	node, err := puo.Save(ctx)
	if err != nil {
		panic(err)
	}
	return node
}

// Exec executes the query on the entity.
func (puo *ProjectUpdateOne) Exec(ctx context.Context) error {
	_, err := puo.Save(ctx)
	return err
}

// ExecX is like Exec, but panics if an error occurs.
func (puo *ProjectUpdateOne) ExecX(ctx context.Context) {
	if err := puo.Exec(ctx); err != nil {
		panic(err)
	}
}

// defaults sets the default values of the builder before save.
func (puo *ProjectUpdateOne) defaults() {
	if _, ok := puo.mutation.UpdatedAt(); !ok && !puo.mutation.UpdatedAtCleared() {
		v := project.UpdateDefaultUpdatedAt()
		puo.mutation.SetUpdatedAt(v)
	}
}

// check runs all checks and user-defined validators on the builder.
func (puo *ProjectUpdateOne) check() error {
	if v, ok := puo.mutation.Name(); ok {
		if err := project.NameValidator(v); err != nil {
			return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Project.name": %w`, err)}
		}
	}
	if v, ok := puo.mutation.Identifier(); ok {
		if err := project.IdentifierValidator(v); err != nil {
			return &ValidationError{Name: "identifier", err: fmt.Errorf(`ent: validator failed for field "Project.identifier": %w`, err)}
		}
	}
	return nil
}

func (puo *ProjectUpdateOne) sqlSave(ctx context.Context) (_node *Project, err error) {
	if err := puo.check(); err != nil {
		return _node, err
	}
	_spec := sqlgraph.NewUpdateSpec(project.Table, project.Columns, sqlgraph.NewFieldSpec(project.FieldID, field.TypeInt64))
	id, ok := puo.mutation.ID()
	if !ok {
		return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Project.id" for update`)}
	}
	_spec.Node.ID.Value = id
	if fields := puo.fields; len(fields) > 0 {
		_spec.Node.Columns = make([]string, 0, len(fields))
		_spec.Node.Columns = append(_spec.Node.Columns, project.FieldID)
		for _, f := range fields {
			if !project.ValidColumn(f) {
				return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
			}
			if f != project.FieldID {
				_spec.Node.Columns = append(_spec.Node.Columns, f)
			}
		}
	}
	if ps := puo.mutation.predicates; len(ps) > 0 {
		_spec.Predicate = func(selector *sql.Selector) {
			for i := range ps {
				ps[i](selector)
			}
		}
	}
	if value, ok := puo.mutation.Name(); ok {
		_spec.SetField(project.FieldName, field.TypeString, value)
	}
	if value, ok := puo.mutation.Identifier(); ok {
		_spec.SetField(project.FieldIdentifier, field.TypeString, value)
	}
	if value, ok := puo.mutation.UpdatedAt(); ok {
		_spec.SetField(project.FieldUpdatedAt, field.TypeTime, value)
	}
	if puo.mutation.UpdatedAtCleared() {
		_spec.ClearField(project.FieldUpdatedAt, field.TypeTime)
	}
	if value, ok := puo.mutation.UpdatedBy(); ok {
		_spec.SetField(project.FieldUpdatedBy, field.TypeUint32, value)
	}
	if value, ok := puo.mutation.AddedUpdatedBy(); ok {
		_spec.AddField(project.FieldUpdatedBy, field.TypeUint32, value)
	}
	if puo.mutation.UpdatedByCleared() {
		_spec.ClearField(project.FieldUpdatedBy, field.TypeUint32)
	}
	if value, ok := puo.mutation.DeletedAt(); ok {
		_spec.SetField(project.FieldDeletedAt, field.TypeTime, value)
	}
	if puo.mutation.DeletedAtCleared() {
		_spec.ClearField(project.FieldDeletedAt, field.TypeTime)
	}
	if value, ok := puo.mutation.DeletedBy(); ok {
		_spec.SetField(project.FieldDeletedBy, field.TypeUint32, value)
	}
	if value, ok := puo.mutation.AddedDeletedBy(); ok {
		_spec.AddField(project.FieldDeletedBy, field.TypeUint32, value)
	}
	if puo.mutation.DeletedByCleared() {
		_spec.ClearField(project.FieldDeletedBy, field.TypeUint32)
	}
	if value, ok := puo.mutation.Status(); ok {
		_spec.SetField(project.FieldStatus, field.TypeInt8, value)
	}
	if value, ok := puo.mutation.AddedStatus(); ok {
		_spec.AddField(project.FieldStatus, field.TypeInt8, value)
	}
	if value, ok := puo.mutation.StartTime(); ok {
		_spec.SetField(project.FieldStartTime, field.TypeTime, value)
	}
	if puo.mutation.StartTimeCleared() {
		_spec.ClearField(project.FieldStartTime, field.TypeTime)
	}
	if value, ok := puo.mutation.Deadline(); ok {
		_spec.SetField(project.FieldDeadline, field.TypeTime, value)
	}
	if puo.mutation.DeadlineCleared() {
		_spec.ClearField(project.FieldDeadline, field.TypeTime)
	}
	if value, ok := puo.mutation.Description(); ok {
		_spec.SetField(project.FieldDescription, field.TypeString, value)
	}
	if puo.mutation.DescriptionCleared() {
		_spec.ClearField(project.FieldDescription, field.TypeString)
	}
	if value, ok := puo.mutation.Remark(); ok {
		_spec.SetField(project.FieldRemark, field.TypeString, value)
	}
	if puo.mutation.RemarkCleared() {
		_spec.ClearField(project.FieldRemark, field.TypeString)
	}
	_node = &Project{config: puo.config}
	_spec.Assign = _node.assignValues
	_spec.ScanValues = _node.scanValues
	if err = sqlgraph.UpdateNode(ctx, puo.driver, _spec); err != nil {
		if _, ok := err.(*sqlgraph.NotFoundError); ok {
			err = &NotFoundError{project.Label}
		} else if sqlgraph.IsConstraintError(err) {
			err = &ConstraintError{msg: err.Error(), wrap: err}
		}
		return nil, err
	}
	puo.mutation.done = true
	return _node, nil
}
