// Code generated by ent, DO NOT EDIT.

package ent

import (
	"context"
	"errors"
	"fmt"

	"entgo.io/ent/dialect/sql"
	"entgo.io/ent/dialect/sql/sqlgraph"
	"entgo.io/ent/schema/field"
	"github.com/Wei-Shaw/sub2api/ent/predicate"
	"github.com/Wei-Shaw/sub2api/ent/requestcapturelog"
)

// RequestCaptureLogUpdate is the builder for updating RequestCaptureLog entities.
type RequestCaptureLogUpdate struct {
	config
	hooks    []Hook
	mutation *RequestCaptureLogMutation
}

// Where appends a list predicates to the RequestCaptureLogUpdate builder.
func (_u *RequestCaptureLogUpdate) Where(ps ...predicate.RequestCaptureLog) *RequestCaptureLogUpdate {
	_u.mutation.Where(ps...)
	return _u
}

// SetAPIKeyID sets the "api_key_id" field.
func (_u *RequestCaptureLogUpdate) SetAPIKeyID(v int64) *RequestCaptureLogUpdate {
	_u.mutation.ResetAPIKeyID()
	_u.mutation.SetAPIKeyID(v)
	return _u
}

// SetNillableAPIKeyID sets the "api_key_id" field if the given value is not nil.
func (_u *RequestCaptureLogUpdate) SetNillableAPIKeyID(v *int64) *RequestCaptureLogUpdate {
	if v != nil {
		_u.SetAPIKeyID(*v)
	}
	return _u
}

// AddAPIKeyID adds value to the "api_key_id" field.
func (_u *RequestCaptureLogUpdate) AddAPIKeyID(v int64) *RequestCaptureLogUpdate {
	_u.mutation.AddAPIKeyID(v)
	return _u
}

// SetUserID sets the "user_id" field.
func (_u *RequestCaptureLogUpdate) SetUserID(v int64) *RequestCaptureLogUpdate {
	_u.mutation.ResetUserID()
	_u.mutation.SetUserID(v)
	return _u
}

// SetNillableUserID sets the "user_id" field if the given value is not nil.
func (_u *RequestCaptureLogUpdate) SetNillableUserID(v *int64) *RequestCaptureLogUpdate {
	if v != nil {
		_u.SetUserID(*v)
	}
	return _u
}

// AddUserID adds value to the "user_id" field.
func (_u *RequestCaptureLogUpdate) AddUserID(v int64) *RequestCaptureLogUpdate {
	_u.mutation.AddUserID(v)
	return _u
}

// SetRequestID sets the "request_id" field.
func (_u *RequestCaptureLogUpdate) SetRequestID(v string) *RequestCaptureLogUpdate {
	_u.mutation.SetRequestID(v)
	return _u
}

// SetNillableRequestID sets the "request_id" field if the given value is not nil.
func (_u *RequestCaptureLogUpdate) SetNillableRequestID(v *string) *RequestCaptureLogUpdate {
	if v != nil {
		_u.SetRequestID(*v)
	}
	return _u
}

// ClearRequestID clears the value of the "request_id" field.
func (_u *RequestCaptureLogUpdate) ClearRequestID() *RequestCaptureLogUpdate {
	_u.mutation.ClearRequestID()
	return _u
}

// SetPath sets the "path" field.
func (_u *RequestCaptureLogUpdate) SetPath(v string) *RequestCaptureLogUpdate {
	_u.mutation.SetPath(v)
	return _u
}

// SetNillablePath sets the "path" field if the given value is not nil.
func (_u *RequestCaptureLogUpdate) SetNillablePath(v *string) *RequestCaptureLogUpdate {
	if v != nil {
		_u.SetPath(*v)
	}
	return _u
}

// ClearPath clears the value of the "path" field.
func (_u *RequestCaptureLogUpdate) ClearPath() *RequestCaptureLogUpdate {
	_u.mutation.ClearPath()
	return _u
}

// SetMethod sets the "method" field.
func (_u *RequestCaptureLogUpdate) SetMethod(v string) *RequestCaptureLogUpdate {
	_u.mutation.SetMethod(v)
	return _u
}

// SetNillableMethod sets the "method" field if the given value is not nil.
func (_u *RequestCaptureLogUpdate) SetNillableMethod(v *string) *RequestCaptureLogUpdate {
	if v != nil {
		_u.SetMethod(*v)
	}
	return _u
}

// ClearMethod clears the value of the "method" field.
func (_u *RequestCaptureLogUpdate) ClearMethod() *RequestCaptureLogUpdate {
	_u.mutation.ClearMethod()
	return _u
}

// SetIPAddress sets the "ip_address" field.
func (_u *RequestCaptureLogUpdate) SetIPAddress(v string) *RequestCaptureLogUpdate {
	_u.mutation.SetIPAddress(v)
	return _u
}

// SetNillableIPAddress sets the "ip_address" field if the given value is not nil.
func (_u *RequestCaptureLogUpdate) SetNillableIPAddress(v *string) *RequestCaptureLogUpdate {
	if v != nil {
		_u.SetIPAddress(*v)
	}
	return _u
}

// ClearIPAddress clears the value of the "ip_address" field.
func (_u *RequestCaptureLogUpdate) ClearIPAddress() *RequestCaptureLogUpdate {
	_u.mutation.ClearIPAddress()
	return _u
}

// SetRequestBody sets the "request_body" field.
func (_u *RequestCaptureLogUpdate) SetRequestBody(v string) *RequestCaptureLogUpdate {
	_u.mutation.SetRequestBody(v)
	return _u
}

// SetNillableRequestBody sets the "request_body" field if the given value is not nil.
func (_u *RequestCaptureLogUpdate) SetNillableRequestBody(v *string) *RequestCaptureLogUpdate {
	if v != nil {
		_u.SetRequestBody(*v)
	}
	return _u
}

// ClearRequestBody clears the value of the "request_body" field.
func (_u *RequestCaptureLogUpdate) ClearRequestBody() *RequestCaptureLogUpdate {
	_u.mutation.ClearRequestBody()
	return _u
}

// SetResponseBody sets the "response_body" field.
func (_u *RequestCaptureLogUpdate) SetResponseBody(v string) *RequestCaptureLogUpdate {
	_u.mutation.SetResponseBody(v)
	return _u
}

// SetNillableResponseBody sets the "response_body" field if the given value is not nil.
func (_u *RequestCaptureLogUpdate) SetNillableResponseBody(v *string) *RequestCaptureLogUpdate {
	if v != nil {
		_u.SetResponseBody(*v)
	}
	return _u
}

// ClearResponseBody clears the value of the "response_body" field.
func (_u *RequestCaptureLogUpdate) ClearResponseBody() *RequestCaptureLogUpdate {
	_u.mutation.ClearResponseBody()
	return _u
}

// SetNfsFilePath sets the "nfs_file_path" field.
func (_u *RequestCaptureLogUpdate) SetNfsFilePath(v string) *RequestCaptureLogUpdate {
	_u.mutation.SetNfsFilePath(v)
	return _u
}

// SetNillableNfsFilePath sets the "nfs_file_path" field if the given value is not nil.
func (_u *RequestCaptureLogUpdate) SetNillableNfsFilePath(v *string) *RequestCaptureLogUpdate {
	if v != nil {
		_u.SetNfsFilePath(*v)
	}
	return _u
}

// ClearNfsFilePath clears the value of the "nfs_file_path" field.
func (_u *RequestCaptureLogUpdate) ClearNfsFilePath() *RequestCaptureLogUpdate {
	_u.mutation.ClearNfsFilePath()
	return _u
}

// Mutation returns the RequestCaptureLogMutation object of the builder.
func (_u *RequestCaptureLogUpdate) Mutation() *RequestCaptureLogMutation {
	return _u.mutation
}

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

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

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

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

// check runs all checks and user-defined validators on the builder.
func (_u *RequestCaptureLogUpdate) check() error {
	if v, ok := _u.mutation.RequestID(); ok {
		if err := requestcapturelog.RequestIDValidator(v); err != nil {
			return &ValidationError{Name: "request_id", err: fmt.Errorf(`ent: validator failed for field "RequestCaptureLog.request_id": %w`, err)}
		}
	}
	if v, ok := _u.mutation.Path(); ok {
		if err := requestcapturelog.PathValidator(v); err != nil {
			return &ValidationError{Name: "path", err: fmt.Errorf(`ent: validator failed for field "RequestCaptureLog.path": %w`, err)}
		}
	}
	if v, ok := _u.mutation.Method(); ok {
		if err := requestcapturelog.MethodValidator(v); err != nil {
			return &ValidationError{Name: "method", err: fmt.Errorf(`ent: validator failed for field "RequestCaptureLog.method": %w`, err)}
		}
	}
	if v, ok := _u.mutation.IPAddress(); ok {
		if err := requestcapturelog.IPAddressValidator(v); err != nil {
			return &ValidationError{Name: "ip_address", err: fmt.Errorf(`ent: validator failed for field "RequestCaptureLog.ip_address": %w`, err)}
		}
	}
	if v, ok := _u.mutation.NfsFilePath(); ok {
		if err := requestcapturelog.NfsFilePathValidator(v); err != nil {
			return &ValidationError{Name: "nfs_file_path", err: fmt.Errorf(`ent: validator failed for field "RequestCaptureLog.nfs_file_path": %w`, err)}
		}
	}
	return nil
}

func (_u *RequestCaptureLogUpdate) sqlSave(ctx context.Context) (_node int, err error) {
	if err := _u.check(); err != nil {
		return _node, err
	}
	_spec := sqlgraph.NewUpdateSpec(requestcapturelog.Table, requestcapturelog.Columns, sqlgraph.NewFieldSpec(requestcapturelog.FieldID, field.TypeInt64))
	if ps := _u.mutation.predicates; len(ps) > 0 {
		_spec.Predicate = func(selector *sql.Selector) {
			for i := range ps {
				ps[i](selector)
			}
		}
	}
	if value, ok := _u.mutation.APIKeyID(); ok {
		_spec.SetField(requestcapturelog.FieldAPIKeyID, field.TypeInt64, value)
	}
	if value, ok := _u.mutation.AddedAPIKeyID(); ok {
		_spec.AddField(requestcapturelog.FieldAPIKeyID, field.TypeInt64, value)
	}
	if value, ok := _u.mutation.UserID(); ok {
		_spec.SetField(requestcapturelog.FieldUserID, field.TypeInt64, value)
	}
	if value, ok := _u.mutation.AddedUserID(); ok {
		_spec.AddField(requestcapturelog.FieldUserID, field.TypeInt64, value)
	}
	if value, ok := _u.mutation.RequestID(); ok {
		_spec.SetField(requestcapturelog.FieldRequestID, field.TypeString, value)
	}
	if _u.mutation.RequestIDCleared() {
		_spec.ClearField(requestcapturelog.FieldRequestID, field.TypeString)
	}
	if value, ok := _u.mutation.Path(); ok {
		_spec.SetField(requestcapturelog.FieldPath, field.TypeString, value)
	}
	if _u.mutation.PathCleared() {
		_spec.ClearField(requestcapturelog.FieldPath, field.TypeString)
	}
	if value, ok := _u.mutation.Method(); ok {
		_spec.SetField(requestcapturelog.FieldMethod, field.TypeString, value)
	}
	if _u.mutation.MethodCleared() {
		_spec.ClearField(requestcapturelog.FieldMethod, field.TypeString)
	}
	if value, ok := _u.mutation.IPAddress(); ok {
		_spec.SetField(requestcapturelog.FieldIPAddress, field.TypeString, value)
	}
	if _u.mutation.IPAddressCleared() {
		_spec.ClearField(requestcapturelog.FieldIPAddress, field.TypeString)
	}
	if value, ok := _u.mutation.RequestBody(); ok {
		_spec.SetField(requestcapturelog.FieldRequestBody, field.TypeString, value)
	}
	if _u.mutation.RequestBodyCleared() {
		_spec.ClearField(requestcapturelog.FieldRequestBody, field.TypeString)
	}
	if value, ok := _u.mutation.ResponseBody(); ok {
		_spec.SetField(requestcapturelog.FieldResponseBody, field.TypeString, value)
	}
	if _u.mutation.ResponseBodyCleared() {
		_spec.ClearField(requestcapturelog.FieldResponseBody, field.TypeString)
	}
	if value, ok := _u.mutation.NfsFilePath(); ok {
		_spec.SetField(requestcapturelog.FieldNfsFilePath, field.TypeString, value)
	}
	if _u.mutation.NfsFilePathCleared() {
		_spec.ClearField(requestcapturelog.FieldNfsFilePath, field.TypeString)
	}
	if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
		if _, ok := err.(*sqlgraph.NotFoundError); ok {
			err = &NotFoundError{requestcapturelog.Label}
		} else if sqlgraph.IsConstraintError(err) {
			err = &ConstraintError{msg: err.Error(), wrap: err}
		}
		return 0, err
	}
	_u.mutation.done = true
	return _node, nil
}

// RequestCaptureLogUpdateOne is the builder for updating a single RequestCaptureLog entity.
type RequestCaptureLogUpdateOne struct {
	config
	fields   []string
	hooks    []Hook
	mutation *RequestCaptureLogMutation
}

// SetAPIKeyID sets the "api_key_id" field.
func (_u *RequestCaptureLogUpdateOne) SetAPIKeyID(v int64) *RequestCaptureLogUpdateOne {
	_u.mutation.ResetAPIKeyID()
	_u.mutation.SetAPIKeyID(v)
	return _u
}

// SetNillableAPIKeyID sets the "api_key_id" field if the given value is not nil.
func (_u *RequestCaptureLogUpdateOne) SetNillableAPIKeyID(v *int64) *RequestCaptureLogUpdateOne {
	if v != nil {
		_u.SetAPIKeyID(*v)
	}
	return _u
}

// AddAPIKeyID adds value to the "api_key_id" field.
func (_u *RequestCaptureLogUpdateOne) AddAPIKeyID(v int64) *RequestCaptureLogUpdateOne {
	_u.mutation.AddAPIKeyID(v)
	return _u
}

// SetUserID sets the "user_id" field.
func (_u *RequestCaptureLogUpdateOne) SetUserID(v int64) *RequestCaptureLogUpdateOne {
	_u.mutation.ResetUserID()
	_u.mutation.SetUserID(v)
	return _u
}

// SetNillableUserID sets the "user_id" field if the given value is not nil.
func (_u *RequestCaptureLogUpdateOne) SetNillableUserID(v *int64) *RequestCaptureLogUpdateOne {
	if v != nil {
		_u.SetUserID(*v)
	}
	return _u
}

// AddUserID adds value to the "user_id" field.
func (_u *RequestCaptureLogUpdateOne) AddUserID(v int64) *RequestCaptureLogUpdateOne {
	_u.mutation.AddUserID(v)
	return _u
}

// SetRequestID sets the "request_id" field.
func (_u *RequestCaptureLogUpdateOne) SetRequestID(v string) *RequestCaptureLogUpdateOne {
	_u.mutation.SetRequestID(v)
	return _u
}

// SetNillableRequestID sets the "request_id" field if the given value is not nil.
func (_u *RequestCaptureLogUpdateOne) SetNillableRequestID(v *string) *RequestCaptureLogUpdateOne {
	if v != nil {
		_u.SetRequestID(*v)
	}
	return _u
}

// ClearRequestID clears the value of the "request_id" field.
func (_u *RequestCaptureLogUpdateOne) ClearRequestID() *RequestCaptureLogUpdateOne {
	_u.mutation.ClearRequestID()
	return _u
}

// SetPath sets the "path" field.
func (_u *RequestCaptureLogUpdateOne) SetPath(v string) *RequestCaptureLogUpdateOne {
	_u.mutation.SetPath(v)
	return _u
}

// SetNillablePath sets the "path" field if the given value is not nil.
func (_u *RequestCaptureLogUpdateOne) SetNillablePath(v *string) *RequestCaptureLogUpdateOne {
	if v != nil {
		_u.SetPath(*v)
	}
	return _u
}

// ClearPath clears the value of the "path" field.
func (_u *RequestCaptureLogUpdateOne) ClearPath() *RequestCaptureLogUpdateOne {
	_u.mutation.ClearPath()
	return _u
}

// SetMethod sets the "method" field.
func (_u *RequestCaptureLogUpdateOne) SetMethod(v string) *RequestCaptureLogUpdateOne {
	_u.mutation.SetMethod(v)
	return _u
}

// SetNillableMethod sets the "method" field if the given value is not nil.
func (_u *RequestCaptureLogUpdateOne) SetNillableMethod(v *string) *RequestCaptureLogUpdateOne {
	if v != nil {
		_u.SetMethod(*v)
	}
	return _u
}

// ClearMethod clears the value of the "method" field.
func (_u *RequestCaptureLogUpdateOne) ClearMethod() *RequestCaptureLogUpdateOne {
	_u.mutation.ClearMethod()
	return _u
}

// SetIPAddress sets the "ip_address" field.
func (_u *RequestCaptureLogUpdateOne) SetIPAddress(v string) *RequestCaptureLogUpdateOne {
	_u.mutation.SetIPAddress(v)
	return _u
}

// SetNillableIPAddress sets the "ip_address" field if the given value is not nil.
func (_u *RequestCaptureLogUpdateOne) SetNillableIPAddress(v *string) *RequestCaptureLogUpdateOne {
	if v != nil {
		_u.SetIPAddress(*v)
	}
	return _u
}

// ClearIPAddress clears the value of the "ip_address" field.
func (_u *RequestCaptureLogUpdateOne) ClearIPAddress() *RequestCaptureLogUpdateOne {
	_u.mutation.ClearIPAddress()
	return _u
}

// SetRequestBody sets the "request_body" field.
func (_u *RequestCaptureLogUpdateOne) SetRequestBody(v string) *RequestCaptureLogUpdateOne {
	_u.mutation.SetRequestBody(v)
	return _u
}

// SetNillableRequestBody sets the "request_body" field if the given value is not nil.
func (_u *RequestCaptureLogUpdateOne) SetNillableRequestBody(v *string) *RequestCaptureLogUpdateOne {
	if v != nil {
		_u.SetRequestBody(*v)
	}
	return _u
}

// ClearRequestBody clears the value of the "request_body" field.
func (_u *RequestCaptureLogUpdateOne) ClearRequestBody() *RequestCaptureLogUpdateOne {
	_u.mutation.ClearRequestBody()
	return _u
}

// SetResponseBody sets the "response_body" field.
func (_u *RequestCaptureLogUpdateOne) SetResponseBody(v string) *RequestCaptureLogUpdateOne {
	_u.mutation.SetResponseBody(v)
	return _u
}

// SetNillableResponseBody sets the "response_body" field if the given value is not nil.
func (_u *RequestCaptureLogUpdateOne) SetNillableResponseBody(v *string) *RequestCaptureLogUpdateOne {
	if v != nil {
		_u.SetResponseBody(*v)
	}
	return _u
}

// ClearResponseBody clears the value of the "response_body" field.
func (_u *RequestCaptureLogUpdateOne) ClearResponseBody() *RequestCaptureLogUpdateOne {
	_u.mutation.ClearResponseBody()
	return _u
}

// SetNfsFilePath sets the "nfs_file_path" field.
func (_u *RequestCaptureLogUpdateOne) SetNfsFilePath(v string) *RequestCaptureLogUpdateOne {
	_u.mutation.SetNfsFilePath(v)
	return _u
}

// SetNillableNfsFilePath sets the "nfs_file_path" field if the given value is not nil.
func (_u *RequestCaptureLogUpdateOne) SetNillableNfsFilePath(v *string) *RequestCaptureLogUpdateOne {
	if v != nil {
		_u.SetNfsFilePath(*v)
	}
	return _u
}

// ClearNfsFilePath clears the value of the "nfs_file_path" field.
func (_u *RequestCaptureLogUpdateOne) ClearNfsFilePath() *RequestCaptureLogUpdateOne {
	_u.mutation.ClearNfsFilePath()
	return _u
}

// Mutation returns the RequestCaptureLogMutation object of the builder.
func (_u *RequestCaptureLogUpdateOne) Mutation() *RequestCaptureLogMutation {
	return _u.mutation
}

// Where appends a list predicates to the RequestCaptureLogUpdate builder.
func (_u *RequestCaptureLogUpdateOne) Where(ps ...predicate.RequestCaptureLog) *RequestCaptureLogUpdateOne {
	_u.mutation.Where(ps...)
	return _u
}

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

// Save executes the query and returns the updated RequestCaptureLog entity.
func (_u *RequestCaptureLogUpdateOne) Save(ctx context.Context) (*RequestCaptureLog, error) {
	return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
}

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

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

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

// check runs all checks and user-defined validators on the builder.
func (_u *RequestCaptureLogUpdateOne) check() error {
	if v, ok := _u.mutation.RequestID(); ok {
		if err := requestcapturelog.RequestIDValidator(v); err != nil {
			return &ValidationError{Name: "request_id", err: fmt.Errorf(`ent: validator failed for field "RequestCaptureLog.request_id": %w`, err)}
		}
	}
	if v, ok := _u.mutation.Path(); ok {
		if err := requestcapturelog.PathValidator(v); err != nil {
			return &ValidationError{Name: "path", err: fmt.Errorf(`ent: validator failed for field "RequestCaptureLog.path": %w`, err)}
		}
	}
	if v, ok := _u.mutation.Method(); ok {
		if err := requestcapturelog.MethodValidator(v); err != nil {
			return &ValidationError{Name: "method", err: fmt.Errorf(`ent: validator failed for field "RequestCaptureLog.method": %w`, err)}
		}
	}
	if v, ok := _u.mutation.IPAddress(); ok {
		if err := requestcapturelog.IPAddressValidator(v); err != nil {
			return &ValidationError{Name: "ip_address", err: fmt.Errorf(`ent: validator failed for field "RequestCaptureLog.ip_address": %w`, err)}
		}
	}
	if v, ok := _u.mutation.NfsFilePath(); ok {
		if err := requestcapturelog.NfsFilePathValidator(v); err != nil {
			return &ValidationError{Name: "nfs_file_path", err: fmt.Errorf(`ent: validator failed for field "RequestCaptureLog.nfs_file_path": %w`, err)}
		}
	}
	return nil
}

func (_u *RequestCaptureLogUpdateOne) sqlSave(ctx context.Context) (_node *RequestCaptureLog, err error) {
	if err := _u.check(); err != nil {
		return _node, err
	}
	_spec := sqlgraph.NewUpdateSpec(requestcapturelog.Table, requestcapturelog.Columns, sqlgraph.NewFieldSpec(requestcapturelog.FieldID, field.TypeInt64))
	id, ok := _u.mutation.ID()
	if !ok {
		return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "RequestCaptureLog.id" for update`)}
	}
	_spec.Node.ID.Value = id
	if fields := _u.fields; len(fields) > 0 {
		_spec.Node.Columns = make([]string, 0, len(fields))
		_spec.Node.Columns = append(_spec.Node.Columns, requestcapturelog.FieldID)
		for _, f := range fields {
			if !requestcapturelog.ValidColumn(f) {
				return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
			}
			if f != requestcapturelog.FieldID {
				_spec.Node.Columns = append(_spec.Node.Columns, f)
			}
		}
	}
	if ps := _u.mutation.predicates; len(ps) > 0 {
		_spec.Predicate = func(selector *sql.Selector) {
			for i := range ps {
				ps[i](selector)
			}
		}
	}
	if value, ok := _u.mutation.APIKeyID(); ok {
		_spec.SetField(requestcapturelog.FieldAPIKeyID, field.TypeInt64, value)
	}
	if value, ok := _u.mutation.AddedAPIKeyID(); ok {
		_spec.AddField(requestcapturelog.FieldAPIKeyID, field.TypeInt64, value)
	}
	if value, ok := _u.mutation.UserID(); ok {
		_spec.SetField(requestcapturelog.FieldUserID, field.TypeInt64, value)
	}
	if value, ok := _u.mutation.AddedUserID(); ok {
		_spec.AddField(requestcapturelog.FieldUserID, field.TypeInt64, value)
	}
	if value, ok := _u.mutation.RequestID(); ok {
		_spec.SetField(requestcapturelog.FieldRequestID, field.TypeString, value)
	}
	if _u.mutation.RequestIDCleared() {
		_spec.ClearField(requestcapturelog.FieldRequestID, field.TypeString)
	}
	if value, ok := _u.mutation.Path(); ok {
		_spec.SetField(requestcapturelog.FieldPath, field.TypeString, value)
	}
	if _u.mutation.PathCleared() {
		_spec.ClearField(requestcapturelog.FieldPath, field.TypeString)
	}
	if value, ok := _u.mutation.Method(); ok {
		_spec.SetField(requestcapturelog.FieldMethod, field.TypeString, value)
	}
	if _u.mutation.MethodCleared() {
		_spec.ClearField(requestcapturelog.FieldMethod, field.TypeString)
	}
	if value, ok := _u.mutation.IPAddress(); ok {
		_spec.SetField(requestcapturelog.FieldIPAddress, field.TypeString, value)
	}
	if _u.mutation.IPAddressCleared() {
		_spec.ClearField(requestcapturelog.FieldIPAddress, field.TypeString)
	}
	if value, ok := _u.mutation.RequestBody(); ok {
		_spec.SetField(requestcapturelog.FieldRequestBody, field.TypeString, value)
	}
	if _u.mutation.RequestBodyCleared() {
		_spec.ClearField(requestcapturelog.FieldRequestBody, field.TypeString)
	}
	if value, ok := _u.mutation.ResponseBody(); ok {
		_spec.SetField(requestcapturelog.FieldResponseBody, field.TypeString, value)
	}
	if _u.mutation.ResponseBodyCleared() {
		_spec.ClearField(requestcapturelog.FieldResponseBody, field.TypeString)
	}
	if value, ok := _u.mutation.NfsFilePath(); ok {
		_spec.SetField(requestcapturelog.FieldNfsFilePath, field.TypeString, value)
	}
	if _u.mutation.NfsFilePathCleared() {
		_spec.ClearField(requestcapturelog.FieldNfsFilePath, field.TypeString)
	}
	_node = &RequestCaptureLog{config: _u.config}
	_spec.Assign = _node.assignValues
	_spec.ScanValues = _node.scanValues
	if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
		if _, ok := err.(*sqlgraph.NotFoundError); ok {
			err = &NotFoundError{requestcapturelog.Label}
		} else if sqlgraph.IsConstraintError(err) {
			err = &ConstraintError{msg: err.Error(), wrap: err}
		}
		return nil, err
	}
	_u.mutation.done = true
	return _node, nil
}
