Files
upstream-mirror 4b3ad0b611
Some checks failed
Atlas CI Public / lint (push) Failing after 13s
Atlas CI Public / sync (push) Has been skipped
snapshot of https://github.com/ent/ent.git (master, 2026-09-15; blobs > 131072B omitted)
2026-09-15 22:12:36 +05:00

592 lines
15 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 comment
import (
"context"
"fmt"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/entc/integration/ent/predicate"
schemadir "entgo.io/ent/entc/integration/ent/schema/dir"
)
// Mutation represents an operation that mutates the Comment nodes in the graph.
type Mutation struct {
op ent.Op
typ string
unique_int *int
addunique_int *int
unique_float *float64
addunique_float *float64
nillable_int *int
addnillable_int *int
table *string
dir *schemadir.Dir
client *string
clearedFields map[string]struct{}
predicates []predicate.Comment
}
// NewMutation creates a new Mutation for the Comment entity.
func NewMutation(op ent.Op) *Mutation {
return &Mutation{
op: op,
typ: "Comment",
clearedFields: make(map[string]struct{}),
}
}
// Predicates returns the list of predicates set on the mutation.
func (m *Mutation) Predicates() []predicate.Comment {
return m.predicates
}
// SetUniqueInt sets the "unique_int" field.
func (m *Mutation) SetUniqueInt(i int) {
m.unique_int = &i
m.addunique_int = nil
}
// UniqueInt returns the value of the "unique_int" field in the mutation.
func (m *Mutation) UniqueInt() (r int, exists bool) {
v := m.unique_int
if v == nil {
return
}
return *v, true
}
// AddUniqueInt adds i to the "unique_int" field.
func (m *Mutation) AddUniqueInt(i int) {
if m.addunique_int != nil {
*m.addunique_int += i
} else {
m.addunique_int = &i
}
}
// AddedUniqueInt returns the value that was added to the "unique_int" field in this mutation.
func (m *Mutation) AddedUniqueInt() (r int, exists bool) {
v := m.addunique_int
if v == nil {
return
}
return *v, true
}
// ResetUniqueInt resets all changes to the "unique_int" field.
func (m *Mutation) ResetUniqueInt() {
m.unique_int = nil
m.addunique_int = nil
}
// SetUniqueFloat sets the "unique_float" field.
func (m *Mutation) SetUniqueFloat(f float64) {
m.unique_float = &f
m.addunique_float = nil
}
// UniqueFloat returns the value of the "unique_float" field in the mutation.
func (m *Mutation) UniqueFloat() (r float64, exists bool) {
v := m.unique_float
if v == nil {
return
}
return *v, true
}
// AddUniqueFloat adds f to the "unique_float" field.
func (m *Mutation) AddUniqueFloat(f float64) {
if m.addunique_float != nil {
*m.addunique_float += f
} else {
m.addunique_float = &f
}
}
// AddedUniqueFloat returns the value that was added to the "unique_float" field in this mutation.
func (m *Mutation) AddedUniqueFloat() (r float64, exists bool) {
v := m.addunique_float
if v == nil {
return
}
return *v, true
}
// ResetUniqueFloat resets all changes to the "unique_float" field.
func (m *Mutation) ResetUniqueFloat() {
m.unique_float = nil
m.addunique_float = nil
}
// SetNillableInt sets the "nillable_int" field.
func (m *Mutation) SetNillableInt(i int) {
m.nillable_int = &i
m.addnillable_int = nil
}
// NillableInt returns the value of the "nillable_int" field in the mutation.
func (m *Mutation) NillableInt() (r int, exists bool) {
v := m.nillable_int
if v == nil {
return
}
return *v, true
}
// AddNillableInt adds i to the "nillable_int" field.
func (m *Mutation) AddNillableInt(i int) {
if m.addnillable_int != nil {
*m.addnillable_int += i
} else {
m.addnillable_int = &i
}
}
// AddedNillableInt returns the value that was added to the "nillable_int" field in this mutation.
func (m *Mutation) AddedNillableInt() (r int, exists bool) {
v := m.addnillable_int
if v == nil {
return
}
return *v, true
}
// ClearNillableInt clears the value of the "nillable_int" field.
func (m *Mutation) ClearNillableInt() {
m.nillable_int = nil
m.addnillable_int = nil
m.clearedFields[FieldNillableInt] = struct{}{}
}
// NillableIntCleared returns if the "nillable_int" field was cleared in this mutation.
func (m *Mutation) NillableIntCleared() bool {
_, ok := m.clearedFields[FieldNillableInt]
return ok
}
// ResetNillableInt resets all changes to the "nillable_int" field.
func (m *Mutation) ResetNillableInt() {
m.nillable_int = nil
m.addnillable_int = nil
delete(m.clearedFields, FieldNillableInt)
}
// SetTable sets the "table" field.
func (m *Mutation) SetTable(s string) {
m.table = &s
}
// Table returns the value of the "table" field in the mutation.
func (m *Mutation) Table() (r string, exists bool) {
v := m.table
if v == nil {
return
}
return *v, true
}
// ClearTable clears the value of the "table" field.
func (m *Mutation) ClearTable() {
m.table = nil
m.clearedFields[FieldTable] = struct{}{}
}
// TableCleared returns if the "table" field was cleared in this mutation.
func (m *Mutation) TableCleared() bool {
_, ok := m.clearedFields[FieldTable]
return ok
}
// ResetTable resets all changes to the "table" field.
func (m *Mutation) ResetTable() {
m.table = nil
delete(m.clearedFields, FieldTable)
}
// SetDir sets the "dir" field.
func (m *Mutation) SetDir(s schemadir.Dir) {
m.dir = &s
}
// Dir returns the value of the "dir" field in the mutation.
func (m *Mutation) Dir() (r schemadir.Dir, exists bool) {
v := m.dir
if v == nil {
return
}
return *v, true
}
// ClearDir clears the value of the "dir" field.
func (m *Mutation) ClearDir() {
m.dir = nil
m.clearedFields[FieldDir] = struct{}{}
}
// DirCleared returns if the "dir" field was cleared in this mutation.
func (m *Mutation) DirCleared() bool {
_, ok := m.clearedFields[FieldDir]
return ok
}
// ResetDir resets all changes to the "dir" field.
func (m *Mutation) ResetDir() {
m.dir = nil
delete(m.clearedFields, FieldDir)
}
// SetClient sets the "client" field.
func (m *Mutation) SetClient(s string) {
m.client = &s
}
// GetClient returns the value of the "client" field in the mutation.
func (m *Mutation) GetClient() (r string, exists bool) {
v := m.client
if v == nil {
return
}
return *v, true
}
// ClearClient clears the value of the "client" field.
func (m *Mutation) ClearClient() {
m.client = nil
m.clearedFields[FieldClient] = struct{}{}
}
// ClientCleared returns if the "client" field was cleared in this mutation.
func (m *Mutation) ClientCleared() bool {
_, ok := m.clearedFields[FieldClient]
return ok
}
// ResetClient resets all changes to the "client" field.
func (m *Mutation) ResetClient() {
m.client = nil
delete(m.clearedFields, FieldClient)
}
// Where appends a list predicates to the Mutation builder.
func (m *Mutation) Where(ps ...predicate.Comment) {
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.Comment, 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 (Comment).
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, 6)
if m.unique_int != nil {
fields = append(fields, FieldUniqueInt)
}
if m.unique_float != nil {
fields = append(fields, FieldUniqueFloat)
}
if m.nillable_int != nil {
fields = append(fields, FieldNillableInt)
}
if m.table != nil {
fields = append(fields, FieldTable)
}
if m.dir != nil {
fields = append(fields, FieldDir)
}
if m.client != nil {
fields = append(fields, FieldClient)
}
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 FieldUniqueInt:
return m.UniqueInt()
case FieldUniqueFloat:
return m.UniqueFloat()
case FieldNillableInt:
return m.NillableInt()
case FieldTable:
return m.Table()
case FieldDir:
return m.Dir()
case FieldClient:
return m.GetClient()
}
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 Comment 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 FieldUniqueInt:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUniqueInt(v)
return nil
case FieldUniqueFloat:
v, ok := value.(float64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUniqueFloat(v)
return nil
case FieldNillableInt:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetNillableInt(v)
return nil
case FieldTable:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetTable(v)
return nil
case FieldDir:
v, ok := value.(schemadir.Dir)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetDir(v)
return nil
case FieldClient:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetClient(v)
return nil
}
return fmt.Errorf("unknown Comment 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.addunique_int != nil {
fields = append(fields, FieldUniqueInt)
}
if m.addunique_float != nil {
fields = append(fields, FieldUniqueFloat)
}
if m.addnillable_int != nil {
fields = append(fields, FieldNillableInt)
}
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 FieldUniqueInt:
return m.AddedUniqueInt()
case FieldUniqueFloat:
return m.AddedUniqueFloat()
case FieldNillableInt:
return m.AddedNillableInt()
}
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 FieldUniqueInt:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddUniqueInt(v)
return nil
case FieldUniqueFloat:
v, ok := value.(float64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddUniqueFloat(v)
return nil
case FieldNillableInt:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddNillableInt(v)
return nil
}
return fmt.Errorf("unknown Comment 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(FieldNillableInt) {
fields = append(fields, FieldNillableInt)
}
if m.FieldCleared(FieldTable) {
fields = append(fields, FieldTable)
}
if m.FieldCleared(FieldDir) {
fields = append(fields, FieldDir)
}
if m.FieldCleared(FieldClient) {
fields = append(fields, FieldClient)
}
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 FieldNillableInt:
m.ClearNillableInt()
return nil
case FieldTable:
m.ClearTable()
return nil
case FieldDir:
m.ClearDir()
return nil
case FieldClient:
m.ClearClient()
return nil
}
return fmt.Errorf("unknown Comment 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 FieldUniqueInt:
m.ResetUniqueInt()
return nil
case FieldUniqueFloat:
m.ResetUniqueFloat()
return nil
case FieldNillableInt:
m.ResetNillableInt()
return nil
case FieldTable:
m.ResetTable()
return nil
case FieldDir:
m.ResetDir()
return nil
case FieldClient:
m.ResetClient()
return nil
}
return fmt.Errorf("unknown Comment field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *Mutation) AddedEdges() []string {
edges := make([]string, 0, 0)
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 {
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *Mutation) RemovedEdges() []string {
edges := make([]string, 0, 0)
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 {
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *Mutation) ClearedEdges() []string {
edges := make([]string, 0, 0)
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 {
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 {
return fmt.Errorf("unknown Comment 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 {
return fmt.Errorf("unknown Comment edge %s", name)
}