snapshot of https://github.com/ent/ent.git (master, 2026-09-15; blobs > 131072B omitted)
This commit is contained in:
301
entc/integration/customid/ent/token/mutation.go
Normal file
301
entc/integration/customid/ent/token/mutation.go
Normal file
@@ -0,0 +1,301 @@
|
||||
// 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 token
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/entc/integration/customid/ent/predicate"
|
||||
"entgo.io/ent/entc/integration/customid/sid"
|
||||
)
|
||||
|
||||
// Mutation represents an operation that mutates the Token nodes in the graph.
|
||||
type Mutation struct {
|
||||
op ent.Op
|
||||
typ string
|
||||
body *string
|
||||
clearedFields map[string]struct{}
|
||||
account *sid.ID
|
||||
clearedaccount bool
|
||||
predicates []predicate.Token
|
||||
}
|
||||
|
||||
// NewMutation creates a new Mutation for the Token entity.
|
||||
func NewMutation(op ent.Op) *Mutation {
|
||||
return &Mutation{
|
||||
op: op,
|
||||
typ: "Token",
|
||||
clearedFields: make(map[string]struct{}),
|
||||
}
|
||||
}
|
||||
|
||||
// Predicates returns the list of predicates set on the mutation.
|
||||
func (m *Mutation) Predicates() []predicate.Token {
|
||||
return m.predicates
|
||||
}
|
||||
|
||||
// SetBody sets the "body" field.
|
||||
func (m *Mutation) SetBody(s string) {
|
||||
m.body = &s
|
||||
}
|
||||
|
||||
// Body returns the value of the "body" field in the mutation.
|
||||
func (m *Mutation) Body() (r string, exists bool) {
|
||||
v := m.body
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// ResetBody resets all changes to the "body" field.
|
||||
func (m *Mutation) ResetBody() {
|
||||
m.body = nil
|
||||
}
|
||||
|
||||
// SetAccountID sets the "account" edge to the Account entity by id.
|
||||
func (m *Mutation) SetAccountID(id sid.ID) {
|
||||
m.account = &id
|
||||
}
|
||||
|
||||
// ClearAccount clears the "account" edge to the Account entity.
|
||||
func (m *Mutation) ClearAccount() {
|
||||
m.clearedaccount = true
|
||||
}
|
||||
|
||||
// AccountCleared reports if the "account" edge to the Account entity was cleared.
|
||||
func (m *Mutation) AccountCleared() bool {
|
||||
return m.clearedaccount
|
||||
}
|
||||
|
||||
// AccountID returns the "account" edge ID in the mutation.
|
||||
func (m *Mutation) AccountID() (id sid.ID, exists bool) {
|
||||
if m.account != nil {
|
||||
return *m.account, true
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// AccountIDs returns the "account" edge IDs in the mutation.
|
||||
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
|
||||
// AccountID instead. It exists only for internal usage by the builders.
|
||||
func (m *Mutation) AccountIDs() (ids []sid.ID) {
|
||||
if id := m.account; id != nil {
|
||||
ids = append(ids, *id)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// ResetAccount resets all changes to the "account" edge.
|
||||
func (m *Mutation) ResetAccount() {
|
||||
m.account = nil
|
||||
m.clearedaccount = false
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the Mutation builder.
|
||||
func (m *Mutation) Where(ps ...predicate.Token) {
|
||||
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.Token, 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 (Token).
|
||||
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, 1)
|
||||
if m.body != nil {
|
||||
fields = append(fields, FieldBody)
|
||||
}
|
||||
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 FieldBody:
|
||||
return m.Body()
|
||||
}
|
||||
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 Token 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 FieldBody:
|
||||
v, ok := value.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetBody(v)
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown Token field %s", name)
|
||||
}
|
||||
|
||||
// AddedFields returns all numeric fields that were incremented/decremented during
|
||||
// this mutation.
|
||||
func (m *Mutation) AddedFields() []string {
|
||||
return nil
|
||||
}
|
||||
|
||||
// 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) {
|
||||
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 {
|
||||
}
|
||||
return fmt.Errorf("unknown Token numeric field %s", name)
|
||||
}
|
||||
|
||||
// ClearedFields returns all nullable fields that were cleared during this
|
||||
// mutation.
|
||||
func (m *Mutation) ClearedFields() []string {
|
||||
return nil
|
||||
}
|
||||
|
||||
// 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 {
|
||||
return fmt.Errorf("unknown Token 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 FieldBody:
|
||||
m.ResetBody()
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown Token field %s", name)
|
||||
}
|
||||
|
||||
// AddedEdges returns all edge names that were set/added in this mutation.
|
||||
func (m *Mutation) AddedEdges() []string {
|
||||
edges := make([]string, 0, 1)
|
||||
if m.account != nil {
|
||||
edges = append(edges, EdgeAccount)
|
||||
}
|
||||
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 EdgeAccount:
|
||||
if id := m.account; id != nil {
|
||||
return []ent.Value{*id}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// RemovedEdges returns all edge names that were removed in this mutation.
|
||||
func (m *Mutation) RemovedEdges() []string {
|
||||
edges := make([]string, 0, 1)
|
||||
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, 1)
|
||||
if m.clearedaccount {
|
||||
edges = append(edges, EdgeAccount)
|
||||
}
|
||||
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 EdgeAccount:
|
||||
return m.clearedaccount
|
||||
}
|
||||
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 EdgeAccount:
|
||||
m.ClearAccount()
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown Token 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 EdgeAccount:
|
||||
m.ResetAccount()
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown Token edge %s", name)
|
||||
}
|
||||
94
entc/integration/customid/ent/token/token.go
Normal file
94
entc/integration/customid/ent/token/token.go
Normal file
@@ -0,0 +1,94 @@
|
||||
// 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 token
|
||||
|
||||
import (
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/entc/integration/customid/sid"
|
||||
)
|
||||
|
||||
const (
|
||||
// Label holds the string label denoting the token type in the database.
|
||||
Label = "token"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldBody holds the string denoting the body field in the database.
|
||||
FieldBody = "body"
|
||||
// EdgeAccount holds the string denoting the account edge name in mutations.
|
||||
EdgeAccount = "account"
|
||||
// Table holds the table name of the token in the database.
|
||||
Table = "tokens"
|
||||
// AccountTable is the table that holds the account relation/edge.
|
||||
AccountTable = "tokens"
|
||||
// AccountInverseTable is the table name for the Account entity.
|
||||
// It exists in this package in order to avoid circular dependency with the "account" package.
|
||||
AccountInverseTable = "accounts"
|
||||
// AccountColumn is the table column denoting the account relation/edge.
|
||||
AccountColumn = "account_token"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for token fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldBody,
|
||||
}
|
||||
|
||||
// ForeignKeys holds the SQL foreign-keys that are owned by the "tokens"
|
||||
// table and are not defined as standalone fields in the schema.
|
||||
var ForeignKeys = []string{
|
||||
"account_token",
|
||||
}
|
||||
|
||||
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||
func ValidColumn(column string) bool {
|
||||
for i := range Columns {
|
||||
if column == Columns[i] {
|
||||
return true
|
||||
}
|
||||
}
|
||||
for i := range ForeignKeys {
|
||||
if column == ForeignKeys[i] {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var (
|
||||
// BodyValidator is a validator for the "body" field. It is called by the builders before save.
|
||||
BodyValidator func(string) error
|
||||
// DefaultID holds the default value on creation for the "id" field.
|
||||
DefaultID func() sid.ID
|
||||
)
|
||||
|
||||
// OrderOption defines the ordering options for the Token queries.
|
||||
type OrderOption func(*sql.Selector)
|
||||
|
||||
// ByID orders the results by the id field.
|
||||
func ByID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByBody orders the results by the body field.
|
||||
func ByBody(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldBody, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByAccountField orders the results by account field.
|
||||
func ByAccountField(field string, opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newAccountStep(), sql.OrderByField(field, opts...))
|
||||
}
|
||||
}
|
||||
func newAccountStep() *sqlgraph.Step {
|
||||
return sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(AccountInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, AccountTable, AccountColumn),
|
||||
)
|
||||
}
|
||||
167
entc/integration/customid/ent/token/where.go
Normal file
167
entc/integration/customid/ent/token/where.go
Normal file
@@ -0,0 +1,167 @@
|
||||
// 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 token
|
||||
|
||||
import (
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/entc/integration/customid/ent/predicate"
|
||||
"entgo.io/ent/entc/integration/customid/sid"
|
||||
)
|
||||
|
||||
// ID filters vertices based on their ID field.
|
||||
func ID(id sid.ID) predicate.Token {
|
||||
return predicate.Token(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDEQ applies the EQ predicate on the ID field.
|
||||
func IDEQ(id sid.ID) predicate.Token {
|
||||
return predicate.Token(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDNEQ applies the NEQ predicate on the ID field.
|
||||
func IDNEQ(id sid.ID) predicate.Token {
|
||||
return predicate.Token(sql.FieldNEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDIn applies the In predicate on the ID field.
|
||||
func IDIn(ids ...sid.ID) predicate.Token {
|
||||
return predicate.Token(sql.FieldIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDNotIn applies the NotIn predicate on the ID field.
|
||||
func IDNotIn(ids ...sid.ID) predicate.Token {
|
||||
return predicate.Token(sql.FieldNotIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDGT applies the GT predicate on the ID field.
|
||||
func IDGT(id sid.ID) predicate.Token {
|
||||
return predicate.Token(sql.FieldGT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDGTE applies the GTE predicate on the ID field.
|
||||
func IDGTE(id sid.ID) predicate.Token {
|
||||
return predicate.Token(sql.FieldGTE(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLT applies the LT predicate on the ID field.
|
||||
func IDLT(id sid.ID) predicate.Token {
|
||||
return predicate.Token(sql.FieldLT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLTE applies the LTE predicate on the ID field.
|
||||
func IDLTE(id sid.ID) predicate.Token {
|
||||
return predicate.Token(sql.FieldLTE(FieldID, id))
|
||||
}
|
||||
|
||||
// Body applies equality check predicate on the "body" field. It's identical to BodyEQ.
|
||||
func Body(v string) predicate.Token {
|
||||
return predicate.Token(sql.FieldEQ(FieldBody, v))
|
||||
}
|
||||
|
||||
// BodyEQ applies the EQ predicate on the "body" field.
|
||||
func BodyEQ(v string) predicate.Token {
|
||||
return predicate.Token(sql.FieldEQ(FieldBody, v))
|
||||
}
|
||||
|
||||
// BodyNEQ applies the NEQ predicate on the "body" field.
|
||||
func BodyNEQ(v string) predicate.Token {
|
||||
return predicate.Token(sql.FieldNEQ(FieldBody, v))
|
||||
}
|
||||
|
||||
// BodyIn applies the In predicate on the "body" field.
|
||||
func BodyIn(vs ...string) predicate.Token {
|
||||
return predicate.Token(sql.FieldIn(FieldBody, vs...))
|
||||
}
|
||||
|
||||
// BodyNotIn applies the NotIn predicate on the "body" field.
|
||||
func BodyNotIn(vs ...string) predicate.Token {
|
||||
return predicate.Token(sql.FieldNotIn(FieldBody, vs...))
|
||||
}
|
||||
|
||||
// BodyGT applies the GT predicate on the "body" field.
|
||||
func BodyGT(v string) predicate.Token {
|
||||
return predicate.Token(sql.FieldGT(FieldBody, v))
|
||||
}
|
||||
|
||||
// BodyGTE applies the GTE predicate on the "body" field.
|
||||
func BodyGTE(v string) predicate.Token {
|
||||
return predicate.Token(sql.FieldGTE(FieldBody, v))
|
||||
}
|
||||
|
||||
// BodyLT applies the LT predicate on the "body" field.
|
||||
func BodyLT(v string) predicate.Token {
|
||||
return predicate.Token(sql.FieldLT(FieldBody, v))
|
||||
}
|
||||
|
||||
// BodyLTE applies the LTE predicate on the "body" field.
|
||||
func BodyLTE(v string) predicate.Token {
|
||||
return predicate.Token(sql.FieldLTE(FieldBody, v))
|
||||
}
|
||||
|
||||
// BodyContains applies the Contains predicate on the "body" field.
|
||||
func BodyContains(v string) predicate.Token {
|
||||
return predicate.Token(sql.FieldContains(FieldBody, v))
|
||||
}
|
||||
|
||||
// BodyHasPrefix applies the HasPrefix predicate on the "body" field.
|
||||
func BodyHasPrefix(v string) predicate.Token {
|
||||
return predicate.Token(sql.FieldHasPrefix(FieldBody, v))
|
||||
}
|
||||
|
||||
// BodyHasSuffix applies the HasSuffix predicate on the "body" field.
|
||||
func BodyHasSuffix(v string) predicate.Token {
|
||||
return predicate.Token(sql.FieldHasSuffix(FieldBody, v))
|
||||
}
|
||||
|
||||
// BodyEqualFold applies the EqualFold predicate on the "body" field.
|
||||
func BodyEqualFold(v string) predicate.Token {
|
||||
return predicate.Token(sql.FieldEqualFold(FieldBody, v))
|
||||
}
|
||||
|
||||
// BodyContainsFold applies the ContainsFold predicate on the "body" field.
|
||||
func BodyContainsFold(v string) predicate.Token {
|
||||
return predicate.Token(sql.FieldContainsFold(FieldBody, v))
|
||||
}
|
||||
|
||||
// HasAccount applies the HasEdge predicate on the "account" edge.
|
||||
func HasAccount() predicate.Token {
|
||||
return predicate.Token(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, AccountTable, AccountColumn),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
})
|
||||
}
|
||||
|
||||
// HasAccountWith applies the HasEdge predicate on the "account" edge with a given conditions (other predicates).
|
||||
func HasAccountWith(preds ...predicate.Account) predicate.Token {
|
||||
return predicate.Token(func(s *sql.Selector) {
|
||||
step := newAccountStep()
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.Token) predicate.Token {
|
||||
return predicate.Token(sql.AndPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Or groups predicates with the OR operator between them.
|
||||
func Or(predicates ...predicate.Token) predicate.Token {
|
||||
return predicate.Token(sql.OrPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Not applies the not operator on the given predicate.
|
||||
func Not(p predicate.Token) predicate.Token {
|
||||
return predicate.Token(sql.NotPredicates(p))
|
||||
}
|
||||
Reference in New Issue
Block a user