912 lines
21 KiB
Go
912 lines
21 KiB
Go
// Copyright 2019-present Facebook Inc. All rights reserved.
|
|
// This source code is licensed under the Apache 2.0 license found
|
|
// in the LICENSE file in the root directory of this source tree.
|
|
|
|
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package file
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"time"
|
|
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/entc/integration/ent/predicate"
|
|
)
|
|
|
|
// Mutation represents an operation that mutates the File nodes in the graph.
|
|
type Mutation struct {
|
|
op ent.Op
|
|
typ string
|
|
set_id *int
|
|
addset_id *int
|
|
size *int
|
|
addsize *int
|
|
name *string
|
|
user *string
|
|
group *string
|
|
_op *bool
|
|
field_id *int
|
|
addfield_id *int
|
|
create_time *time.Time
|
|
clearedFields map[string]struct{}
|
|
owner *int
|
|
clearedowner bool
|
|
_type *int
|
|
cleared_type bool
|
|
field map[int]struct{}
|
|
removedfield map[int]struct{}
|
|
clearedfield bool
|
|
predicates []predicate.File
|
|
}
|
|
|
|
// NewMutation creates a new Mutation for the File entity.
|
|
func NewMutation(op ent.Op) *Mutation {
|
|
return &Mutation{
|
|
op: op,
|
|
typ: "File",
|
|
clearedFields: make(map[string]struct{}),
|
|
}
|
|
}
|
|
|
|
// Predicates returns the list of predicates set on the mutation.
|
|
func (m *Mutation) Predicates() []predicate.File {
|
|
return m.predicates
|
|
}
|
|
|
|
// SetSetID sets the "set_id" field.
|
|
func (m *Mutation) SetSetID(i int) {
|
|
m.set_id = &i
|
|
m.addset_id = nil
|
|
}
|
|
|
|
// SetID returns the value of the "set_id" field in the mutation.
|
|
func (m *Mutation) SetID() (r int, exists bool) {
|
|
v := m.set_id
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// AddSetID adds i to the "set_id" field.
|
|
func (m *Mutation) AddSetID(i int) {
|
|
if m.addset_id != nil {
|
|
*m.addset_id += i
|
|
} else {
|
|
m.addset_id = &i
|
|
}
|
|
}
|
|
|
|
// AddedSetID returns the value that was added to the "set_id" field in this mutation.
|
|
func (m *Mutation) AddedSetID() (r int, exists bool) {
|
|
v := m.addset_id
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// ClearSetID clears the value of the "set_id" field.
|
|
func (m *Mutation) ClearSetID() {
|
|
m.set_id = nil
|
|
m.addset_id = nil
|
|
m.clearedFields[FieldSetID] = struct{}{}
|
|
}
|
|
|
|
// SetIDCleared returns if the "set_id" field was cleared in this mutation.
|
|
func (m *Mutation) SetIDCleared() bool {
|
|
_, ok := m.clearedFields[FieldSetID]
|
|
return ok
|
|
}
|
|
|
|
// ResetSetID resets all changes to the "set_id" field.
|
|
func (m *Mutation) ResetSetID() {
|
|
m.set_id = nil
|
|
m.addset_id = nil
|
|
delete(m.clearedFields, FieldSetID)
|
|
}
|
|
|
|
// SetSize sets the "size" field.
|
|
func (m *Mutation) SetSize(i int) {
|
|
m.size = &i
|
|
m.addsize = nil
|
|
}
|
|
|
|
// Size returns the value of the "size" field in the mutation.
|
|
func (m *Mutation) Size() (r int, exists bool) {
|
|
v := m.size
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// AddSize adds i to the "size" field.
|
|
func (m *Mutation) AddSize(i int) {
|
|
if m.addsize != nil {
|
|
*m.addsize += i
|
|
} else {
|
|
m.addsize = &i
|
|
}
|
|
}
|
|
|
|
// AddedSize returns the value that was added to the "size" field in this mutation.
|
|
func (m *Mutation) AddedSize() (r int, exists bool) {
|
|
v := m.addsize
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// ResetSize resets all changes to the "size" field.
|
|
func (m *Mutation) ResetSize() {
|
|
m.size = nil
|
|
m.addsize = nil
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (m *Mutation) SetName(s string) {
|
|
m.name = &s
|
|
}
|
|
|
|
// Name returns the value of the "name" field in the mutation.
|
|
func (m *Mutation) Name() (r string, exists bool) {
|
|
v := m.name
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// ResetName resets all changes to the "name" field.
|
|
func (m *Mutation) ResetName() {
|
|
m.name = nil
|
|
}
|
|
|
|
// SetUser sets the "user" field.
|
|
func (m *Mutation) SetUser(s string) {
|
|
m.user = &s
|
|
}
|
|
|
|
// User returns the value of the "user" field in the mutation.
|
|
func (m *Mutation) User() (r string, exists bool) {
|
|
v := m.user
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// ClearUser clears the value of the "user" field.
|
|
func (m *Mutation) ClearUser() {
|
|
m.user = nil
|
|
m.clearedFields[FieldUser] = struct{}{}
|
|
}
|
|
|
|
// UserCleared returns if the "user" field was cleared in this mutation.
|
|
func (m *Mutation) UserCleared() bool {
|
|
_, ok := m.clearedFields[FieldUser]
|
|
return ok
|
|
}
|
|
|
|
// ResetUser resets all changes to the "user" field.
|
|
func (m *Mutation) ResetUser() {
|
|
m.user = nil
|
|
delete(m.clearedFields, FieldUser)
|
|
}
|
|
|
|
// SetGroup sets the "group" field.
|
|
func (m *Mutation) SetGroup(s string) {
|
|
m.group = &s
|
|
}
|
|
|
|
// Group returns the value of the "group" field in the mutation.
|
|
func (m *Mutation) Group() (r string, exists bool) {
|
|
v := m.group
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// ClearGroup clears the value of the "group" field.
|
|
func (m *Mutation) ClearGroup() {
|
|
m.group = nil
|
|
m.clearedFields[FieldGroup] = struct{}{}
|
|
}
|
|
|
|
// GroupCleared returns if the "group" field was cleared in this mutation.
|
|
func (m *Mutation) GroupCleared() bool {
|
|
_, ok := m.clearedFields[FieldGroup]
|
|
return ok
|
|
}
|
|
|
|
// ResetGroup resets all changes to the "group" field.
|
|
func (m *Mutation) ResetGroup() {
|
|
m.group = nil
|
|
delete(m.clearedFields, FieldGroup)
|
|
}
|
|
|
|
// SetOpField sets the "op" field.
|
|
func (m *Mutation) SetOpField(b bool) {
|
|
m._op = &b
|
|
}
|
|
|
|
// GetOp returns the value of the "op" field in the mutation.
|
|
func (m *Mutation) GetOp() (r bool, exists bool) {
|
|
v := m._op
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// ClearOp clears the value of the "op" field.
|
|
func (m *Mutation) ClearOp() {
|
|
m._op = nil
|
|
m.clearedFields[FieldOp] = struct{}{}
|
|
}
|
|
|
|
// OpCleared returns if the "op" field was cleared in this mutation.
|
|
func (m *Mutation) OpCleared() bool {
|
|
_, ok := m.clearedFields[FieldOp]
|
|
return ok
|
|
}
|
|
|
|
// ResetOp resets all changes to the "op" field.
|
|
func (m *Mutation) ResetOp() {
|
|
m._op = nil
|
|
delete(m.clearedFields, FieldOp)
|
|
}
|
|
|
|
// SetFieldID sets the "field_id" field.
|
|
func (m *Mutation) SetFieldID(i int) {
|
|
m.field_id = &i
|
|
m.addfield_id = nil
|
|
}
|
|
|
|
// FieldID returns the value of the "field_id" field in the mutation.
|
|
func (m *Mutation) FieldID() (r int, exists bool) {
|
|
v := m.field_id
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// AddFieldID adds i to the "field_id" field.
|
|
func (m *Mutation) AddFieldID(i int) {
|
|
if m.addfield_id != nil {
|
|
*m.addfield_id += i
|
|
} else {
|
|
m.addfield_id = &i
|
|
}
|
|
}
|
|
|
|
// AddedFieldID returns the value that was added to the "field_id" field in this mutation.
|
|
func (m *Mutation) AddedFieldID() (r int, exists bool) {
|
|
v := m.addfield_id
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// ClearFieldID clears the value of the "field_id" field.
|
|
func (m *Mutation) ClearFieldID() {
|
|
m.field_id = nil
|
|
m.addfield_id = nil
|
|
m.clearedFields[FieldFieldID] = struct{}{}
|
|
}
|
|
|
|
// FieldIDCleared returns if the "field_id" field was cleared in this mutation.
|
|
func (m *Mutation) FieldIDCleared() bool {
|
|
_, ok := m.clearedFields[FieldFieldID]
|
|
return ok
|
|
}
|
|
|
|
// ResetFieldID resets all changes to the "field_id" field.
|
|
func (m *Mutation) ResetFieldID() {
|
|
m.field_id = nil
|
|
m.addfield_id = nil
|
|
delete(m.clearedFields, FieldFieldID)
|
|
}
|
|
|
|
// SetCreateTime sets the "create_time" field.
|
|
func (m *Mutation) SetCreateTime(t time.Time) {
|
|
m.create_time = &t
|
|
}
|
|
|
|
// CreateTime returns the value of the "create_time" field in the mutation.
|
|
func (m *Mutation) CreateTime() (r time.Time, exists bool) {
|
|
v := m.create_time
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// ClearCreateTime clears the value of the "create_time" field.
|
|
func (m *Mutation) ClearCreateTime() {
|
|
m.create_time = nil
|
|
m.clearedFields[FieldCreateTime] = struct{}{}
|
|
}
|
|
|
|
// CreateTimeCleared returns if the "create_time" field was cleared in this mutation.
|
|
func (m *Mutation) CreateTimeCleared() bool {
|
|
_, ok := m.clearedFields[FieldCreateTime]
|
|
return ok
|
|
}
|
|
|
|
// ResetCreateTime resets all changes to the "create_time" field.
|
|
func (m *Mutation) ResetCreateTime() {
|
|
m.create_time = nil
|
|
delete(m.clearedFields, FieldCreateTime)
|
|
}
|
|
|
|
// SetOwnerID sets the "owner" edge to the User entity by id.
|
|
func (m *Mutation) SetOwnerID(id int) {
|
|
m.owner = &id
|
|
}
|
|
|
|
// ClearOwner clears the "owner" edge to the User entity.
|
|
func (m *Mutation) ClearOwner() {
|
|
m.clearedowner = true
|
|
}
|
|
|
|
// OwnerCleared reports if the "owner" edge to the User entity was cleared.
|
|
func (m *Mutation) OwnerCleared() bool {
|
|
return m.clearedowner
|
|
}
|
|
|
|
// OwnerID returns the "owner" edge ID in the mutation.
|
|
func (m *Mutation) OwnerID() (id int, exists bool) {
|
|
if m.owner != nil {
|
|
return *m.owner, true
|
|
}
|
|
return
|
|
}
|
|
|
|
// OwnerIDs returns the "owner" edge IDs in the mutation.
|
|
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
|
|
// OwnerID instead. It exists only for internal usage by the builders.
|
|
func (m *Mutation) OwnerIDs() (ids []int) {
|
|
if id := m.owner; id != nil {
|
|
ids = append(ids, *id)
|
|
}
|
|
return
|
|
}
|
|
|
|
// ResetOwner resets all changes to the "owner" edge.
|
|
func (m *Mutation) ResetOwner() {
|
|
m.owner = nil
|
|
m.clearedowner = false
|
|
}
|
|
|
|
// SetTypeID sets the "type" edge to the FileType entity by id.
|
|
func (m *Mutation) SetTypeID(id int) {
|
|
m._type = &id
|
|
}
|
|
|
|
// ClearType clears the "type" edge to the FileType entity.
|
|
func (m *Mutation) ClearType() {
|
|
m.cleared_type = true
|
|
}
|
|
|
|
// TypeCleared reports if the "type" edge to the FileType entity was cleared.
|
|
func (m *Mutation) TypeCleared() bool {
|
|
return m.cleared_type
|
|
}
|
|
|
|
// TypeID returns the "type" edge ID in the mutation.
|
|
func (m *Mutation) TypeID() (id int, exists bool) {
|
|
if m._type != nil {
|
|
return *m._type, true
|
|
}
|
|
return
|
|
}
|
|
|
|
// TypeIDs returns the "type" edge IDs in the mutation.
|
|
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
|
|
// TypeID instead. It exists only for internal usage by the builders.
|
|
func (m *Mutation) TypeIDs() (ids []int) {
|
|
if id := m._type; id != nil {
|
|
ids = append(ids, *id)
|
|
}
|
|
return
|
|
}
|
|
|
|
// ResetType resets all changes to the "type" edge.
|
|
func (m *Mutation) ResetType() {
|
|
m._type = nil
|
|
m.cleared_type = false
|
|
}
|
|
|
|
// AddFieldIDs adds the "field" edge to the FieldType entity by ids.
|
|
func (m *Mutation) AddFieldIDs(ids ...int) {
|
|
if m.field == nil {
|
|
m.field = make(map[int]struct{})
|
|
}
|
|
for i := range ids {
|
|
m.field[ids[i]] = struct{}{}
|
|
}
|
|
}
|
|
|
|
// ClearFieldEdge clears the "field" edge to the FieldType entity.
|
|
func (m *Mutation) ClearFieldEdge() {
|
|
m.clearedfield = true
|
|
}
|
|
|
|
// FieldEdgeCleared reports if the "field" edge to the FieldType entity was cleared.
|
|
func (m *Mutation) FieldEdgeCleared() bool {
|
|
return m.clearedfield
|
|
}
|
|
|
|
// RemoveFieldIDs removes the "field" edge to the FieldType entity by IDs.
|
|
func (m *Mutation) RemoveFieldIDs(ids ...int) {
|
|
if m.removedfield == nil {
|
|
m.removedfield = make(map[int]struct{})
|
|
}
|
|
for i := range ids {
|
|
delete(m.field, ids[i])
|
|
m.removedfield[ids[i]] = struct{}{}
|
|
}
|
|
}
|
|
|
|
// RemovedField returns the removed IDs of the "field" edge to the FieldType entity.
|
|
func (m *Mutation) RemovedFieldIDs() (ids []int) {
|
|
for id := range m.removedfield {
|
|
ids = append(ids, id)
|
|
}
|
|
return
|
|
}
|
|
|
|
// FieldIDs returns the "field" edge IDs in the mutation.
|
|
func (m *Mutation) FieldIDs() (ids []int) {
|
|
for id := range m.field {
|
|
ids = append(ids, id)
|
|
}
|
|
return
|
|
}
|
|
|
|
// ResetFieldEdge resets all changes to the "field" edge.
|
|
func (m *Mutation) ResetFieldEdge() {
|
|
m.field = nil
|
|
m.clearedfield = false
|
|
m.removedfield = nil
|
|
}
|
|
|
|
// Where appends a list predicates to the Mutation builder.
|
|
func (m *Mutation) Where(ps ...predicate.File) {
|
|
m.predicates = append(m.predicates, ps...)
|
|
}
|
|
|
|
// WhereP appends storage-level predicates to the Mutation builder. Using this method,
|
|
// users can use type-assertion to append predicates that do not depend on any generated package.
|
|
func (m *Mutation) WhereP(ps ...func(*sql.Selector)) {
|
|
p := make([]predicate.File, len(ps))
|
|
for i := range ps {
|
|
p[i] = ps[i]
|
|
}
|
|
m.Where(p...)
|
|
}
|
|
|
|
// Op returns the operation name.
|
|
func (m *Mutation) Op() ent.Op {
|
|
return m.op
|
|
}
|
|
|
|
// SetOp allows setting the mutation operation.
|
|
func (m *Mutation) SetOp(op ent.Op) {
|
|
m.op = op
|
|
}
|
|
|
|
// Type returns the node type of this mutation (File).
|
|
func (m *Mutation) Type() string {
|
|
return m.typ
|
|
}
|
|
|
|
// Fields returns all fields that were changed during this mutation. Note that in
|
|
// order to get all numeric fields that were incremented/decremented, call
|
|
// AddedFields().
|
|
func (m *Mutation) Fields() []string {
|
|
fields := make([]string, 0, 8)
|
|
if m.set_id != nil {
|
|
fields = append(fields, FieldSetID)
|
|
}
|
|
if m.size != nil {
|
|
fields = append(fields, FieldSize)
|
|
}
|
|
if m.name != nil {
|
|
fields = append(fields, FieldName)
|
|
}
|
|
if m.user != nil {
|
|
fields = append(fields, FieldUser)
|
|
}
|
|
if m.group != nil {
|
|
fields = append(fields, FieldGroup)
|
|
}
|
|
if m._op != nil {
|
|
fields = append(fields, FieldOp)
|
|
}
|
|
if m.field_id != nil {
|
|
fields = append(fields, FieldFieldID)
|
|
}
|
|
if m.create_time != nil {
|
|
fields = append(fields, FieldCreateTime)
|
|
}
|
|
return fields
|
|
}
|
|
|
|
// Field returns the value of a field with the given name. The second boolean
|
|
// return value indicates that this field was not set, or was not defined in the
|
|
// schema.
|
|
func (m *Mutation) Field(name string) (ent.Value, bool) {
|
|
switch name {
|
|
case FieldSetID:
|
|
return m.SetID()
|
|
case FieldSize:
|
|
return m.Size()
|
|
case FieldName:
|
|
return m.Name()
|
|
case FieldUser:
|
|
return m.User()
|
|
case FieldGroup:
|
|
return m.Group()
|
|
case FieldOp:
|
|
return m.GetOp()
|
|
case FieldFieldID:
|
|
return m.FieldID()
|
|
case FieldCreateTime:
|
|
return m.CreateTime()
|
|
}
|
|
return nil, false
|
|
}
|
|
|
|
// OldField returns the old value of the field from the database. An error is
|
|
// returned if the mutation operation is not UpdateOne, or the query to the
|
|
// database failed.
|
|
func (m *Mutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
|
return nil, fmt.Errorf("unknown File field %s", name)
|
|
}
|
|
|
|
// SetField sets the value of a field with the given name. It returns an error if
|
|
// the field is not defined in the schema, or if the type mismatched the field
|
|
// type.
|
|
func (m *Mutation) SetField(name string, value ent.Value) error {
|
|
switch name {
|
|
case FieldSetID:
|
|
v, ok := value.(int)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetSetID(v)
|
|
return nil
|
|
case FieldSize:
|
|
v, ok := value.(int)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetSize(v)
|
|
return nil
|
|
case FieldName:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetName(v)
|
|
return nil
|
|
case FieldUser:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetUser(v)
|
|
return nil
|
|
case FieldGroup:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetGroup(v)
|
|
return nil
|
|
case FieldOp:
|
|
v, ok := value.(bool)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetOpField(v)
|
|
return nil
|
|
case FieldFieldID:
|
|
v, ok := value.(int)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetFieldID(v)
|
|
return nil
|
|
case FieldCreateTime:
|
|
v, ok := value.(time.Time)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetCreateTime(v)
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown File field %s", name)
|
|
}
|
|
|
|
// AddedFields returns all numeric fields that were incremented/decremented during
|
|
// this mutation.
|
|
func (m *Mutation) AddedFields() []string {
|
|
var fields []string
|
|
if m.addset_id != nil {
|
|
fields = append(fields, FieldSetID)
|
|
}
|
|
if m.addsize != nil {
|
|
fields = append(fields, FieldSize)
|
|
}
|
|
if m.addfield_id != nil {
|
|
fields = append(fields, FieldFieldID)
|
|
}
|
|
return fields
|
|
}
|
|
|
|
// AddedField returns the numeric value that was incremented/decremented on a field
|
|
// with the given name. The second boolean return value indicates that this field
|
|
// was not set, or was not defined in the schema.
|
|
func (m *Mutation) AddedField(name string) (ent.Value, bool) {
|
|
switch name {
|
|
case FieldSetID:
|
|
return m.AddedSetID()
|
|
case FieldSize:
|
|
return m.AddedSize()
|
|
case FieldFieldID:
|
|
return m.AddedFieldID()
|
|
}
|
|
return nil, false
|
|
}
|
|
|
|
// AddField adds the value to the field with the given name. It returns an error if
|
|
// the field is not defined in the schema, or if the type mismatched the field
|
|
// type.
|
|
func (m *Mutation) AddField(name string, value ent.Value) error {
|
|
switch name {
|
|
case FieldSetID:
|
|
v, ok := value.(int)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.AddSetID(v)
|
|
return nil
|
|
case FieldSize:
|
|
v, ok := value.(int)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.AddSize(v)
|
|
return nil
|
|
case FieldFieldID:
|
|
v, ok := value.(int)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.AddFieldID(v)
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown File numeric field %s", name)
|
|
}
|
|
|
|
// ClearedFields returns all nullable fields that were cleared during this
|
|
// mutation.
|
|
func (m *Mutation) ClearedFields() []string {
|
|
var fields []string
|
|
if m.FieldCleared(FieldSetID) {
|
|
fields = append(fields, FieldSetID)
|
|
}
|
|
if m.FieldCleared(FieldUser) {
|
|
fields = append(fields, FieldUser)
|
|
}
|
|
if m.FieldCleared(FieldGroup) {
|
|
fields = append(fields, FieldGroup)
|
|
}
|
|
if m.FieldCleared(FieldOp) {
|
|
fields = append(fields, FieldOp)
|
|
}
|
|
if m.FieldCleared(FieldFieldID) {
|
|
fields = append(fields, FieldFieldID)
|
|
}
|
|
if m.FieldCleared(FieldCreateTime) {
|
|
fields = append(fields, FieldCreateTime)
|
|
}
|
|
return fields
|
|
}
|
|
|
|
// FieldCleared returns a boolean indicating if a field with the given name was
|
|
// cleared in this mutation.
|
|
func (m *Mutation) FieldCleared(name string) bool {
|
|
_, ok := m.clearedFields[name]
|
|
return ok
|
|
}
|
|
|
|
// ClearField clears the value of the field with the given name. It returns an
|
|
// error if the field is not defined in the schema.
|
|
func (m *Mutation) ClearField(name string) error {
|
|
switch name {
|
|
case FieldSetID:
|
|
m.ClearSetID()
|
|
return nil
|
|
case FieldUser:
|
|
m.ClearUser()
|
|
return nil
|
|
case FieldGroup:
|
|
m.ClearGroup()
|
|
return nil
|
|
case FieldOp:
|
|
m.ClearOp()
|
|
return nil
|
|
case FieldFieldID:
|
|
m.ClearFieldID()
|
|
return nil
|
|
case FieldCreateTime:
|
|
m.ClearCreateTime()
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown File nullable field %s", name)
|
|
}
|
|
|
|
// ResetField resets all changes in the mutation for the field with the given name.
|
|
// It returns an error if the field is not defined in the schema.
|
|
func (m *Mutation) ResetField(name string) error {
|
|
switch name {
|
|
case FieldSetID:
|
|
m.ResetSetID()
|
|
return nil
|
|
case FieldSize:
|
|
m.ResetSize()
|
|
return nil
|
|
case FieldName:
|
|
m.ResetName()
|
|
return nil
|
|
case FieldUser:
|
|
m.ResetUser()
|
|
return nil
|
|
case FieldGroup:
|
|
m.ResetGroup()
|
|
return nil
|
|
case FieldOp:
|
|
m.ResetOp()
|
|
return nil
|
|
case FieldFieldID:
|
|
m.ResetFieldID()
|
|
return nil
|
|
case FieldCreateTime:
|
|
m.ResetCreateTime()
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown File field %s", name)
|
|
}
|
|
|
|
// AddedEdges returns all edge names that were set/added in this mutation.
|
|
func (m *Mutation) AddedEdges() []string {
|
|
edges := make([]string, 0, 3)
|
|
if m.owner != nil {
|
|
edges = append(edges, EdgeOwner)
|
|
}
|
|
if m._type != nil {
|
|
edges = append(edges, EdgeType)
|
|
}
|
|
if m.field != nil {
|
|
edges = append(edges, EdgeField)
|
|
}
|
|
return edges
|
|
}
|
|
|
|
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
|
|
// name in this mutation.
|
|
func (m *Mutation) AddedIDs(name string) []ent.Value {
|
|
switch name {
|
|
case EdgeOwner:
|
|
if id := m.owner; id != nil {
|
|
return []ent.Value{*id}
|
|
}
|
|
case EdgeType:
|
|
if id := m._type; id != nil {
|
|
return []ent.Value{*id}
|
|
}
|
|
case EdgeField:
|
|
ids := make([]ent.Value, 0, len(m.field))
|
|
for id := range m.field {
|
|
ids = append(ids, id)
|
|
}
|
|
return ids
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// RemovedEdges returns all edge names that were removed in this mutation.
|
|
func (m *Mutation) RemovedEdges() []string {
|
|
edges := make([]string, 0, 3)
|
|
if m.removedfield != nil {
|
|
edges = append(edges, EdgeField)
|
|
}
|
|
return edges
|
|
}
|
|
|
|
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
|
|
// the given name in this mutation.
|
|
func (m *Mutation) RemovedIDs(name string) []ent.Value {
|
|
switch name {
|
|
case EdgeField:
|
|
ids := make([]ent.Value, 0, len(m.removedfield))
|
|
for id := range m.removedfield {
|
|
ids = append(ids, id)
|
|
}
|
|
return ids
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// ClearedEdges returns all edge names that were cleared in this mutation.
|
|
func (m *Mutation) ClearedEdges() []string {
|
|
edges := make([]string, 0, 3)
|
|
if m.clearedowner {
|
|
edges = append(edges, EdgeOwner)
|
|
}
|
|
if m.cleared_type {
|
|
edges = append(edges, EdgeType)
|
|
}
|
|
if m.clearedfield {
|
|
edges = append(edges, EdgeField)
|
|
}
|
|
return edges
|
|
}
|
|
|
|
// EdgeCleared returns a boolean which indicates if the edge with the given name
|
|
// was cleared in this mutation.
|
|
func (m *Mutation) EdgeCleared(name string) bool {
|
|
switch name {
|
|
case EdgeOwner:
|
|
return m.clearedowner
|
|
case EdgeType:
|
|
return m.cleared_type
|
|
case EdgeField:
|
|
return m.clearedfield
|
|
}
|
|
return false
|
|
}
|
|
|
|
// ClearEdge clears the value of the edge with the given name. It returns an error
|
|
// if that edge is not defined in the schema.
|
|
func (m *Mutation) ClearEdge(name string) error {
|
|
switch name {
|
|
case EdgeOwner:
|
|
m.ClearOwner()
|
|
return nil
|
|
case EdgeType:
|
|
m.ClearType()
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown File unique edge %s", name)
|
|
}
|
|
|
|
// ResetEdge resets all changes to the edge with the given name in this mutation.
|
|
// It returns an error if the edge is not defined in the schema.
|
|
func (m *Mutation) ResetEdge(name string) error {
|
|
switch name {
|
|
case EdgeOwner:
|
|
m.ResetOwner()
|
|
return nil
|
|
case EdgeType:
|
|
m.ResetType()
|
|
return nil
|
|
case EdgeField:
|
|
m.ResetFieldEdge()
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown File edge %s", name)
|
|
}
|