mirror of
https://github.com/sysadminsmedia/homebox.git
synced 2025-12-26 07:13:37 +01:00
Get main into this PR.
Done on ✈️
This commit is contained in:
@@ -317,6 +317,8 @@ github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/
|
||||
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
|
||||
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
||||
github.com/mattn/go-sqlite3 v1.14.32 h1:JD12Ag3oLy1zQA+BNn74xRgaBbdhbNIDYvQUEuuErjs=
|
||||
github.com/mattn/go-sqlite3 v1.14.32/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
|
||||
github.com/mfridman/interpolate v0.0.2 h1:pnuTK7MQIxxFz1Gr+rjSIx9u7qVjf5VOoM/u6BbAxPY=
|
||||
@@ -340,6 +342,8 @@ github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJm
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||
github.com/olahol/melody v1.3.0 h1:n7UlKiQnxVrgxKoM0d7usZiN+Z0y2lVENtYLgKtXS6s=
|
||||
github.com/olahol/melody v1.3.0/go.mod h1:GgkTl6Y7yWj/HtfD48Q5vLKPVoZOH+Qqgfa7CvJgJM4=
|
||||
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
|
||||
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
|
||||
github.com/onsi/ginkgo/v2 v2.9.2 h1:BA2GMJOtfGAfagzYtrAlufIP0lq6QERkFmHLMLPwFSU=
|
||||
github.com/onsi/ginkgo/v2 v2.9.2/go.mod h1:WHcJJG2dIlcCqVfBAwUCrJxSPFb6v4azBwgxeMeDuts=
|
||||
github.com/onsi/gomega v1.27.6 h1:ENqfyGeS5AX/rlXDd/ETokDz93u0YufY1Pgxuy/PvWE=
|
||||
@@ -382,6 +386,10 @@ github.com/shirou/gopsutil/v4 v4.25.7 h1:bNb2JuqKuAu3tRlPv5piSmBZyMfecwQ+t/ILq+1
|
||||
github.com/shirou/gopsutil/v4 v4.25.7/go.mod h1:XV/egmwJtd3ZQjBpJVY5kndsiOO4IRqy9TQnmm6VP7U=
|
||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0=
|
||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M=
|
||||
github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=
|
||||
github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
|
||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/spiffe/go-spiffe/v2 v2.5.0 h1:N2I01KCUkv1FAjZXJMwh95KK1ZIQLYbPfhaxw8WS0hE=
|
||||
github.com/spiffe/go-spiffe/v2 v2.5.0/go.mod h1:P+NxobPc6wXhVtINNtFjNWGBTreew1GBUCwT2wPmb7g=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
|
||||
@@ -100,7 +100,7 @@ func (*Attachment) scanValues(columns []string) ([]any, error) {
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the Attachment fields.
|
||||
func (a *Attachment) assignValues(columns []string, values []any) error {
|
||||
func (_m *Attachment) assignValues(columns []string, values []any) error {
|
||||
if m, n := len(values), len(columns); m < n {
|
||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||
}
|
||||
@@ -110,66 +110,66 @@ func (a *Attachment) assignValues(columns []string, values []any) error {
|
||||
if value, ok := values[i].(*uuid.UUID); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", values[i])
|
||||
} else if value != nil {
|
||||
a.ID = *value
|
||||
_m.ID = *value
|
||||
}
|
||||
case attachment.FieldCreatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
||||
} else if value.Valid {
|
||||
a.CreatedAt = value.Time
|
||||
_m.CreatedAt = value.Time
|
||||
}
|
||||
case attachment.FieldUpdatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
|
||||
} else if value.Valid {
|
||||
a.UpdatedAt = value.Time
|
||||
_m.UpdatedAt = value.Time
|
||||
}
|
||||
case attachment.FieldType:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field type", values[i])
|
||||
} else if value.Valid {
|
||||
a.Type = attachment.Type(value.String)
|
||||
_m.Type = attachment.Type(value.String)
|
||||
}
|
||||
case attachment.FieldPrimary:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field primary", values[i])
|
||||
} else if value.Valid {
|
||||
a.Primary = value.Bool
|
||||
_m.Primary = value.Bool
|
||||
}
|
||||
case attachment.FieldTitle:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field title", values[i])
|
||||
} else if value.Valid {
|
||||
a.Title = value.String
|
||||
_m.Title = value.String
|
||||
}
|
||||
case attachment.FieldPath:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field path", values[i])
|
||||
} else if value.Valid {
|
||||
a.Path = value.String
|
||||
_m.Path = value.String
|
||||
}
|
||||
case attachment.FieldMimeType:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field mime_type", values[i])
|
||||
} else if value.Valid {
|
||||
a.MimeType = value.String
|
||||
_m.MimeType = value.String
|
||||
}
|
||||
case attachment.ForeignKeys[0]:
|
||||
if value, ok := values[i].(*sql.NullScanner); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field attachment_thumbnail", values[i])
|
||||
} else if value.Valid {
|
||||
a.attachment_thumbnail = new(uuid.UUID)
|
||||
*a.attachment_thumbnail = *value.S.(*uuid.UUID)
|
||||
_m.attachment_thumbnail = new(uuid.UUID)
|
||||
*_m.attachment_thumbnail = *value.S.(*uuid.UUID)
|
||||
}
|
||||
case attachment.ForeignKeys[1]:
|
||||
if value, ok := values[i].(*sql.NullScanner); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field entity_attachments", values[i])
|
||||
} else if value.Valid {
|
||||
a.entity_attachments = new(uuid.UUID)
|
||||
*a.entity_attachments = *value.S.(*uuid.UUID)
|
||||
_m.entity_attachments = new(uuid.UUID)
|
||||
*_m.entity_attachments = *value.S.(*uuid.UUID)
|
||||
}
|
||||
default:
|
||||
a.selectValues.Set(columns[i], values[i])
|
||||
_m.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -177,63 +177,63 @@ func (a *Attachment) assignValues(columns []string, values []any) error {
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the Attachment.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (a *Attachment) Value(name string) (ent.Value, error) {
|
||||
return a.selectValues.Get(name)
|
||||
func (_m *Attachment) Value(name string) (ent.Value, error) {
|
||||
return _m.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// QueryEntity queries the "entity" edge of the Attachment entity.
|
||||
func (a *Attachment) QueryEntity() *EntityQuery {
|
||||
return NewAttachmentClient(a.config).QueryEntity(a)
|
||||
func (_m *Attachment) QueryEntity() *EntityQuery {
|
||||
return NewAttachmentClient(_m.config).QueryEntity(_m)
|
||||
}
|
||||
|
||||
// QueryThumbnail queries the "thumbnail" edge of the Attachment entity.
|
||||
func (a *Attachment) QueryThumbnail() *AttachmentQuery {
|
||||
return NewAttachmentClient(a.config).QueryThumbnail(a)
|
||||
func (_m *Attachment) QueryThumbnail() *AttachmentQuery {
|
||||
return NewAttachmentClient(_m.config).QueryThumbnail(_m)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this Attachment.
|
||||
// Note that you need to call Attachment.Unwrap() before calling this method if this Attachment
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (a *Attachment) Update() *AttachmentUpdateOne {
|
||||
return NewAttachmentClient(a.config).UpdateOne(a)
|
||||
func (_m *Attachment) Update() *AttachmentUpdateOne {
|
||||
return NewAttachmentClient(_m.config).UpdateOne(_m)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the Attachment entity that was returned from a transaction after it was closed,
|
||||
// so that all future queries will be executed through the driver which created the transaction.
|
||||
func (a *Attachment) Unwrap() *Attachment {
|
||||
_tx, ok := a.config.driver.(*txDriver)
|
||||
func (_m *Attachment) Unwrap() *Attachment {
|
||||
_tx, ok := _m.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: Attachment is not a transactional entity")
|
||||
}
|
||||
a.config.driver = _tx.drv
|
||||
return a
|
||||
_m.config.driver = _tx.drv
|
||||
return _m
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (a *Attachment) String() string {
|
||||
func (_m *Attachment) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("Attachment(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", a.ID))
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||||
builder.WriteString("created_at=")
|
||||
builder.WriteString(a.CreatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("updated_at=")
|
||||
builder.WriteString(a.UpdatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("type=")
|
||||
builder.WriteString(fmt.Sprintf("%v", a.Type))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Type))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("primary=")
|
||||
builder.WriteString(fmt.Sprintf("%v", a.Primary))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Primary))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("title=")
|
||||
builder.WriteString(a.Title)
|
||||
builder.WriteString(_m.Title)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("path=")
|
||||
builder.WriteString(a.Path)
|
||||
builder.WriteString(_m.Path)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("mime_type=")
|
||||
builder.WriteString(a.MimeType)
|
||||
builder.WriteString(_m.MimeType)
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
@@ -23,169 +23,169 @@ type AttachmentCreate struct {
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (ac *AttachmentCreate) SetCreatedAt(t time.Time) *AttachmentCreate {
|
||||
ac.mutation.SetCreatedAt(t)
|
||||
return ac
|
||||
func (_c *AttachmentCreate) SetCreatedAt(v time.Time) *AttachmentCreate {
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||
func (ac *AttachmentCreate) SetNillableCreatedAt(t *time.Time) *AttachmentCreate {
|
||||
if t != nil {
|
||||
ac.SetCreatedAt(*t)
|
||||
func (_c *AttachmentCreate) SetNillableCreatedAt(v *time.Time) *AttachmentCreate {
|
||||
if v != nil {
|
||||
_c.SetCreatedAt(*v)
|
||||
}
|
||||
return ac
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (ac *AttachmentCreate) SetUpdatedAt(t time.Time) *AttachmentCreate {
|
||||
ac.mutation.SetUpdatedAt(t)
|
||||
return ac
|
||||
func (_c *AttachmentCreate) SetUpdatedAt(v time.Time) *AttachmentCreate {
|
||||
_c.mutation.SetUpdatedAt(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
||||
func (ac *AttachmentCreate) SetNillableUpdatedAt(t *time.Time) *AttachmentCreate {
|
||||
if t != nil {
|
||||
ac.SetUpdatedAt(*t)
|
||||
func (_c *AttachmentCreate) SetNillableUpdatedAt(v *time.Time) *AttachmentCreate {
|
||||
if v != nil {
|
||||
_c.SetUpdatedAt(*v)
|
||||
}
|
||||
return ac
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetType sets the "type" field.
|
||||
func (ac *AttachmentCreate) SetType(a attachment.Type) *AttachmentCreate {
|
||||
ac.mutation.SetType(a)
|
||||
return ac
|
||||
func (_c *AttachmentCreate) SetType(v attachment.Type) *AttachmentCreate {
|
||||
_c.mutation.SetType(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableType sets the "type" field if the given value is not nil.
|
||||
func (ac *AttachmentCreate) SetNillableType(a *attachment.Type) *AttachmentCreate {
|
||||
if a != nil {
|
||||
ac.SetType(*a)
|
||||
func (_c *AttachmentCreate) SetNillableType(v *attachment.Type) *AttachmentCreate {
|
||||
if v != nil {
|
||||
_c.SetType(*v)
|
||||
}
|
||||
return ac
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetPrimary sets the "primary" field.
|
||||
func (ac *AttachmentCreate) SetPrimary(b bool) *AttachmentCreate {
|
||||
ac.mutation.SetPrimary(b)
|
||||
return ac
|
||||
func (_c *AttachmentCreate) SetPrimary(v bool) *AttachmentCreate {
|
||||
_c.mutation.SetPrimary(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillablePrimary sets the "primary" field if the given value is not nil.
|
||||
func (ac *AttachmentCreate) SetNillablePrimary(b *bool) *AttachmentCreate {
|
||||
if b != nil {
|
||||
ac.SetPrimary(*b)
|
||||
func (_c *AttachmentCreate) SetNillablePrimary(v *bool) *AttachmentCreate {
|
||||
if v != nil {
|
||||
_c.SetPrimary(*v)
|
||||
}
|
||||
return ac
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetTitle sets the "title" field.
|
||||
func (ac *AttachmentCreate) SetTitle(s string) *AttachmentCreate {
|
||||
ac.mutation.SetTitle(s)
|
||||
return ac
|
||||
func (_c *AttachmentCreate) SetTitle(v string) *AttachmentCreate {
|
||||
_c.mutation.SetTitle(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableTitle sets the "title" field if the given value is not nil.
|
||||
func (ac *AttachmentCreate) SetNillableTitle(s *string) *AttachmentCreate {
|
||||
if s != nil {
|
||||
ac.SetTitle(*s)
|
||||
func (_c *AttachmentCreate) SetNillableTitle(v *string) *AttachmentCreate {
|
||||
if v != nil {
|
||||
_c.SetTitle(*v)
|
||||
}
|
||||
return ac
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetPath sets the "path" field.
|
||||
func (ac *AttachmentCreate) SetPath(s string) *AttachmentCreate {
|
||||
ac.mutation.SetPath(s)
|
||||
return ac
|
||||
func (_c *AttachmentCreate) SetPath(v string) *AttachmentCreate {
|
||||
_c.mutation.SetPath(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillablePath sets the "path" field if the given value is not nil.
|
||||
func (ac *AttachmentCreate) SetNillablePath(s *string) *AttachmentCreate {
|
||||
if s != nil {
|
||||
ac.SetPath(*s)
|
||||
func (_c *AttachmentCreate) SetNillablePath(v *string) *AttachmentCreate {
|
||||
if v != nil {
|
||||
_c.SetPath(*v)
|
||||
}
|
||||
return ac
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetMimeType sets the "mime_type" field.
|
||||
func (ac *AttachmentCreate) SetMimeType(s string) *AttachmentCreate {
|
||||
ac.mutation.SetMimeType(s)
|
||||
return ac
|
||||
func (_c *AttachmentCreate) SetMimeType(v string) *AttachmentCreate {
|
||||
_c.mutation.SetMimeType(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableMimeType sets the "mime_type" field if the given value is not nil.
|
||||
func (ac *AttachmentCreate) SetNillableMimeType(s *string) *AttachmentCreate {
|
||||
if s != nil {
|
||||
ac.SetMimeType(*s)
|
||||
func (_c *AttachmentCreate) SetNillableMimeType(v *string) *AttachmentCreate {
|
||||
if v != nil {
|
||||
_c.SetMimeType(*v)
|
||||
}
|
||||
return ac
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetID sets the "id" field.
|
||||
func (ac *AttachmentCreate) SetID(u uuid.UUID) *AttachmentCreate {
|
||||
ac.mutation.SetID(u)
|
||||
return ac
|
||||
func (_c *AttachmentCreate) SetID(v uuid.UUID) *AttachmentCreate {
|
||||
_c.mutation.SetID(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableID sets the "id" field if the given value is not nil.
|
||||
func (ac *AttachmentCreate) SetNillableID(u *uuid.UUID) *AttachmentCreate {
|
||||
if u != nil {
|
||||
ac.SetID(*u)
|
||||
func (_c *AttachmentCreate) SetNillableID(v *uuid.UUID) *AttachmentCreate {
|
||||
if v != nil {
|
||||
_c.SetID(*v)
|
||||
}
|
||||
return ac
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetEntityID sets the "entity" edge to the Entity entity by ID.
|
||||
func (ac *AttachmentCreate) SetEntityID(id uuid.UUID) *AttachmentCreate {
|
||||
ac.mutation.SetEntityID(id)
|
||||
return ac
|
||||
func (_c *AttachmentCreate) SetEntityID(id uuid.UUID) *AttachmentCreate {
|
||||
_c.mutation.SetEntityID(id)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableEntityID sets the "entity" edge to the Entity entity by ID if the given value is not nil.
|
||||
func (ac *AttachmentCreate) SetNillableEntityID(id *uuid.UUID) *AttachmentCreate {
|
||||
func (_c *AttachmentCreate) SetNillableEntityID(id *uuid.UUID) *AttachmentCreate {
|
||||
if id != nil {
|
||||
ac = ac.SetEntityID(*id)
|
||||
_c = _c.SetEntityID(*id)
|
||||
}
|
||||
return ac
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetEntity sets the "entity" edge to the Entity entity.
|
||||
func (ac *AttachmentCreate) SetEntity(e *Entity) *AttachmentCreate {
|
||||
return ac.SetEntityID(e.ID)
|
||||
func (_c *AttachmentCreate) SetEntity(v *Entity) *AttachmentCreate {
|
||||
return _c.SetEntityID(v.ID)
|
||||
}
|
||||
|
||||
// SetThumbnailID sets the "thumbnail" edge to the Attachment entity by ID.
|
||||
func (ac *AttachmentCreate) SetThumbnailID(id uuid.UUID) *AttachmentCreate {
|
||||
ac.mutation.SetThumbnailID(id)
|
||||
return ac
|
||||
func (_c *AttachmentCreate) SetThumbnailID(id uuid.UUID) *AttachmentCreate {
|
||||
_c.mutation.SetThumbnailID(id)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableThumbnailID sets the "thumbnail" edge to the Attachment entity by ID if the given value is not nil.
|
||||
func (ac *AttachmentCreate) SetNillableThumbnailID(id *uuid.UUID) *AttachmentCreate {
|
||||
func (_c *AttachmentCreate) SetNillableThumbnailID(id *uuid.UUID) *AttachmentCreate {
|
||||
if id != nil {
|
||||
ac = ac.SetThumbnailID(*id)
|
||||
_c = _c.SetThumbnailID(*id)
|
||||
}
|
||||
return ac
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetThumbnail sets the "thumbnail" edge to the Attachment entity.
|
||||
func (ac *AttachmentCreate) SetThumbnail(a *Attachment) *AttachmentCreate {
|
||||
return ac.SetThumbnailID(a.ID)
|
||||
func (_c *AttachmentCreate) SetThumbnail(v *Attachment) *AttachmentCreate {
|
||||
return _c.SetThumbnailID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the AttachmentMutation object of the builder.
|
||||
func (ac *AttachmentCreate) Mutation() *AttachmentMutation {
|
||||
return ac.mutation
|
||||
func (_c *AttachmentCreate) Mutation() *AttachmentMutation {
|
||||
return _c.mutation
|
||||
}
|
||||
|
||||
// Save creates the Attachment in the database.
|
||||
func (ac *AttachmentCreate) Save(ctx context.Context) (*Attachment, error) {
|
||||
ac.defaults()
|
||||
return withHooks(ctx, ac.sqlSave, ac.mutation, ac.hooks)
|
||||
func (_c *AttachmentCreate) Save(ctx context.Context) (*Attachment, error) {
|
||||
_c.defaults()
|
||||
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (ac *AttachmentCreate) SaveX(ctx context.Context) *Attachment {
|
||||
v, err := ac.Save(ctx)
|
||||
func (_c *AttachmentCreate) SaveX(ctx context.Context) *Attachment {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -193,91 +193,91 @@ func (ac *AttachmentCreate) SaveX(ctx context.Context) *Attachment {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (ac *AttachmentCreate) Exec(ctx context.Context) error {
|
||||
_, err := ac.Save(ctx)
|
||||
func (_c *AttachmentCreate) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (ac *AttachmentCreate) ExecX(ctx context.Context) {
|
||||
if err := ac.Exec(ctx); err != nil {
|
||||
func (_c *AttachmentCreate) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (ac *AttachmentCreate) defaults() {
|
||||
if _, ok := ac.mutation.CreatedAt(); !ok {
|
||||
func (_c *AttachmentCreate) defaults() {
|
||||
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||
v := attachment.DefaultCreatedAt()
|
||||
ac.mutation.SetCreatedAt(v)
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
}
|
||||
if _, ok := ac.mutation.UpdatedAt(); !ok {
|
||||
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
||||
v := attachment.DefaultUpdatedAt()
|
||||
ac.mutation.SetUpdatedAt(v)
|
||||
_c.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
if _, ok := ac.mutation.GetType(); !ok {
|
||||
if _, ok := _c.mutation.GetType(); !ok {
|
||||
v := attachment.DefaultType
|
||||
ac.mutation.SetType(v)
|
||||
_c.mutation.SetType(v)
|
||||
}
|
||||
if _, ok := ac.mutation.Primary(); !ok {
|
||||
if _, ok := _c.mutation.Primary(); !ok {
|
||||
v := attachment.DefaultPrimary
|
||||
ac.mutation.SetPrimary(v)
|
||||
_c.mutation.SetPrimary(v)
|
||||
}
|
||||
if _, ok := ac.mutation.Title(); !ok {
|
||||
if _, ok := _c.mutation.Title(); !ok {
|
||||
v := attachment.DefaultTitle
|
||||
ac.mutation.SetTitle(v)
|
||||
_c.mutation.SetTitle(v)
|
||||
}
|
||||
if _, ok := ac.mutation.Path(); !ok {
|
||||
if _, ok := _c.mutation.Path(); !ok {
|
||||
v := attachment.DefaultPath
|
||||
ac.mutation.SetPath(v)
|
||||
_c.mutation.SetPath(v)
|
||||
}
|
||||
if _, ok := ac.mutation.MimeType(); !ok {
|
||||
if _, ok := _c.mutation.MimeType(); !ok {
|
||||
v := attachment.DefaultMimeType
|
||||
ac.mutation.SetMimeType(v)
|
||||
_c.mutation.SetMimeType(v)
|
||||
}
|
||||
if _, ok := ac.mutation.ID(); !ok {
|
||||
if _, ok := _c.mutation.ID(); !ok {
|
||||
v := attachment.DefaultID()
|
||||
ac.mutation.SetID(v)
|
||||
_c.mutation.SetID(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (ac *AttachmentCreate) check() error {
|
||||
if _, ok := ac.mutation.CreatedAt(); !ok {
|
||||
func (_c *AttachmentCreate) check() error {
|
||||
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Attachment.created_at"`)}
|
||||
}
|
||||
if _, ok := ac.mutation.UpdatedAt(); !ok {
|
||||
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
||||
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Attachment.updated_at"`)}
|
||||
}
|
||||
if _, ok := ac.mutation.GetType(); !ok {
|
||||
if _, ok := _c.mutation.GetType(); !ok {
|
||||
return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "Attachment.type"`)}
|
||||
}
|
||||
if v, ok := ac.mutation.GetType(); ok {
|
||||
if v, ok := _c.mutation.GetType(); ok {
|
||||
if err := attachment.TypeValidator(v); err != nil {
|
||||
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Attachment.type": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := ac.mutation.Primary(); !ok {
|
||||
if _, ok := _c.mutation.Primary(); !ok {
|
||||
return &ValidationError{Name: "primary", err: errors.New(`ent: missing required field "Attachment.primary"`)}
|
||||
}
|
||||
if _, ok := ac.mutation.Title(); !ok {
|
||||
if _, ok := _c.mutation.Title(); !ok {
|
||||
return &ValidationError{Name: "title", err: errors.New(`ent: missing required field "Attachment.title"`)}
|
||||
}
|
||||
if _, ok := ac.mutation.Path(); !ok {
|
||||
if _, ok := _c.mutation.Path(); !ok {
|
||||
return &ValidationError{Name: "path", err: errors.New(`ent: missing required field "Attachment.path"`)}
|
||||
}
|
||||
if _, ok := ac.mutation.MimeType(); !ok {
|
||||
if _, ok := _c.mutation.MimeType(); !ok {
|
||||
return &ValidationError{Name: "mime_type", err: errors.New(`ent: missing required field "Attachment.mime_type"`)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ac *AttachmentCreate) sqlSave(ctx context.Context) (*Attachment, error) {
|
||||
if err := ac.check(); err != nil {
|
||||
func (_c *AttachmentCreate) sqlSave(ctx context.Context) (*Attachment, error) {
|
||||
if err := _c.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_node, _spec := ac.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, ac.driver, _spec); err != nil {
|
||||
_node, _spec := _c.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
@@ -290,49 +290,49 @@ func (ac *AttachmentCreate) sqlSave(ctx context.Context) (*Attachment, error) {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
ac.mutation.id = &_node.ID
|
||||
ac.mutation.done = true
|
||||
_c.mutation.id = &_node.ID
|
||||
_c.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
func (ac *AttachmentCreate) createSpec() (*Attachment, *sqlgraph.CreateSpec) {
|
||||
func (_c *AttachmentCreate) createSpec() (*Attachment, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &Attachment{config: ac.config}
|
||||
_node = &Attachment{config: _c.config}
|
||||
_spec = sqlgraph.NewCreateSpec(attachment.Table, sqlgraph.NewFieldSpec(attachment.FieldID, field.TypeUUID))
|
||||
)
|
||||
if id, ok := ac.mutation.ID(); ok {
|
||||
if id, ok := _c.mutation.ID(); ok {
|
||||
_node.ID = id
|
||||
_spec.ID.Value = &id
|
||||
}
|
||||
if value, ok := ac.mutation.CreatedAt(); ok {
|
||||
if value, ok := _c.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(attachment.FieldCreatedAt, field.TypeTime, value)
|
||||
_node.CreatedAt = value
|
||||
}
|
||||
if value, ok := ac.mutation.UpdatedAt(); ok {
|
||||
if value, ok := _c.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(attachment.FieldUpdatedAt, field.TypeTime, value)
|
||||
_node.UpdatedAt = value
|
||||
}
|
||||
if value, ok := ac.mutation.GetType(); ok {
|
||||
if value, ok := _c.mutation.GetType(); ok {
|
||||
_spec.SetField(attachment.FieldType, field.TypeEnum, value)
|
||||
_node.Type = value
|
||||
}
|
||||
if value, ok := ac.mutation.Primary(); ok {
|
||||
if value, ok := _c.mutation.Primary(); ok {
|
||||
_spec.SetField(attachment.FieldPrimary, field.TypeBool, value)
|
||||
_node.Primary = value
|
||||
}
|
||||
if value, ok := ac.mutation.Title(); ok {
|
||||
if value, ok := _c.mutation.Title(); ok {
|
||||
_spec.SetField(attachment.FieldTitle, field.TypeString, value)
|
||||
_node.Title = value
|
||||
}
|
||||
if value, ok := ac.mutation.Path(); ok {
|
||||
if value, ok := _c.mutation.Path(); ok {
|
||||
_spec.SetField(attachment.FieldPath, field.TypeString, value)
|
||||
_node.Path = value
|
||||
}
|
||||
if value, ok := ac.mutation.MimeType(); ok {
|
||||
if value, ok := _c.mutation.MimeType(); ok {
|
||||
_spec.SetField(attachment.FieldMimeType, field.TypeString, value)
|
||||
_node.MimeType = value
|
||||
}
|
||||
if nodes := ac.mutation.EntityIDs(); len(nodes) > 0 {
|
||||
if nodes := _c.mutation.EntityIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -349,7 +349,7 @@ func (ac *AttachmentCreate) createSpec() (*Attachment, *sqlgraph.CreateSpec) {
|
||||
_node.entity_attachments = &nodes[0]
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
if nodes := ac.mutation.ThumbnailIDs(); len(nodes) > 0 {
|
||||
if nodes := _c.mutation.ThumbnailIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2O,
|
||||
Inverse: false,
|
||||
@@ -377,16 +377,16 @@ type AttachmentCreateBulk struct {
|
||||
}
|
||||
|
||||
// Save creates the Attachment entities in the database.
|
||||
func (acb *AttachmentCreateBulk) Save(ctx context.Context) ([]*Attachment, error) {
|
||||
if acb.err != nil {
|
||||
return nil, acb.err
|
||||
func (_c *AttachmentCreateBulk) Save(ctx context.Context) ([]*Attachment, error) {
|
||||
if _c.err != nil {
|
||||
return nil, _c.err
|
||||
}
|
||||
specs := make([]*sqlgraph.CreateSpec, len(acb.builders))
|
||||
nodes := make([]*Attachment, len(acb.builders))
|
||||
mutators := make([]Mutator, len(acb.builders))
|
||||
for i := range acb.builders {
|
||||
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
||||
nodes := make([]*Attachment, len(_c.builders))
|
||||
mutators := make([]Mutator, len(_c.builders))
|
||||
for i := range _c.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := acb.builders[i]
|
||||
builder := _c.builders[i]
|
||||
builder.defaults()
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*AttachmentMutation)
|
||||
@@ -400,11 +400,11 @@ func (acb *AttachmentCreateBulk) Save(ctx context.Context) ([]*Attachment, error
|
||||
var err error
|
||||
nodes[i], specs[i] = builder.createSpec()
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, acb.builders[i+1].mutation)
|
||||
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
|
||||
} else {
|
||||
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
||||
// Invoke the actual operation on the latest mutation in the chain.
|
||||
if err = sqlgraph.BatchCreate(ctx, acb.driver, spec); err != nil {
|
||||
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
@@ -424,7 +424,7 @@ func (acb *AttachmentCreateBulk) Save(ctx context.Context) ([]*Attachment, error
|
||||
}(i, ctx)
|
||||
}
|
||||
if len(mutators) > 0 {
|
||||
if _, err := mutators[0].Mutate(ctx, acb.builders[0].mutation); err != nil {
|
||||
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
@@ -432,8 +432,8 @@ func (acb *AttachmentCreateBulk) Save(ctx context.Context) ([]*Attachment, error
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (acb *AttachmentCreateBulk) SaveX(ctx context.Context) []*Attachment {
|
||||
v, err := acb.Save(ctx)
|
||||
func (_c *AttachmentCreateBulk) SaveX(ctx context.Context) []*Attachment {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -441,14 +441,14 @@ func (acb *AttachmentCreateBulk) SaveX(ctx context.Context) []*Attachment {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (acb *AttachmentCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := acb.Save(ctx)
|
||||
func (_c *AttachmentCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (acb *AttachmentCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := acb.Exec(ctx); err != nil {
|
||||
func (_c *AttachmentCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,56 +20,56 @@ type AttachmentDelete struct {
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the AttachmentDelete builder.
|
||||
func (ad *AttachmentDelete) Where(ps ...predicate.Attachment) *AttachmentDelete {
|
||||
ad.mutation.Where(ps...)
|
||||
return ad
|
||||
func (_d *AttachmentDelete) Where(ps ...predicate.Attachment) *AttachmentDelete {
|
||||
_d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (ad *AttachmentDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, ad.sqlExec, ad.mutation, ad.hooks)
|
||||
func (_d *AttachmentDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (ad *AttachmentDelete) ExecX(ctx context.Context) int {
|
||||
n, err := ad.Exec(ctx)
|
||||
func (_d *AttachmentDelete) ExecX(ctx context.Context) int {
|
||||
n, err := _d.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (ad *AttachmentDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
func (_d *AttachmentDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := sqlgraph.NewDeleteSpec(attachment.Table, sqlgraph.NewFieldSpec(attachment.FieldID, field.TypeUUID))
|
||||
if ps := ad.mutation.predicates; len(ps) > 0 {
|
||||
if ps := _d.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, ad.driver, _spec)
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec)
|
||||
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
ad.mutation.done = true
|
||||
_d.mutation.done = true
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// AttachmentDeleteOne is the builder for deleting a single Attachment entity.
|
||||
type AttachmentDeleteOne struct {
|
||||
ad *AttachmentDelete
|
||||
_d *AttachmentDelete
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the AttachmentDelete builder.
|
||||
func (ado *AttachmentDeleteOne) Where(ps ...predicate.Attachment) *AttachmentDeleteOne {
|
||||
ado.ad.mutation.Where(ps...)
|
||||
return ado
|
||||
func (_d *AttachmentDeleteOne) Where(ps ...predicate.Attachment) *AttachmentDeleteOne {
|
||||
_d._d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (ado *AttachmentDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := ado.ad.Exec(ctx)
|
||||
func (_d *AttachmentDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := _d._d.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
@@ -81,8 +81,8 @@ func (ado *AttachmentDeleteOne) Exec(ctx context.Context) error {
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (ado *AttachmentDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := ado.Exec(ctx); err != nil {
|
||||
func (_d *AttachmentDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := _d.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,44 +33,44 @@ type AttachmentQuery struct {
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the AttachmentQuery builder.
|
||||
func (aq *AttachmentQuery) Where(ps ...predicate.Attachment) *AttachmentQuery {
|
||||
aq.predicates = append(aq.predicates, ps...)
|
||||
return aq
|
||||
func (_q *AttachmentQuery) Where(ps ...predicate.Attachment) *AttachmentQuery {
|
||||
_q.predicates = append(_q.predicates, ps...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// Limit the number of records to be returned by this query.
|
||||
func (aq *AttachmentQuery) Limit(limit int) *AttachmentQuery {
|
||||
aq.ctx.Limit = &limit
|
||||
return aq
|
||||
func (_q *AttachmentQuery) Limit(limit int) *AttachmentQuery {
|
||||
_q.ctx.Limit = &limit
|
||||
return _q
|
||||
}
|
||||
|
||||
// Offset to start from.
|
||||
func (aq *AttachmentQuery) Offset(offset int) *AttachmentQuery {
|
||||
aq.ctx.Offset = &offset
|
||||
return aq
|
||||
func (_q *AttachmentQuery) Offset(offset int) *AttachmentQuery {
|
||||
_q.ctx.Offset = &offset
|
||||
return _q
|
||||
}
|
||||
|
||||
// Unique configures the query builder to filter duplicate records on query.
|
||||
// By default, unique is set to true, and can be disabled using this method.
|
||||
func (aq *AttachmentQuery) Unique(unique bool) *AttachmentQuery {
|
||||
aq.ctx.Unique = &unique
|
||||
return aq
|
||||
func (_q *AttachmentQuery) Unique(unique bool) *AttachmentQuery {
|
||||
_q.ctx.Unique = &unique
|
||||
return _q
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (aq *AttachmentQuery) Order(o ...attachment.OrderOption) *AttachmentQuery {
|
||||
aq.order = append(aq.order, o...)
|
||||
return aq
|
||||
func (_q *AttachmentQuery) Order(o ...attachment.OrderOption) *AttachmentQuery {
|
||||
_q.order = append(_q.order, o...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// QueryEntity chains the current query on the "entity" edge.
|
||||
func (aq *AttachmentQuery) QueryEntity() *EntityQuery {
|
||||
query := (&EntityClient{config: aq.config}).Query()
|
||||
func (_q *AttachmentQuery) QueryEntity() *EntityQuery {
|
||||
query := (&EntityClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := aq.prepareQuery(ctx); err != nil {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := aq.sqlQuery(ctx)
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -79,20 +79,20 @@ func (aq *AttachmentQuery) QueryEntity() *EntityQuery {
|
||||
sqlgraph.To(entity.Table, entity.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, attachment.EntityTable, attachment.EntityColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(aq.driver.Dialect(), step)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryThumbnail chains the current query on the "thumbnail" edge.
|
||||
func (aq *AttachmentQuery) QueryThumbnail() *AttachmentQuery {
|
||||
query := (&AttachmentClient{config: aq.config}).Query()
|
||||
func (_q *AttachmentQuery) QueryThumbnail() *AttachmentQuery {
|
||||
query := (&AttachmentClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := aq.prepareQuery(ctx); err != nil {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := aq.sqlQuery(ctx)
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -101,7 +101,7 @@ func (aq *AttachmentQuery) QueryThumbnail() *AttachmentQuery {
|
||||
sqlgraph.To(attachment.Table, attachment.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2O, false, attachment.ThumbnailTable, attachment.ThumbnailColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(aq.driver.Dialect(), step)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
@@ -109,8 +109,8 @@ func (aq *AttachmentQuery) QueryThumbnail() *AttachmentQuery {
|
||||
|
||||
// First returns the first Attachment entity from the query.
|
||||
// Returns a *NotFoundError when no Attachment was found.
|
||||
func (aq *AttachmentQuery) First(ctx context.Context) (*Attachment, error) {
|
||||
nodes, err := aq.Limit(1).All(setContextOp(ctx, aq.ctx, ent.OpQueryFirst))
|
||||
func (_q *AttachmentQuery) First(ctx context.Context) (*Attachment, error) {
|
||||
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -121,8 +121,8 @@ func (aq *AttachmentQuery) First(ctx context.Context) (*Attachment, error) {
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (aq *AttachmentQuery) FirstX(ctx context.Context) *Attachment {
|
||||
node, err := aq.First(ctx)
|
||||
func (_q *AttachmentQuery) FirstX(ctx context.Context) *Attachment {
|
||||
node, err := _q.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
@@ -131,9 +131,9 @@ func (aq *AttachmentQuery) FirstX(ctx context.Context) *Attachment {
|
||||
|
||||
// FirstID returns the first Attachment ID from the query.
|
||||
// Returns a *NotFoundError when no Attachment ID was found.
|
||||
func (aq *AttachmentQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
func (_q *AttachmentQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
var ids []uuid.UUID
|
||||
if ids, err = aq.Limit(1).IDs(setContextOp(ctx, aq.ctx, ent.OpQueryFirstID)); err != nil {
|
||||
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
@@ -144,8 +144,8 @@ func (aq *AttachmentQuery) FirstID(ctx context.Context) (id uuid.UUID, err error
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (aq *AttachmentQuery) FirstIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := aq.FirstID(ctx)
|
||||
func (_q *AttachmentQuery) FirstIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := _q.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
@@ -155,8 +155,8 @@ func (aq *AttachmentQuery) FirstIDX(ctx context.Context) uuid.UUID {
|
||||
// Only returns a single Attachment entity found by the query, ensuring it only returns one.
|
||||
// Returns a *NotSingularError when more than one Attachment entity is found.
|
||||
// Returns a *NotFoundError when no Attachment entities are found.
|
||||
func (aq *AttachmentQuery) Only(ctx context.Context) (*Attachment, error) {
|
||||
nodes, err := aq.Limit(2).All(setContextOp(ctx, aq.ctx, ent.OpQueryOnly))
|
||||
func (_q *AttachmentQuery) Only(ctx context.Context) (*Attachment, error) {
|
||||
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -171,8 +171,8 @@ func (aq *AttachmentQuery) Only(ctx context.Context) (*Attachment, error) {
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (aq *AttachmentQuery) OnlyX(ctx context.Context) *Attachment {
|
||||
node, err := aq.Only(ctx)
|
||||
func (_q *AttachmentQuery) OnlyX(ctx context.Context) *Attachment {
|
||||
node, err := _q.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -182,9 +182,9 @@ func (aq *AttachmentQuery) OnlyX(ctx context.Context) *Attachment {
|
||||
// OnlyID is like Only, but returns the only Attachment ID in the query.
|
||||
// Returns a *NotSingularError when more than one Attachment ID is found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (aq *AttachmentQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
func (_q *AttachmentQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
var ids []uuid.UUID
|
||||
if ids, err = aq.Limit(2).IDs(setContextOp(ctx, aq.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
@@ -199,8 +199,8 @@ func (aq *AttachmentQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error)
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (aq *AttachmentQuery) OnlyIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := aq.OnlyID(ctx)
|
||||
func (_q *AttachmentQuery) OnlyIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := _q.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -208,18 +208,18 @@ func (aq *AttachmentQuery) OnlyIDX(ctx context.Context) uuid.UUID {
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of Attachments.
|
||||
func (aq *AttachmentQuery) All(ctx context.Context) ([]*Attachment, error) {
|
||||
ctx = setContextOp(ctx, aq.ctx, ent.OpQueryAll)
|
||||
if err := aq.prepareQuery(ctx); err != nil {
|
||||
func (_q *AttachmentQuery) All(ctx context.Context) ([]*Attachment, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qr := querierAll[[]*Attachment, *AttachmentQuery]()
|
||||
return withInterceptors[[]*Attachment](ctx, aq, qr, aq.inters)
|
||||
return withInterceptors[[]*Attachment](ctx, _q, qr, _q.inters)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (aq *AttachmentQuery) AllX(ctx context.Context) []*Attachment {
|
||||
nodes, err := aq.All(ctx)
|
||||
func (_q *AttachmentQuery) AllX(ctx context.Context) []*Attachment {
|
||||
nodes, err := _q.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -227,20 +227,20 @@ func (aq *AttachmentQuery) AllX(ctx context.Context) []*Attachment {
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of Attachment IDs.
|
||||
func (aq *AttachmentQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
|
||||
if aq.ctx.Unique == nil && aq.path != nil {
|
||||
aq.Unique(true)
|
||||
func (_q *AttachmentQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
|
||||
if _q.ctx.Unique == nil && _q.path != nil {
|
||||
_q.Unique(true)
|
||||
}
|
||||
ctx = setContextOp(ctx, aq.ctx, ent.OpQueryIDs)
|
||||
if err = aq.Select(attachment.FieldID).Scan(ctx, &ids); err != nil {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
|
||||
if err = _q.Select(attachment.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (aq *AttachmentQuery) IDsX(ctx context.Context) []uuid.UUID {
|
||||
ids, err := aq.IDs(ctx)
|
||||
func (_q *AttachmentQuery) IDsX(ctx context.Context) []uuid.UUID {
|
||||
ids, err := _q.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -248,17 +248,17 @@ func (aq *AttachmentQuery) IDsX(ctx context.Context) []uuid.UUID {
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (aq *AttachmentQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, aq.ctx, ent.OpQueryCount)
|
||||
if err := aq.prepareQuery(ctx); err != nil {
|
||||
func (_q *AttachmentQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return withInterceptors[int](ctx, aq, querierCount[*AttachmentQuery](), aq.inters)
|
||||
return withInterceptors[int](ctx, _q, querierCount[*AttachmentQuery](), _q.inters)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (aq *AttachmentQuery) CountX(ctx context.Context) int {
|
||||
count, err := aq.Count(ctx)
|
||||
func (_q *AttachmentQuery) CountX(ctx context.Context) int {
|
||||
count, err := _q.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -266,9 +266,9 @@ func (aq *AttachmentQuery) CountX(ctx context.Context) int {
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (aq *AttachmentQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, aq.ctx, ent.OpQueryExist)
|
||||
switch _, err := aq.FirstID(ctx); {
|
||||
func (_q *AttachmentQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
|
||||
switch _, err := _q.FirstID(ctx); {
|
||||
case IsNotFound(err):
|
||||
return false, nil
|
||||
case err != nil:
|
||||
@@ -279,8 +279,8 @@ func (aq *AttachmentQuery) Exist(ctx context.Context) (bool, error) {
|
||||
}
|
||||
|
||||
// ExistX is like Exist, but panics if an error occurs.
|
||||
func (aq *AttachmentQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := aq.Exist(ctx)
|
||||
func (_q *AttachmentQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := _q.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -289,44 +289,44 @@ func (aq *AttachmentQuery) ExistX(ctx context.Context) bool {
|
||||
|
||||
// Clone returns a duplicate of the AttachmentQuery builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (aq *AttachmentQuery) Clone() *AttachmentQuery {
|
||||
if aq == nil {
|
||||
func (_q *AttachmentQuery) Clone() *AttachmentQuery {
|
||||
if _q == nil {
|
||||
return nil
|
||||
}
|
||||
return &AttachmentQuery{
|
||||
config: aq.config,
|
||||
ctx: aq.ctx.Clone(),
|
||||
order: append([]attachment.OrderOption{}, aq.order...),
|
||||
inters: append([]Interceptor{}, aq.inters...),
|
||||
predicates: append([]predicate.Attachment{}, aq.predicates...),
|
||||
withEntity: aq.withEntity.Clone(),
|
||||
withThumbnail: aq.withThumbnail.Clone(),
|
||||
config: _q.config,
|
||||
ctx: _q.ctx.Clone(),
|
||||
order: append([]attachment.OrderOption{}, _q.order...),
|
||||
inters: append([]Interceptor{}, _q.inters...),
|
||||
predicates: append([]predicate.Attachment{}, _q.predicates...),
|
||||
withEntity: _q.withEntity.Clone(),
|
||||
withThumbnail: _q.withThumbnail.Clone(),
|
||||
// clone intermediate query.
|
||||
sql: aq.sql.Clone(),
|
||||
path: aq.path,
|
||||
sql: _q.sql.Clone(),
|
||||
path: _q.path,
|
||||
}
|
||||
}
|
||||
|
||||
// WithEntity tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "entity" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (aq *AttachmentQuery) WithEntity(opts ...func(*EntityQuery)) *AttachmentQuery {
|
||||
query := (&EntityClient{config: aq.config}).Query()
|
||||
func (_q *AttachmentQuery) WithEntity(opts ...func(*EntityQuery)) *AttachmentQuery {
|
||||
query := (&EntityClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
aq.withEntity = query
|
||||
return aq
|
||||
_q.withEntity = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// WithThumbnail tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "thumbnail" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (aq *AttachmentQuery) WithThumbnail(opts ...func(*AttachmentQuery)) *AttachmentQuery {
|
||||
query := (&AttachmentClient{config: aq.config}).Query()
|
||||
func (_q *AttachmentQuery) WithThumbnail(opts ...func(*AttachmentQuery)) *AttachmentQuery {
|
||||
query := (&AttachmentClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
aq.withThumbnail = query
|
||||
return aq
|
||||
_q.withThumbnail = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// GroupBy is used to group vertices by one or more fields/columns.
|
||||
@@ -343,10 +343,10 @@ func (aq *AttachmentQuery) WithThumbnail(opts ...func(*AttachmentQuery)) *Attach
|
||||
// GroupBy(attachment.FieldCreatedAt).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (aq *AttachmentQuery) GroupBy(field string, fields ...string) *AttachmentGroupBy {
|
||||
aq.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &AttachmentGroupBy{build: aq}
|
||||
grbuild.flds = &aq.ctx.Fields
|
||||
func (_q *AttachmentQuery) GroupBy(field string, fields ...string) *AttachmentGroupBy {
|
||||
_q.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &AttachmentGroupBy{build: _q}
|
||||
grbuild.flds = &_q.ctx.Fields
|
||||
grbuild.label = attachment.Label
|
||||
grbuild.scan = grbuild.Scan
|
||||
return grbuild
|
||||
@@ -364,56 +364,56 @@ func (aq *AttachmentQuery) GroupBy(field string, fields ...string) *AttachmentGr
|
||||
// client.Attachment.Query().
|
||||
// Select(attachment.FieldCreatedAt).
|
||||
// Scan(ctx, &v)
|
||||
func (aq *AttachmentQuery) Select(fields ...string) *AttachmentSelect {
|
||||
aq.ctx.Fields = append(aq.ctx.Fields, fields...)
|
||||
sbuild := &AttachmentSelect{AttachmentQuery: aq}
|
||||
func (_q *AttachmentQuery) Select(fields ...string) *AttachmentSelect {
|
||||
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
||||
sbuild := &AttachmentSelect{AttachmentQuery: _q}
|
||||
sbuild.label = attachment.Label
|
||||
sbuild.flds, sbuild.scan = &aq.ctx.Fields, sbuild.Scan
|
||||
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
|
||||
return sbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a AttachmentSelect configured with the given aggregations.
|
||||
func (aq *AttachmentQuery) Aggregate(fns ...AggregateFunc) *AttachmentSelect {
|
||||
return aq.Select().Aggregate(fns...)
|
||||
func (_q *AttachmentQuery) Aggregate(fns ...AggregateFunc) *AttachmentSelect {
|
||||
return _q.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (aq *AttachmentQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range aq.inters {
|
||||
func (_q *AttachmentQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range _q.inters {
|
||||
if inter == nil {
|
||||
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
|
||||
}
|
||||
if trv, ok := inter.(Traverser); ok {
|
||||
if err := trv.Traverse(ctx, aq); err != nil {
|
||||
if err := trv.Traverse(ctx, _q); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, f := range aq.ctx.Fields {
|
||||
for _, f := range _q.ctx.Fields {
|
||||
if !attachment.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
}
|
||||
if aq.path != nil {
|
||||
prev, err := aq.path(ctx)
|
||||
if _q.path != nil {
|
||||
prev, err := _q.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
aq.sql = prev
|
||||
_q.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (aq *AttachmentQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Attachment, error) {
|
||||
func (_q *AttachmentQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Attachment, error) {
|
||||
var (
|
||||
nodes = []*Attachment{}
|
||||
withFKs = aq.withFKs
|
||||
_spec = aq.querySpec()
|
||||
withFKs = _q.withFKs
|
||||
_spec = _q.querySpec()
|
||||
loadedTypes = [2]bool{
|
||||
aq.withEntity != nil,
|
||||
aq.withThumbnail != nil,
|
||||
_q.withEntity != nil,
|
||||
_q.withThumbnail != nil,
|
||||
}
|
||||
)
|
||||
if aq.withEntity != nil || aq.withThumbnail != nil {
|
||||
if _q.withEntity != nil || _q.withThumbnail != nil {
|
||||
withFKs = true
|
||||
}
|
||||
if withFKs {
|
||||
@@ -423,7 +423,7 @@ func (aq *AttachmentQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*A
|
||||
return (*Attachment).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &Attachment{config: aq.config}
|
||||
node := &Attachment{config: _q.config}
|
||||
nodes = append(nodes, node)
|
||||
node.Edges.loadedTypes = loadedTypes
|
||||
return node.assignValues(columns, values)
|
||||
@@ -431,20 +431,20 @@ func (aq *AttachmentQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*A
|
||||
for i := range hooks {
|
||||
hooks[i](ctx, _spec)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, aq.driver, _spec); err != nil {
|
||||
if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
if query := aq.withEntity; query != nil {
|
||||
if err := aq.loadEntity(ctx, query, nodes, nil,
|
||||
if query := _q.withEntity; query != nil {
|
||||
if err := _q.loadEntity(ctx, query, nodes, nil,
|
||||
func(n *Attachment, e *Entity) { n.Edges.Entity = e }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if query := aq.withThumbnail; query != nil {
|
||||
if err := aq.loadThumbnail(ctx, query, nodes, nil,
|
||||
if query := _q.withThumbnail; query != nil {
|
||||
if err := _q.loadThumbnail(ctx, query, nodes, nil,
|
||||
func(n *Attachment, e *Attachment) { n.Edges.Thumbnail = e }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -452,7 +452,7 @@ func (aq *AttachmentQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*A
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (aq *AttachmentQuery) loadEntity(ctx context.Context, query *EntityQuery, nodes []*Attachment, init func(*Attachment), assign func(*Attachment, *Entity)) error {
|
||||
func (_q *AttachmentQuery) loadEntity(ctx context.Context, query *EntityQuery, nodes []*Attachment, init func(*Attachment), assign func(*Attachment, *Entity)) error {
|
||||
ids := make([]uuid.UUID, 0, len(nodes))
|
||||
nodeids := make(map[uuid.UUID][]*Attachment)
|
||||
for i := range nodes {
|
||||
@@ -484,7 +484,7 @@ func (aq *AttachmentQuery) loadEntity(ctx context.Context, query *EntityQuery, n
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (aq *AttachmentQuery) loadThumbnail(ctx context.Context, query *AttachmentQuery, nodes []*Attachment, init func(*Attachment), assign func(*Attachment, *Attachment)) error {
|
||||
func (_q *AttachmentQuery) loadThumbnail(ctx context.Context, query *AttachmentQuery, nodes []*Attachment, init func(*Attachment), assign func(*Attachment, *Attachment)) error {
|
||||
ids := make([]uuid.UUID, 0, len(nodes))
|
||||
nodeids := make(map[uuid.UUID][]*Attachment)
|
||||
for i := range nodes {
|
||||
@@ -517,24 +517,24 @@ func (aq *AttachmentQuery) loadThumbnail(ctx context.Context, query *AttachmentQ
|
||||
return nil
|
||||
}
|
||||
|
||||
func (aq *AttachmentQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := aq.querySpec()
|
||||
_spec.Node.Columns = aq.ctx.Fields
|
||||
if len(aq.ctx.Fields) > 0 {
|
||||
_spec.Unique = aq.ctx.Unique != nil && *aq.ctx.Unique
|
||||
func (_q *AttachmentQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := _q.querySpec()
|
||||
_spec.Node.Columns = _q.ctx.Fields
|
||||
if len(_q.ctx.Fields) > 0 {
|
||||
_spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, aq.driver, _spec)
|
||||
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
|
||||
}
|
||||
|
||||
func (aq *AttachmentQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
func (_q *AttachmentQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := sqlgraph.NewQuerySpec(attachment.Table, attachment.Columns, sqlgraph.NewFieldSpec(attachment.FieldID, field.TypeUUID))
|
||||
_spec.From = aq.sql
|
||||
if unique := aq.ctx.Unique; unique != nil {
|
||||
_spec.From = _q.sql
|
||||
if unique := _q.ctx.Unique; unique != nil {
|
||||
_spec.Unique = *unique
|
||||
} else if aq.path != nil {
|
||||
} else if _q.path != nil {
|
||||
_spec.Unique = true
|
||||
}
|
||||
if fields := aq.ctx.Fields; len(fields) > 0 {
|
||||
if fields := _q.ctx.Fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, attachment.FieldID)
|
||||
for i := range fields {
|
||||
@@ -543,20 +543,20 @@ func (aq *AttachmentQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := aq.predicates; len(ps) > 0 {
|
||||
if ps := _q.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := aq.ctx.Limit; limit != nil {
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := aq.ctx.Offset; offset != nil {
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := aq.order; len(ps) > 0 {
|
||||
if ps := _q.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
@@ -566,33 +566,33 @@ func (aq *AttachmentQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (aq *AttachmentQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(aq.driver.Dialect())
|
||||
func (_q *AttachmentQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(_q.driver.Dialect())
|
||||
t1 := builder.Table(attachment.Table)
|
||||
columns := aq.ctx.Fields
|
||||
columns := _q.ctx.Fields
|
||||
if len(columns) == 0 {
|
||||
columns = attachment.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if aq.sql != nil {
|
||||
selector = aq.sql
|
||||
if _q.sql != nil {
|
||||
selector = _q.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
if aq.ctx.Unique != nil && *aq.ctx.Unique {
|
||||
if _q.ctx.Unique != nil && *_q.ctx.Unique {
|
||||
selector.Distinct()
|
||||
}
|
||||
for _, p := range aq.predicates {
|
||||
for _, p := range _q.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range aq.order {
|
||||
for _, p := range _q.order {
|
||||
p(selector)
|
||||
}
|
||||
if offset := aq.ctx.Offset; offset != nil {
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
// limit is mandatory for offset clause. We start
|
||||
// with default value, and override it below if needed.
|
||||
selector.Offset(*offset).Limit(math.MaxInt32)
|
||||
}
|
||||
if limit := aq.ctx.Limit; limit != nil {
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
@@ -605,41 +605,41 @@ type AttachmentGroupBy struct {
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (agb *AttachmentGroupBy) Aggregate(fns ...AggregateFunc) *AttachmentGroupBy {
|
||||
agb.fns = append(agb.fns, fns...)
|
||||
return agb
|
||||
func (_g *AttachmentGroupBy) Aggregate(fns ...AggregateFunc) *AttachmentGroupBy {
|
||||
_g.fns = append(_g.fns, fns...)
|
||||
return _g
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (agb *AttachmentGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, agb.build.ctx, ent.OpQueryGroupBy)
|
||||
if err := agb.build.prepareQuery(ctx); err != nil {
|
||||
func (_g *AttachmentGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
|
||||
if err := _g.build.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*AttachmentQuery, *AttachmentGroupBy](ctx, agb.build, agb, agb.build.inters, v)
|
||||
return scanWithInterceptors[*AttachmentQuery, *AttachmentGroupBy](ctx, _g.build, _g, _g.build.inters, v)
|
||||
}
|
||||
|
||||
func (agb *AttachmentGroupBy) sqlScan(ctx context.Context, root *AttachmentQuery, v any) error {
|
||||
func (_g *AttachmentGroupBy) sqlScan(ctx context.Context, root *AttachmentQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx).Select()
|
||||
aggregation := make([]string, 0, len(agb.fns))
|
||||
for _, fn := range agb.fns {
|
||||
aggregation := make([]string, 0, len(_g.fns))
|
||||
for _, fn := range _g.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(*agb.flds)+len(agb.fns))
|
||||
for _, f := range *agb.flds {
|
||||
columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
|
||||
for _, f := range *_g.flds {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
columns = append(columns, aggregation...)
|
||||
selector.Select(columns...)
|
||||
}
|
||||
selector.GroupBy(selector.Columns(*agb.flds...)...)
|
||||
selector.GroupBy(selector.Columns(*_g.flds...)...)
|
||||
if err := selector.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := agb.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
@@ -653,27 +653,27 @@ type AttachmentSelect struct {
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (as *AttachmentSelect) Aggregate(fns ...AggregateFunc) *AttachmentSelect {
|
||||
as.fns = append(as.fns, fns...)
|
||||
return as
|
||||
func (_s *AttachmentSelect) Aggregate(fns ...AggregateFunc) *AttachmentSelect {
|
||||
_s.fns = append(_s.fns, fns...)
|
||||
return _s
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (as *AttachmentSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, as.ctx, ent.OpQuerySelect)
|
||||
if err := as.prepareQuery(ctx); err != nil {
|
||||
func (_s *AttachmentSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
|
||||
if err := _s.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*AttachmentQuery, *AttachmentSelect](ctx, as.AttachmentQuery, as, as.inters, v)
|
||||
return scanWithInterceptors[*AttachmentQuery, *AttachmentSelect](ctx, _s.AttachmentQuery, _s, _s.inters, v)
|
||||
}
|
||||
|
||||
func (as *AttachmentSelect) sqlScan(ctx context.Context, root *AttachmentQuery, v any) error {
|
||||
func (_s *AttachmentSelect) sqlScan(ctx context.Context, root *AttachmentQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx)
|
||||
aggregation := make([]string, 0, len(as.fns))
|
||||
for _, fn := range as.fns {
|
||||
aggregation := make([]string, 0, len(_s.fns))
|
||||
for _, fn := range _s.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
switch n := len(*as.selector.flds); {
|
||||
switch n := len(*_s.selector.flds); {
|
||||
case n == 0 && len(aggregation) > 0:
|
||||
selector.Select(aggregation...)
|
||||
case n != 0 && len(aggregation) > 0:
|
||||
@@ -681,7 +681,7 @@ func (as *AttachmentSelect) sqlScan(ctx context.Context, root *AttachmentQuery,
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := as.driver.Query(ctx, query, args, rows); err != nil {
|
||||
if err := _s.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
@@ -25,151 +25,151 @@ type AttachmentUpdate struct {
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the AttachmentUpdate builder.
|
||||
func (au *AttachmentUpdate) Where(ps ...predicate.Attachment) *AttachmentUpdate {
|
||||
au.mutation.Where(ps...)
|
||||
return au
|
||||
func (_u *AttachmentUpdate) Where(ps ...predicate.Attachment) *AttachmentUpdate {
|
||||
_u.mutation.Where(ps...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (au *AttachmentUpdate) SetUpdatedAt(t time.Time) *AttachmentUpdate {
|
||||
au.mutation.SetUpdatedAt(t)
|
||||
return au
|
||||
func (_u *AttachmentUpdate) SetUpdatedAt(v time.Time) *AttachmentUpdate {
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetType sets the "type" field.
|
||||
func (au *AttachmentUpdate) SetType(a attachment.Type) *AttachmentUpdate {
|
||||
au.mutation.SetType(a)
|
||||
return au
|
||||
func (_u *AttachmentUpdate) SetType(v attachment.Type) *AttachmentUpdate {
|
||||
_u.mutation.SetType(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableType sets the "type" field if the given value is not nil.
|
||||
func (au *AttachmentUpdate) SetNillableType(a *attachment.Type) *AttachmentUpdate {
|
||||
if a != nil {
|
||||
au.SetType(*a)
|
||||
func (_u *AttachmentUpdate) SetNillableType(v *attachment.Type) *AttachmentUpdate {
|
||||
if v != nil {
|
||||
_u.SetType(*v)
|
||||
}
|
||||
return au
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetPrimary sets the "primary" field.
|
||||
func (au *AttachmentUpdate) SetPrimary(b bool) *AttachmentUpdate {
|
||||
au.mutation.SetPrimary(b)
|
||||
return au
|
||||
func (_u *AttachmentUpdate) SetPrimary(v bool) *AttachmentUpdate {
|
||||
_u.mutation.SetPrimary(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillablePrimary sets the "primary" field if the given value is not nil.
|
||||
func (au *AttachmentUpdate) SetNillablePrimary(b *bool) *AttachmentUpdate {
|
||||
if b != nil {
|
||||
au.SetPrimary(*b)
|
||||
func (_u *AttachmentUpdate) SetNillablePrimary(v *bool) *AttachmentUpdate {
|
||||
if v != nil {
|
||||
_u.SetPrimary(*v)
|
||||
}
|
||||
return au
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetTitle sets the "title" field.
|
||||
func (au *AttachmentUpdate) SetTitle(s string) *AttachmentUpdate {
|
||||
au.mutation.SetTitle(s)
|
||||
return au
|
||||
func (_u *AttachmentUpdate) SetTitle(v string) *AttachmentUpdate {
|
||||
_u.mutation.SetTitle(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableTitle sets the "title" field if the given value is not nil.
|
||||
func (au *AttachmentUpdate) SetNillableTitle(s *string) *AttachmentUpdate {
|
||||
if s != nil {
|
||||
au.SetTitle(*s)
|
||||
func (_u *AttachmentUpdate) SetNillableTitle(v *string) *AttachmentUpdate {
|
||||
if v != nil {
|
||||
_u.SetTitle(*v)
|
||||
}
|
||||
return au
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetPath sets the "path" field.
|
||||
func (au *AttachmentUpdate) SetPath(s string) *AttachmentUpdate {
|
||||
au.mutation.SetPath(s)
|
||||
return au
|
||||
func (_u *AttachmentUpdate) SetPath(v string) *AttachmentUpdate {
|
||||
_u.mutation.SetPath(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillablePath sets the "path" field if the given value is not nil.
|
||||
func (au *AttachmentUpdate) SetNillablePath(s *string) *AttachmentUpdate {
|
||||
if s != nil {
|
||||
au.SetPath(*s)
|
||||
func (_u *AttachmentUpdate) SetNillablePath(v *string) *AttachmentUpdate {
|
||||
if v != nil {
|
||||
_u.SetPath(*v)
|
||||
}
|
||||
return au
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetMimeType sets the "mime_type" field.
|
||||
func (au *AttachmentUpdate) SetMimeType(s string) *AttachmentUpdate {
|
||||
au.mutation.SetMimeType(s)
|
||||
return au
|
||||
func (_u *AttachmentUpdate) SetMimeType(v string) *AttachmentUpdate {
|
||||
_u.mutation.SetMimeType(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableMimeType sets the "mime_type" field if the given value is not nil.
|
||||
func (au *AttachmentUpdate) SetNillableMimeType(s *string) *AttachmentUpdate {
|
||||
if s != nil {
|
||||
au.SetMimeType(*s)
|
||||
func (_u *AttachmentUpdate) SetNillableMimeType(v *string) *AttachmentUpdate {
|
||||
if v != nil {
|
||||
_u.SetMimeType(*v)
|
||||
}
|
||||
return au
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetEntityID sets the "entity" edge to the Entity entity by ID.
|
||||
func (au *AttachmentUpdate) SetEntityID(id uuid.UUID) *AttachmentUpdate {
|
||||
au.mutation.SetEntityID(id)
|
||||
return au
|
||||
func (_u *AttachmentUpdate) SetEntityID(id uuid.UUID) *AttachmentUpdate {
|
||||
_u.mutation.SetEntityID(id)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableEntityID sets the "entity" edge to the Entity entity by ID if the given value is not nil.
|
||||
func (au *AttachmentUpdate) SetNillableEntityID(id *uuid.UUID) *AttachmentUpdate {
|
||||
func (_u *AttachmentUpdate) SetNillableEntityID(id *uuid.UUID) *AttachmentUpdate {
|
||||
if id != nil {
|
||||
au = au.SetEntityID(*id)
|
||||
_u = _u.SetEntityID(*id)
|
||||
}
|
||||
return au
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetEntity sets the "entity" edge to the Entity entity.
|
||||
func (au *AttachmentUpdate) SetEntity(e *Entity) *AttachmentUpdate {
|
||||
return au.SetEntityID(e.ID)
|
||||
func (_u *AttachmentUpdate) SetEntity(v *Entity) *AttachmentUpdate {
|
||||
return _u.SetEntityID(v.ID)
|
||||
}
|
||||
|
||||
// SetThumbnailID sets the "thumbnail" edge to the Attachment entity by ID.
|
||||
func (au *AttachmentUpdate) SetThumbnailID(id uuid.UUID) *AttachmentUpdate {
|
||||
au.mutation.SetThumbnailID(id)
|
||||
return au
|
||||
func (_u *AttachmentUpdate) SetThumbnailID(id uuid.UUID) *AttachmentUpdate {
|
||||
_u.mutation.SetThumbnailID(id)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableThumbnailID sets the "thumbnail" edge to the Attachment entity by ID if the given value is not nil.
|
||||
func (au *AttachmentUpdate) SetNillableThumbnailID(id *uuid.UUID) *AttachmentUpdate {
|
||||
func (_u *AttachmentUpdate) SetNillableThumbnailID(id *uuid.UUID) *AttachmentUpdate {
|
||||
if id != nil {
|
||||
au = au.SetThumbnailID(*id)
|
||||
_u = _u.SetThumbnailID(*id)
|
||||
}
|
||||
return au
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetThumbnail sets the "thumbnail" edge to the Attachment entity.
|
||||
func (au *AttachmentUpdate) SetThumbnail(a *Attachment) *AttachmentUpdate {
|
||||
return au.SetThumbnailID(a.ID)
|
||||
func (_u *AttachmentUpdate) SetThumbnail(v *Attachment) *AttachmentUpdate {
|
||||
return _u.SetThumbnailID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the AttachmentMutation object of the builder.
|
||||
func (au *AttachmentUpdate) Mutation() *AttachmentMutation {
|
||||
return au.mutation
|
||||
func (_u *AttachmentUpdate) Mutation() *AttachmentMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// ClearEntity clears the "entity" edge to the Entity entity.
|
||||
func (au *AttachmentUpdate) ClearEntity() *AttachmentUpdate {
|
||||
au.mutation.ClearEntity()
|
||||
return au
|
||||
func (_u *AttachmentUpdate) ClearEntity() *AttachmentUpdate {
|
||||
_u.mutation.ClearEntity()
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearThumbnail clears the "thumbnail" edge to the Attachment entity.
|
||||
func (au *AttachmentUpdate) ClearThumbnail() *AttachmentUpdate {
|
||||
au.mutation.ClearThumbnail()
|
||||
return au
|
||||
func (_u *AttachmentUpdate) ClearThumbnail() *AttachmentUpdate {
|
||||
_u.mutation.ClearThumbnail()
|
||||
return _u
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (au *AttachmentUpdate) Save(ctx context.Context) (int, error) {
|
||||
au.defaults()
|
||||
return withHooks(ctx, au.sqlSave, au.mutation, au.hooks)
|
||||
func (_u *AttachmentUpdate) Save(ctx context.Context) (int, error) {
|
||||
_u.defaults()
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (au *AttachmentUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := au.Save(ctx)
|
||||
func (_u *AttachmentUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -177,29 +177,29 @@ func (au *AttachmentUpdate) SaveX(ctx context.Context) int {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (au *AttachmentUpdate) Exec(ctx context.Context) error {
|
||||
_, err := au.Save(ctx)
|
||||
func (_u *AttachmentUpdate) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (au *AttachmentUpdate) ExecX(ctx context.Context) {
|
||||
if err := au.Exec(ctx); err != nil {
|
||||
func (_u *AttachmentUpdate) ExecX(ctx context.Context) {
|
||||
if err := _u.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (au *AttachmentUpdate) defaults() {
|
||||
if _, ok := au.mutation.UpdatedAt(); !ok {
|
||||
func (_u *AttachmentUpdate) defaults() {
|
||||
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
||||
v := attachment.UpdateDefaultUpdatedAt()
|
||||
au.mutation.SetUpdatedAt(v)
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (au *AttachmentUpdate) check() error {
|
||||
if v, ok := au.mutation.GetType(); ok {
|
||||
func (_u *AttachmentUpdate) check() error {
|
||||
if v, ok := _u.mutation.GetType(); ok {
|
||||
if err := attachment.TypeValidator(v); err != nil {
|
||||
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Attachment.type": %w`, err)}
|
||||
}
|
||||
@@ -207,37 +207,37 @@ func (au *AttachmentUpdate) check() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (au *AttachmentUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
if err := au.check(); err != nil {
|
||||
return n, err
|
||||
func (_u *AttachmentUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
if err := _u.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(attachment.Table, attachment.Columns, sqlgraph.NewFieldSpec(attachment.FieldID, field.TypeUUID))
|
||||
if ps := au.mutation.predicates; len(ps) > 0 {
|
||||
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := au.mutation.UpdatedAt(); ok {
|
||||
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(attachment.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := au.mutation.GetType(); ok {
|
||||
if value, ok := _u.mutation.GetType(); ok {
|
||||
_spec.SetField(attachment.FieldType, field.TypeEnum, value)
|
||||
}
|
||||
if value, ok := au.mutation.Primary(); ok {
|
||||
if value, ok := _u.mutation.Primary(); ok {
|
||||
_spec.SetField(attachment.FieldPrimary, field.TypeBool, value)
|
||||
}
|
||||
if value, ok := au.mutation.Title(); ok {
|
||||
if value, ok := _u.mutation.Title(); ok {
|
||||
_spec.SetField(attachment.FieldTitle, field.TypeString, value)
|
||||
}
|
||||
if value, ok := au.mutation.Path(); ok {
|
||||
if value, ok := _u.mutation.Path(); ok {
|
||||
_spec.SetField(attachment.FieldPath, field.TypeString, value)
|
||||
}
|
||||
if value, ok := au.mutation.MimeType(); ok {
|
||||
if value, ok := _u.mutation.MimeType(); ok {
|
||||
_spec.SetField(attachment.FieldMimeType, field.TypeString, value)
|
||||
}
|
||||
if au.mutation.EntityCleared() {
|
||||
if _u.mutation.EntityCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -250,7 +250,7 @@ func (au *AttachmentUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := au.mutation.EntityIDs(); len(nodes) > 0 {
|
||||
if nodes := _u.mutation.EntityIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -266,7 +266,7 @@ func (au *AttachmentUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if au.mutation.ThumbnailCleared() {
|
||||
if _u.mutation.ThumbnailCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2O,
|
||||
Inverse: false,
|
||||
@@ -279,7 +279,7 @@ func (au *AttachmentUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := au.mutation.ThumbnailIDs(); len(nodes) > 0 {
|
||||
if nodes := _u.mutation.ThumbnailIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2O,
|
||||
Inverse: false,
|
||||
@@ -295,7 +295,7 @@ func (au *AttachmentUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, au.driver, _spec); err != nil {
|
||||
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{attachment.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
@@ -303,8 +303,8 @@ func (au *AttachmentUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
au.mutation.done = true
|
||||
return n, nil
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
// AttachmentUpdateOne is the builder for updating a single Attachment entity.
|
||||
@@ -316,158 +316,158 @@ type AttachmentUpdateOne struct {
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (auo *AttachmentUpdateOne) SetUpdatedAt(t time.Time) *AttachmentUpdateOne {
|
||||
auo.mutation.SetUpdatedAt(t)
|
||||
return auo
|
||||
func (_u *AttachmentUpdateOne) SetUpdatedAt(v time.Time) *AttachmentUpdateOne {
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetType sets the "type" field.
|
||||
func (auo *AttachmentUpdateOne) SetType(a attachment.Type) *AttachmentUpdateOne {
|
||||
auo.mutation.SetType(a)
|
||||
return auo
|
||||
func (_u *AttachmentUpdateOne) SetType(v attachment.Type) *AttachmentUpdateOne {
|
||||
_u.mutation.SetType(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableType sets the "type" field if the given value is not nil.
|
||||
func (auo *AttachmentUpdateOne) SetNillableType(a *attachment.Type) *AttachmentUpdateOne {
|
||||
if a != nil {
|
||||
auo.SetType(*a)
|
||||
func (_u *AttachmentUpdateOne) SetNillableType(v *attachment.Type) *AttachmentUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetType(*v)
|
||||
}
|
||||
return auo
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetPrimary sets the "primary" field.
|
||||
func (auo *AttachmentUpdateOne) SetPrimary(b bool) *AttachmentUpdateOne {
|
||||
auo.mutation.SetPrimary(b)
|
||||
return auo
|
||||
func (_u *AttachmentUpdateOne) SetPrimary(v bool) *AttachmentUpdateOne {
|
||||
_u.mutation.SetPrimary(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillablePrimary sets the "primary" field if the given value is not nil.
|
||||
func (auo *AttachmentUpdateOne) SetNillablePrimary(b *bool) *AttachmentUpdateOne {
|
||||
if b != nil {
|
||||
auo.SetPrimary(*b)
|
||||
func (_u *AttachmentUpdateOne) SetNillablePrimary(v *bool) *AttachmentUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetPrimary(*v)
|
||||
}
|
||||
return auo
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetTitle sets the "title" field.
|
||||
func (auo *AttachmentUpdateOne) SetTitle(s string) *AttachmentUpdateOne {
|
||||
auo.mutation.SetTitle(s)
|
||||
return auo
|
||||
func (_u *AttachmentUpdateOne) SetTitle(v string) *AttachmentUpdateOne {
|
||||
_u.mutation.SetTitle(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableTitle sets the "title" field if the given value is not nil.
|
||||
func (auo *AttachmentUpdateOne) SetNillableTitle(s *string) *AttachmentUpdateOne {
|
||||
if s != nil {
|
||||
auo.SetTitle(*s)
|
||||
func (_u *AttachmentUpdateOne) SetNillableTitle(v *string) *AttachmentUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetTitle(*v)
|
||||
}
|
||||
return auo
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetPath sets the "path" field.
|
||||
func (auo *AttachmentUpdateOne) SetPath(s string) *AttachmentUpdateOne {
|
||||
auo.mutation.SetPath(s)
|
||||
return auo
|
||||
func (_u *AttachmentUpdateOne) SetPath(v string) *AttachmentUpdateOne {
|
||||
_u.mutation.SetPath(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillablePath sets the "path" field if the given value is not nil.
|
||||
func (auo *AttachmentUpdateOne) SetNillablePath(s *string) *AttachmentUpdateOne {
|
||||
if s != nil {
|
||||
auo.SetPath(*s)
|
||||
func (_u *AttachmentUpdateOne) SetNillablePath(v *string) *AttachmentUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetPath(*v)
|
||||
}
|
||||
return auo
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetMimeType sets the "mime_type" field.
|
||||
func (auo *AttachmentUpdateOne) SetMimeType(s string) *AttachmentUpdateOne {
|
||||
auo.mutation.SetMimeType(s)
|
||||
return auo
|
||||
func (_u *AttachmentUpdateOne) SetMimeType(v string) *AttachmentUpdateOne {
|
||||
_u.mutation.SetMimeType(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableMimeType sets the "mime_type" field if the given value is not nil.
|
||||
func (auo *AttachmentUpdateOne) SetNillableMimeType(s *string) *AttachmentUpdateOne {
|
||||
if s != nil {
|
||||
auo.SetMimeType(*s)
|
||||
func (_u *AttachmentUpdateOne) SetNillableMimeType(v *string) *AttachmentUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetMimeType(*v)
|
||||
}
|
||||
return auo
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetEntityID sets the "entity" edge to the Entity entity by ID.
|
||||
func (auo *AttachmentUpdateOne) SetEntityID(id uuid.UUID) *AttachmentUpdateOne {
|
||||
auo.mutation.SetEntityID(id)
|
||||
return auo
|
||||
func (_u *AttachmentUpdateOne) SetEntityID(id uuid.UUID) *AttachmentUpdateOne {
|
||||
_u.mutation.SetEntityID(id)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableEntityID sets the "entity" edge to the Entity entity by ID if the given value is not nil.
|
||||
func (auo *AttachmentUpdateOne) SetNillableEntityID(id *uuid.UUID) *AttachmentUpdateOne {
|
||||
func (_u *AttachmentUpdateOne) SetNillableEntityID(id *uuid.UUID) *AttachmentUpdateOne {
|
||||
if id != nil {
|
||||
auo = auo.SetEntityID(*id)
|
||||
_u = _u.SetEntityID(*id)
|
||||
}
|
||||
return auo
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetEntity sets the "entity" edge to the Entity entity.
|
||||
func (auo *AttachmentUpdateOne) SetEntity(e *Entity) *AttachmentUpdateOne {
|
||||
return auo.SetEntityID(e.ID)
|
||||
func (_u *AttachmentUpdateOne) SetEntity(v *Entity) *AttachmentUpdateOne {
|
||||
return _u.SetEntityID(v.ID)
|
||||
}
|
||||
|
||||
// SetThumbnailID sets the "thumbnail" edge to the Attachment entity by ID.
|
||||
func (auo *AttachmentUpdateOne) SetThumbnailID(id uuid.UUID) *AttachmentUpdateOne {
|
||||
auo.mutation.SetThumbnailID(id)
|
||||
return auo
|
||||
func (_u *AttachmentUpdateOne) SetThumbnailID(id uuid.UUID) *AttachmentUpdateOne {
|
||||
_u.mutation.SetThumbnailID(id)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableThumbnailID sets the "thumbnail" edge to the Attachment entity by ID if the given value is not nil.
|
||||
func (auo *AttachmentUpdateOne) SetNillableThumbnailID(id *uuid.UUID) *AttachmentUpdateOne {
|
||||
func (_u *AttachmentUpdateOne) SetNillableThumbnailID(id *uuid.UUID) *AttachmentUpdateOne {
|
||||
if id != nil {
|
||||
auo = auo.SetThumbnailID(*id)
|
||||
_u = _u.SetThumbnailID(*id)
|
||||
}
|
||||
return auo
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetThumbnail sets the "thumbnail" edge to the Attachment entity.
|
||||
func (auo *AttachmentUpdateOne) SetThumbnail(a *Attachment) *AttachmentUpdateOne {
|
||||
return auo.SetThumbnailID(a.ID)
|
||||
func (_u *AttachmentUpdateOne) SetThumbnail(v *Attachment) *AttachmentUpdateOne {
|
||||
return _u.SetThumbnailID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the AttachmentMutation object of the builder.
|
||||
func (auo *AttachmentUpdateOne) Mutation() *AttachmentMutation {
|
||||
return auo.mutation
|
||||
func (_u *AttachmentUpdateOne) Mutation() *AttachmentMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// ClearEntity clears the "entity" edge to the Entity entity.
|
||||
func (auo *AttachmentUpdateOne) ClearEntity() *AttachmentUpdateOne {
|
||||
auo.mutation.ClearEntity()
|
||||
return auo
|
||||
func (_u *AttachmentUpdateOne) ClearEntity() *AttachmentUpdateOne {
|
||||
_u.mutation.ClearEntity()
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearThumbnail clears the "thumbnail" edge to the Attachment entity.
|
||||
func (auo *AttachmentUpdateOne) ClearThumbnail() *AttachmentUpdateOne {
|
||||
auo.mutation.ClearThumbnail()
|
||||
return auo
|
||||
func (_u *AttachmentUpdateOne) ClearThumbnail() *AttachmentUpdateOne {
|
||||
_u.mutation.ClearThumbnail()
|
||||
return _u
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the AttachmentUpdate builder.
|
||||
func (auo *AttachmentUpdateOne) Where(ps ...predicate.Attachment) *AttachmentUpdateOne {
|
||||
auo.mutation.Where(ps...)
|
||||
return auo
|
||||
func (_u *AttachmentUpdateOne) Where(ps ...predicate.Attachment) *AttachmentUpdateOne {
|
||||
_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 (auo *AttachmentUpdateOne) Select(field string, fields ...string) *AttachmentUpdateOne {
|
||||
auo.fields = append([]string{field}, fields...)
|
||||
return auo
|
||||
func (_u *AttachmentUpdateOne) Select(field string, fields ...string) *AttachmentUpdateOne {
|
||||
_u.fields = append([]string{field}, fields...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated Attachment entity.
|
||||
func (auo *AttachmentUpdateOne) Save(ctx context.Context) (*Attachment, error) {
|
||||
auo.defaults()
|
||||
return withHooks(ctx, auo.sqlSave, auo.mutation, auo.hooks)
|
||||
func (_u *AttachmentUpdateOne) Save(ctx context.Context) (*Attachment, error) {
|
||||
_u.defaults()
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (auo *AttachmentUpdateOne) SaveX(ctx context.Context) *Attachment {
|
||||
node, err := auo.Save(ctx)
|
||||
func (_u *AttachmentUpdateOne) SaveX(ctx context.Context) *Attachment {
|
||||
node, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -475,29 +475,29 @@ func (auo *AttachmentUpdateOne) SaveX(ctx context.Context) *Attachment {
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (auo *AttachmentUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := auo.Save(ctx)
|
||||
func (_u *AttachmentUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (auo *AttachmentUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := auo.Exec(ctx); err != nil {
|
||||
func (_u *AttachmentUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := _u.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (auo *AttachmentUpdateOne) defaults() {
|
||||
if _, ok := auo.mutation.UpdatedAt(); !ok {
|
||||
func (_u *AttachmentUpdateOne) defaults() {
|
||||
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
||||
v := attachment.UpdateDefaultUpdatedAt()
|
||||
auo.mutation.SetUpdatedAt(v)
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (auo *AttachmentUpdateOne) check() error {
|
||||
if v, ok := auo.mutation.GetType(); ok {
|
||||
func (_u *AttachmentUpdateOne) check() error {
|
||||
if v, ok := _u.mutation.GetType(); ok {
|
||||
if err := attachment.TypeValidator(v); err != nil {
|
||||
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Attachment.type": %w`, err)}
|
||||
}
|
||||
@@ -505,17 +505,17 @@ func (auo *AttachmentUpdateOne) check() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (auo *AttachmentUpdateOne) sqlSave(ctx context.Context) (_node *Attachment, err error) {
|
||||
if err := auo.check(); err != nil {
|
||||
func (_u *AttachmentUpdateOne) sqlSave(ctx context.Context) (_node *Attachment, err error) {
|
||||
if err := _u.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(attachment.Table, attachment.Columns, sqlgraph.NewFieldSpec(attachment.FieldID, field.TypeUUID))
|
||||
id, ok := auo.mutation.ID()
|
||||
id, ok := _u.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Attachment.id" for update`)}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
if fields := auo.fields; len(fields) > 0 {
|
||||
if fields := _u.fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, attachment.FieldID)
|
||||
for _, f := range fields {
|
||||
@@ -527,32 +527,32 @@ func (auo *AttachmentUpdateOne) sqlSave(ctx context.Context) (_node *Attachment,
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := auo.mutation.predicates; len(ps) > 0 {
|
||||
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := auo.mutation.UpdatedAt(); ok {
|
||||
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(attachment.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := auo.mutation.GetType(); ok {
|
||||
if value, ok := _u.mutation.GetType(); ok {
|
||||
_spec.SetField(attachment.FieldType, field.TypeEnum, value)
|
||||
}
|
||||
if value, ok := auo.mutation.Primary(); ok {
|
||||
if value, ok := _u.mutation.Primary(); ok {
|
||||
_spec.SetField(attachment.FieldPrimary, field.TypeBool, value)
|
||||
}
|
||||
if value, ok := auo.mutation.Title(); ok {
|
||||
if value, ok := _u.mutation.Title(); ok {
|
||||
_spec.SetField(attachment.FieldTitle, field.TypeString, value)
|
||||
}
|
||||
if value, ok := auo.mutation.Path(); ok {
|
||||
if value, ok := _u.mutation.Path(); ok {
|
||||
_spec.SetField(attachment.FieldPath, field.TypeString, value)
|
||||
}
|
||||
if value, ok := auo.mutation.MimeType(); ok {
|
||||
if value, ok := _u.mutation.MimeType(); ok {
|
||||
_spec.SetField(attachment.FieldMimeType, field.TypeString, value)
|
||||
}
|
||||
if auo.mutation.EntityCleared() {
|
||||
if _u.mutation.EntityCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -565,7 +565,7 @@ func (auo *AttachmentUpdateOne) sqlSave(ctx context.Context) (_node *Attachment,
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := auo.mutation.EntityIDs(); len(nodes) > 0 {
|
||||
if nodes := _u.mutation.EntityIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -581,7 +581,7 @@ func (auo *AttachmentUpdateOne) sqlSave(ctx context.Context) (_node *Attachment,
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if auo.mutation.ThumbnailCleared() {
|
||||
if _u.mutation.ThumbnailCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2O,
|
||||
Inverse: false,
|
||||
@@ -594,7 +594,7 @@ func (auo *AttachmentUpdateOne) sqlSave(ctx context.Context) (_node *Attachment,
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := auo.mutation.ThumbnailIDs(); len(nodes) > 0 {
|
||||
if nodes := _u.mutation.ThumbnailIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2O,
|
||||
Inverse: false,
|
||||
@@ -610,10 +610,10 @@ func (auo *AttachmentUpdateOne) sqlSave(ctx context.Context) (_node *Attachment,
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
_node = &Attachment{config: auo.config}
|
||||
_node = &Attachment{config: _u.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
if err = sqlgraph.UpdateNode(ctx, auo.driver, _spec); err != nil {
|
||||
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{attachment.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
@@ -621,6 +621,6 @@ func (auo *AttachmentUpdateOne) sqlSave(ctx context.Context) (_node *Attachment,
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
auo.mutation.done = true
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ func (*AuthRoles) scanValues(columns []string) ([]any, error) {
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the AuthRoles fields.
|
||||
func (ar *AuthRoles) assignValues(columns []string, values []any) error {
|
||||
func (_m *AuthRoles) assignValues(columns []string, values []any) error {
|
||||
if m, n := len(values), len(columns); m < n {
|
||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||
}
|
||||
@@ -78,22 +78,22 @@ func (ar *AuthRoles) assignValues(columns []string, values []any) error {
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", value)
|
||||
}
|
||||
ar.ID = int(value.Int64)
|
||||
_m.ID = int(value.Int64)
|
||||
case authroles.FieldRole:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field role", values[i])
|
||||
} else if value.Valid {
|
||||
ar.Role = authroles.Role(value.String)
|
||||
_m.Role = authroles.Role(value.String)
|
||||
}
|
||||
case authroles.ForeignKeys[0]:
|
||||
if value, ok := values[i].(*sql.NullScanner); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field auth_tokens_roles", values[i])
|
||||
} else if value.Valid {
|
||||
ar.auth_tokens_roles = new(uuid.UUID)
|
||||
*ar.auth_tokens_roles = *value.S.(*uuid.UUID)
|
||||
_m.auth_tokens_roles = new(uuid.UUID)
|
||||
*_m.auth_tokens_roles = *value.S.(*uuid.UUID)
|
||||
}
|
||||
default:
|
||||
ar.selectValues.Set(columns[i], values[i])
|
||||
_m.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -101,40 +101,40 @@ func (ar *AuthRoles) assignValues(columns []string, values []any) error {
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the AuthRoles.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (ar *AuthRoles) Value(name string) (ent.Value, error) {
|
||||
return ar.selectValues.Get(name)
|
||||
func (_m *AuthRoles) Value(name string) (ent.Value, error) {
|
||||
return _m.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// QueryToken queries the "token" edge of the AuthRoles entity.
|
||||
func (ar *AuthRoles) QueryToken() *AuthTokensQuery {
|
||||
return NewAuthRolesClient(ar.config).QueryToken(ar)
|
||||
func (_m *AuthRoles) QueryToken() *AuthTokensQuery {
|
||||
return NewAuthRolesClient(_m.config).QueryToken(_m)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this AuthRoles.
|
||||
// Note that you need to call AuthRoles.Unwrap() before calling this method if this AuthRoles
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (ar *AuthRoles) Update() *AuthRolesUpdateOne {
|
||||
return NewAuthRolesClient(ar.config).UpdateOne(ar)
|
||||
func (_m *AuthRoles) Update() *AuthRolesUpdateOne {
|
||||
return NewAuthRolesClient(_m.config).UpdateOne(_m)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the AuthRoles entity that was returned from a transaction after it was closed,
|
||||
// so that all future queries will be executed through the driver which created the transaction.
|
||||
func (ar *AuthRoles) Unwrap() *AuthRoles {
|
||||
_tx, ok := ar.config.driver.(*txDriver)
|
||||
func (_m *AuthRoles) Unwrap() *AuthRoles {
|
||||
_tx, ok := _m.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: AuthRoles is not a transactional entity")
|
||||
}
|
||||
ar.config.driver = _tx.drv
|
||||
return ar
|
||||
_m.config.driver = _tx.drv
|
||||
return _m
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (ar *AuthRoles) String() string {
|
||||
func (_m *AuthRoles) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("AuthRoles(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", ar.ID))
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||||
builder.WriteString("role=")
|
||||
builder.WriteString(fmt.Sprintf("%v", ar.Role))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Role))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
@@ -22,52 +22,52 @@ type AuthRolesCreate struct {
|
||||
}
|
||||
|
||||
// SetRole sets the "role" field.
|
||||
func (arc *AuthRolesCreate) SetRole(a authroles.Role) *AuthRolesCreate {
|
||||
arc.mutation.SetRole(a)
|
||||
return arc
|
||||
func (_c *AuthRolesCreate) SetRole(v authroles.Role) *AuthRolesCreate {
|
||||
_c.mutation.SetRole(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableRole sets the "role" field if the given value is not nil.
|
||||
func (arc *AuthRolesCreate) SetNillableRole(a *authroles.Role) *AuthRolesCreate {
|
||||
if a != nil {
|
||||
arc.SetRole(*a)
|
||||
func (_c *AuthRolesCreate) SetNillableRole(v *authroles.Role) *AuthRolesCreate {
|
||||
if v != nil {
|
||||
_c.SetRole(*v)
|
||||
}
|
||||
return arc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetTokenID sets the "token" edge to the AuthTokens entity by ID.
|
||||
func (arc *AuthRolesCreate) SetTokenID(id uuid.UUID) *AuthRolesCreate {
|
||||
arc.mutation.SetTokenID(id)
|
||||
return arc
|
||||
func (_c *AuthRolesCreate) SetTokenID(id uuid.UUID) *AuthRolesCreate {
|
||||
_c.mutation.SetTokenID(id)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableTokenID sets the "token" edge to the AuthTokens entity by ID if the given value is not nil.
|
||||
func (arc *AuthRolesCreate) SetNillableTokenID(id *uuid.UUID) *AuthRolesCreate {
|
||||
func (_c *AuthRolesCreate) SetNillableTokenID(id *uuid.UUID) *AuthRolesCreate {
|
||||
if id != nil {
|
||||
arc = arc.SetTokenID(*id)
|
||||
_c = _c.SetTokenID(*id)
|
||||
}
|
||||
return arc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetToken sets the "token" edge to the AuthTokens entity.
|
||||
func (arc *AuthRolesCreate) SetToken(a *AuthTokens) *AuthRolesCreate {
|
||||
return arc.SetTokenID(a.ID)
|
||||
func (_c *AuthRolesCreate) SetToken(v *AuthTokens) *AuthRolesCreate {
|
||||
return _c.SetTokenID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the AuthRolesMutation object of the builder.
|
||||
func (arc *AuthRolesCreate) Mutation() *AuthRolesMutation {
|
||||
return arc.mutation
|
||||
func (_c *AuthRolesCreate) Mutation() *AuthRolesMutation {
|
||||
return _c.mutation
|
||||
}
|
||||
|
||||
// Save creates the AuthRoles in the database.
|
||||
func (arc *AuthRolesCreate) Save(ctx context.Context) (*AuthRoles, error) {
|
||||
arc.defaults()
|
||||
return withHooks(ctx, arc.sqlSave, arc.mutation, arc.hooks)
|
||||
func (_c *AuthRolesCreate) Save(ctx context.Context) (*AuthRoles, error) {
|
||||
_c.defaults()
|
||||
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (arc *AuthRolesCreate) SaveX(ctx context.Context) *AuthRoles {
|
||||
v, err := arc.Save(ctx)
|
||||
func (_c *AuthRolesCreate) SaveX(ctx context.Context) *AuthRoles {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -75,32 +75,32 @@ func (arc *AuthRolesCreate) SaveX(ctx context.Context) *AuthRoles {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (arc *AuthRolesCreate) Exec(ctx context.Context) error {
|
||||
_, err := arc.Save(ctx)
|
||||
func (_c *AuthRolesCreate) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (arc *AuthRolesCreate) ExecX(ctx context.Context) {
|
||||
if err := arc.Exec(ctx); err != nil {
|
||||
func (_c *AuthRolesCreate) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (arc *AuthRolesCreate) defaults() {
|
||||
if _, ok := arc.mutation.Role(); !ok {
|
||||
func (_c *AuthRolesCreate) defaults() {
|
||||
if _, ok := _c.mutation.Role(); !ok {
|
||||
v := authroles.DefaultRole
|
||||
arc.mutation.SetRole(v)
|
||||
_c.mutation.SetRole(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (arc *AuthRolesCreate) check() error {
|
||||
if _, ok := arc.mutation.Role(); !ok {
|
||||
func (_c *AuthRolesCreate) check() error {
|
||||
if _, ok := _c.mutation.Role(); !ok {
|
||||
return &ValidationError{Name: "role", err: errors.New(`ent: missing required field "AuthRoles.role"`)}
|
||||
}
|
||||
if v, ok := arc.mutation.Role(); ok {
|
||||
if v, ok := _c.mutation.Role(); ok {
|
||||
if err := authroles.RoleValidator(v); err != nil {
|
||||
return &ValidationError{Name: "role", err: fmt.Errorf(`ent: validator failed for field "AuthRoles.role": %w`, err)}
|
||||
}
|
||||
@@ -108,12 +108,12 @@ func (arc *AuthRolesCreate) check() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (arc *AuthRolesCreate) sqlSave(ctx context.Context) (*AuthRoles, error) {
|
||||
if err := arc.check(); err != nil {
|
||||
func (_c *AuthRolesCreate) sqlSave(ctx context.Context) (*AuthRoles, error) {
|
||||
if err := _c.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_node, _spec := arc.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, arc.driver, _spec); err != nil {
|
||||
_node, _spec := _c.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
@@ -121,21 +121,21 @@ func (arc *AuthRolesCreate) sqlSave(ctx context.Context) (*AuthRoles, error) {
|
||||
}
|
||||
id := _spec.ID.Value.(int64)
|
||||
_node.ID = int(id)
|
||||
arc.mutation.id = &_node.ID
|
||||
arc.mutation.done = true
|
||||
_c.mutation.id = &_node.ID
|
||||
_c.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
func (arc *AuthRolesCreate) createSpec() (*AuthRoles, *sqlgraph.CreateSpec) {
|
||||
func (_c *AuthRolesCreate) createSpec() (*AuthRoles, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &AuthRoles{config: arc.config}
|
||||
_node = &AuthRoles{config: _c.config}
|
||||
_spec = sqlgraph.NewCreateSpec(authroles.Table, sqlgraph.NewFieldSpec(authroles.FieldID, field.TypeInt))
|
||||
)
|
||||
if value, ok := arc.mutation.Role(); ok {
|
||||
if value, ok := _c.mutation.Role(); ok {
|
||||
_spec.SetField(authroles.FieldRole, field.TypeEnum, value)
|
||||
_node.Role = value
|
||||
}
|
||||
if nodes := arc.mutation.TokenIDs(); len(nodes) > 0 {
|
||||
if nodes := _c.mutation.TokenIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2O,
|
||||
Inverse: true,
|
||||
@@ -163,16 +163,16 @@ type AuthRolesCreateBulk struct {
|
||||
}
|
||||
|
||||
// Save creates the AuthRoles entities in the database.
|
||||
func (arcb *AuthRolesCreateBulk) Save(ctx context.Context) ([]*AuthRoles, error) {
|
||||
if arcb.err != nil {
|
||||
return nil, arcb.err
|
||||
func (_c *AuthRolesCreateBulk) Save(ctx context.Context) ([]*AuthRoles, error) {
|
||||
if _c.err != nil {
|
||||
return nil, _c.err
|
||||
}
|
||||
specs := make([]*sqlgraph.CreateSpec, len(arcb.builders))
|
||||
nodes := make([]*AuthRoles, len(arcb.builders))
|
||||
mutators := make([]Mutator, len(arcb.builders))
|
||||
for i := range arcb.builders {
|
||||
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
||||
nodes := make([]*AuthRoles, len(_c.builders))
|
||||
mutators := make([]Mutator, len(_c.builders))
|
||||
for i := range _c.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := arcb.builders[i]
|
||||
builder := _c.builders[i]
|
||||
builder.defaults()
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*AuthRolesMutation)
|
||||
@@ -186,11 +186,11 @@ func (arcb *AuthRolesCreateBulk) Save(ctx context.Context) ([]*AuthRoles, error)
|
||||
var err error
|
||||
nodes[i], specs[i] = builder.createSpec()
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, arcb.builders[i+1].mutation)
|
||||
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
|
||||
} else {
|
||||
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
||||
// Invoke the actual operation on the latest mutation in the chain.
|
||||
if err = sqlgraph.BatchCreate(ctx, arcb.driver, spec); err != nil {
|
||||
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
@@ -214,7 +214,7 @@ func (arcb *AuthRolesCreateBulk) Save(ctx context.Context) ([]*AuthRoles, error)
|
||||
}(i, ctx)
|
||||
}
|
||||
if len(mutators) > 0 {
|
||||
if _, err := mutators[0].Mutate(ctx, arcb.builders[0].mutation); err != nil {
|
||||
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
@@ -222,8 +222,8 @@ func (arcb *AuthRolesCreateBulk) Save(ctx context.Context) ([]*AuthRoles, error)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (arcb *AuthRolesCreateBulk) SaveX(ctx context.Context) []*AuthRoles {
|
||||
v, err := arcb.Save(ctx)
|
||||
func (_c *AuthRolesCreateBulk) SaveX(ctx context.Context) []*AuthRoles {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -231,14 +231,14 @@ func (arcb *AuthRolesCreateBulk) SaveX(ctx context.Context) []*AuthRoles {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (arcb *AuthRolesCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := arcb.Save(ctx)
|
||||
func (_c *AuthRolesCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (arcb *AuthRolesCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := arcb.Exec(ctx); err != nil {
|
||||
func (_c *AuthRolesCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,56 +20,56 @@ type AuthRolesDelete struct {
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the AuthRolesDelete builder.
|
||||
func (ard *AuthRolesDelete) Where(ps ...predicate.AuthRoles) *AuthRolesDelete {
|
||||
ard.mutation.Where(ps...)
|
||||
return ard
|
||||
func (_d *AuthRolesDelete) Where(ps ...predicate.AuthRoles) *AuthRolesDelete {
|
||||
_d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (ard *AuthRolesDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, ard.sqlExec, ard.mutation, ard.hooks)
|
||||
func (_d *AuthRolesDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (ard *AuthRolesDelete) ExecX(ctx context.Context) int {
|
||||
n, err := ard.Exec(ctx)
|
||||
func (_d *AuthRolesDelete) ExecX(ctx context.Context) int {
|
||||
n, err := _d.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (ard *AuthRolesDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
func (_d *AuthRolesDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := sqlgraph.NewDeleteSpec(authroles.Table, sqlgraph.NewFieldSpec(authroles.FieldID, field.TypeInt))
|
||||
if ps := ard.mutation.predicates; len(ps) > 0 {
|
||||
if ps := _d.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, ard.driver, _spec)
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec)
|
||||
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
ard.mutation.done = true
|
||||
_d.mutation.done = true
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// AuthRolesDeleteOne is the builder for deleting a single AuthRoles entity.
|
||||
type AuthRolesDeleteOne struct {
|
||||
ard *AuthRolesDelete
|
||||
_d *AuthRolesDelete
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the AuthRolesDelete builder.
|
||||
func (ardo *AuthRolesDeleteOne) Where(ps ...predicate.AuthRoles) *AuthRolesDeleteOne {
|
||||
ardo.ard.mutation.Where(ps...)
|
||||
return ardo
|
||||
func (_d *AuthRolesDeleteOne) Where(ps ...predicate.AuthRoles) *AuthRolesDeleteOne {
|
||||
_d._d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (ardo *AuthRolesDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := ardo.ard.Exec(ctx)
|
||||
func (_d *AuthRolesDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := _d._d.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
@@ -81,8 +81,8 @@ func (ardo *AuthRolesDeleteOne) Exec(ctx context.Context) error {
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (ardo *AuthRolesDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := ardo.Exec(ctx); err != nil {
|
||||
func (_d *AuthRolesDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := _d.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,44 +32,44 @@ type AuthRolesQuery struct {
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the AuthRolesQuery builder.
|
||||
func (arq *AuthRolesQuery) Where(ps ...predicate.AuthRoles) *AuthRolesQuery {
|
||||
arq.predicates = append(arq.predicates, ps...)
|
||||
return arq
|
||||
func (_q *AuthRolesQuery) Where(ps ...predicate.AuthRoles) *AuthRolesQuery {
|
||||
_q.predicates = append(_q.predicates, ps...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// Limit the number of records to be returned by this query.
|
||||
func (arq *AuthRolesQuery) Limit(limit int) *AuthRolesQuery {
|
||||
arq.ctx.Limit = &limit
|
||||
return arq
|
||||
func (_q *AuthRolesQuery) Limit(limit int) *AuthRolesQuery {
|
||||
_q.ctx.Limit = &limit
|
||||
return _q
|
||||
}
|
||||
|
||||
// Offset to start from.
|
||||
func (arq *AuthRolesQuery) Offset(offset int) *AuthRolesQuery {
|
||||
arq.ctx.Offset = &offset
|
||||
return arq
|
||||
func (_q *AuthRolesQuery) Offset(offset int) *AuthRolesQuery {
|
||||
_q.ctx.Offset = &offset
|
||||
return _q
|
||||
}
|
||||
|
||||
// Unique configures the query builder to filter duplicate records on query.
|
||||
// By default, unique is set to true, and can be disabled using this method.
|
||||
func (arq *AuthRolesQuery) Unique(unique bool) *AuthRolesQuery {
|
||||
arq.ctx.Unique = &unique
|
||||
return arq
|
||||
func (_q *AuthRolesQuery) Unique(unique bool) *AuthRolesQuery {
|
||||
_q.ctx.Unique = &unique
|
||||
return _q
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (arq *AuthRolesQuery) Order(o ...authroles.OrderOption) *AuthRolesQuery {
|
||||
arq.order = append(arq.order, o...)
|
||||
return arq
|
||||
func (_q *AuthRolesQuery) Order(o ...authroles.OrderOption) *AuthRolesQuery {
|
||||
_q.order = append(_q.order, o...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// QueryToken chains the current query on the "token" edge.
|
||||
func (arq *AuthRolesQuery) QueryToken() *AuthTokensQuery {
|
||||
query := (&AuthTokensClient{config: arq.config}).Query()
|
||||
func (_q *AuthRolesQuery) QueryToken() *AuthTokensQuery {
|
||||
query := (&AuthTokensClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := arq.prepareQuery(ctx); err != nil {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := arq.sqlQuery(ctx)
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -78,7 +78,7 @@ func (arq *AuthRolesQuery) QueryToken() *AuthTokensQuery {
|
||||
sqlgraph.To(authtokens.Table, authtokens.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2O, true, authroles.TokenTable, authroles.TokenColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(arq.driver.Dialect(), step)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
@@ -86,8 +86,8 @@ func (arq *AuthRolesQuery) QueryToken() *AuthTokensQuery {
|
||||
|
||||
// First returns the first AuthRoles entity from the query.
|
||||
// Returns a *NotFoundError when no AuthRoles was found.
|
||||
func (arq *AuthRolesQuery) First(ctx context.Context) (*AuthRoles, error) {
|
||||
nodes, err := arq.Limit(1).All(setContextOp(ctx, arq.ctx, ent.OpQueryFirst))
|
||||
func (_q *AuthRolesQuery) First(ctx context.Context) (*AuthRoles, error) {
|
||||
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -98,8 +98,8 @@ func (arq *AuthRolesQuery) First(ctx context.Context) (*AuthRoles, error) {
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (arq *AuthRolesQuery) FirstX(ctx context.Context) *AuthRoles {
|
||||
node, err := arq.First(ctx)
|
||||
func (_q *AuthRolesQuery) FirstX(ctx context.Context) *AuthRoles {
|
||||
node, err := _q.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
@@ -108,9 +108,9 @@ func (arq *AuthRolesQuery) FirstX(ctx context.Context) *AuthRoles {
|
||||
|
||||
// FirstID returns the first AuthRoles ID from the query.
|
||||
// Returns a *NotFoundError when no AuthRoles ID was found.
|
||||
func (arq *AuthRolesQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||
func (_q *AuthRolesQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = arq.Limit(1).IDs(setContextOp(ctx, arq.ctx, ent.OpQueryFirstID)); err != nil {
|
||||
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
@@ -121,8 +121,8 @@ func (arq *AuthRolesQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (arq *AuthRolesQuery) FirstIDX(ctx context.Context) int {
|
||||
id, err := arq.FirstID(ctx)
|
||||
func (_q *AuthRolesQuery) FirstIDX(ctx context.Context) int {
|
||||
id, err := _q.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
@@ -132,8 +132,8 @@ func (arq *AuthRolesQuery) FirstIDX(ctx context.Context) int {
|
||||
// Only returns a single AuthRoles entity found by the query, ensuring it only returns one.
|
||||
// Returns a *NotSingularError when more than one AuthRoles entity is found.
|
||||
// Returns a *NotFoundError when no AuthRoles entities are found.
|
||||
func (arq *AuthRolesQuery) Only(ctx context.Context) (*AuthRoles, error) {
|
||||
nodes, err := arq.Limit(2).All(setContextOp(ctx, arq.ctx, ent.OpQueryOnly))
|
||||
func (_q *AuthRolesQuery) Only(ctx context.Context) (*AuthRoles, error) {
|
||||
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -148,8 +148,8 @@ func (arq *AuthRolesQuery) Only(ctx context.Context) (*AuthRoles, error) {
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (arq *AuthRolesQuery) OnlyX(ctx context.Context) *AuthRoles {
|
||||
node, err := arq.Only(ctx)
|
||||
func (_q *AuthRolesQuery) OnlyX(ctx context.Context) *AuthRoles {
|
||||
node, err := _q.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -159,9 +159,9 @@ func (arq *AuthRolesQuery) OnlyX(ctx context.Context) *AuthRoles {
|
||||
// OnlyID is like Only, but returns the only AuthRoles ID in the query.
|
||||
// Returns a *NotSingularError when more than one AuthRoles ID is found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (arq *AuthRolesQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||
func (_q *AuthRolesQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = arq.Limit(2).IDs(setContextOp(ctx, arq.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
@@ -176,8 +176,8 @@ func (arq *AuthRolesQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (arq *AuthRolesQuery) OnlyIDX(ctx context.Context) int {
|
||||
id, err := arq.OnlyID(ctx)
|
||||
func (_q *AuthRolesQuery) OnlyIDX(ctx context.Context) int {
|
||||
id, err := _q.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -185,18 +185,18 @@ func (arq *AuthRolesQuery) OnlyIDX(ctx context.Context) int {
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of AuthRolesSlice.
|
||||
func (arq *AuthRolesQuery) All(ctx context.Context) ([]*AuthRoles, error) {
|
||||
ctx = setContextOp(ctx, arq.ctx, ent.OpQueryAll)
|
||||
if err := arq.prepareQuery(ctx); err != nil {
|
||||
func (_q *AuthRolesQuery) All(ctx context.Context) ([]*AuthRoles, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qr := querierAll[[]*AuthRoles, *AuthRolesQuery]()
|
||||
return withInterceptors[[]*AuthRoles](ctx, arq, qr, arq.inters)
|
||||
return withInterceptors[[]*AuthRoles](ctx, _q, qr, _q.inters)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (arq *AuthRolesQuery) AllX(ctx context.Context) []*AuthRoles {
|
||||
nodes, err := arq.All(ctx)
|
||||
func (_q *AuthRolesQuery) AllX(ctx context.Context) []*AuthRoles {
|
||||
nodes, err := _q.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -204,20 +204,20 @@ func (arq *AuthRolesQuery) AllX(ctx context.Context) []*AuthRoles {
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of AuthRoles IDs.
|
||||
func (arq *AuthRolesQuery) IDs(ctx context.Context) (ids []int, err error) {
|
||||
if arq.ctx.Unique == nil && arq.path != nil {
|
||||
arq.Unique(true)
|
||||
func (_q *AuthRolesQuery) IDs(ctx context.Context) (ids []int, err error) {
|
||||
if _q.ctx.Unique == nil && _q.path != nil {
|
||||
_q.Unique(true)
|
||||
}
|
||||
ctx = setContextOp(ctx, arq.ctx, ent.OpQueryIDs)
|
||||
if err = arq.Select(authroles.FieldID).Scan(ctx, &ids); err != nil {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
|
||||
if err = _q.Select(authroles.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (arq *AuthRolesQuery) IDsX(ctx context.Context) []int {
|
||||
ids, err := arq.IDs(ctx)
|
||||
func (_q *AuthRolesQuery) IDsX(ctx context.Context) []int {
|
||||
ids, err := _q.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -225,17 +225,17 @@ func (arq *AuthRolesQuery) IDsX(ctx context.Context) []int {
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (arq *AuthRolesQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, arq.ctx, ent.OpQueryCount)
|
||||
if err := arq.prepareQuery(ctx); err != nil {
|
||||
func (_q *AuthRolesQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return withInterceptors[int](ctx, arq, querierCount[*AuthRolesQuery](), arq.inters)
|
||||
return withInterceptors[int](ctx, _q, querierCount[*AuthRolesQuery](), _q.inters)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (arq *AuthRolesQuery) CountX(ctx context.Context) int {
|
||||
count, err := arq.Count(ctx)
|
||||
func (_q *AuthRolesQuery) CountX(ctx context.Context) int {
|
||||
count, err := _q.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -243,9 +243,9 @@ func (arq *AuthRolesQuery) CountX(ctx context.Context) int {
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (arq *AuthRolesQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, arq.ctx, ent.OpQueryExist)
|
||||
switch _, err := arq.FirstID(ctx); {
|
||||
func (_q *AuthRolesQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
|
||||
switch _, err := _q.FirstID(ctx); {
|
||||
case IsNotFound(err):
|
||||
return false, nil
|
||||
case err != nil:
|
||||
@@ -256,8 +256,8 @@ func (arq *AuthRolesQuery) Exist(ctx context.Context) (bool, error) {
|
||||
}
|
||||
|
||||
// ExistX is like Exist, but panics if an error occurs.
|
||||
func (arq *AuthRolesQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := arq.Exist(ctx)
|
||||
func (_q *AuthRolesQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := _q.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -266,32 +266,32 @@ func (arq *AuthRolesQuery) ExistX(ctx context.Context) bool {
|
||||
|
||||
// Clone returns a duplicate of the AuthRolesQuery builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (arq *AuthRolesQuery) Clone() *AuthRolesQuery {
|
||||
if arq == nil {
|
||||
func (_q *AuthRolesQuery) Clone() *AuthRolesQuery {
|
||||
if _q == nil {
|
||||
return nil
|
||||
}
|
||||
return &AuthRolesQuery{
|
||||
config: arq.config,
|
||||
ctx: arq.ctx.Clone(),
|
||||
order: append([]authroles.OrderOption{}, arq.order...),
|
||||
inters: append([]Interceptor{}, arq.inters...),
|
||||
predicates: append([]predicate.AuthRoles{}, arq.predicates...),
|
||||
withToken: arq.withToken.Clone(),
|
||||
config: _q.config,
|
||||
ctx: _q.ctx.Clone(),
|
||||
order: append([]authroles.OrderOption{}, _q.order...),
|
||||
inters: append([]Interceptor{}, _q.inters...),
|
||||
predicates: append([]predicate.AuthRoles{}, _q.predicates...),
|
||||
withToken: _q.withToken.Clone(),
|
||||
// clone intermediate query.
|
||||
sql: arq.sql.Clone(),
|
||||
path: arq.path,
|
||||
sql: _q.sql.Clone(),
|
||||
path: _q.path,
|
||||
}
|
||||
}
|
||||
|
||||
// WithToken tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "token" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (arq *AuthRolesQuery) WithToken(opts ...func(*AuthTokensQuery)) *AuthRolesQuery {
|
||||
query := (&AuthTokensClient{config: arq.config}).Query()
|
||||
func (_q *AuthRolesQuery) WithToken(opts ...func(*AuthTokensQuery)) *AuthRolesQuery {
|
||||
query := (&AuthTokensClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
arq.withToken = query
|
||||
return arq
|
||||
_q.withToken = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// GroupBy is used to group vertices by one or more fields/columns.
|
||||
@@ -308,10 +308,10 @@ func (arq *AuthRolesQuery) WithToken(opts ...func(*AuthTokensQuery)) *AuthRolesQ
|
||||
// GroupBy(authroles.FieldRole).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (arq *AuthRolesQuery) GroupBy(field string, fields ...string) *AuthRolesGroupBy {
|
||||
arq.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &AuthRolesGroupBy{build: arq}
|
||||
grbuild.flds = &arq.ctx.Fields
|
||||
func (_q *AuthRolesQuery) GroupBy(field string, fields ...string) *AuthRolesGroupBy {
|
||||
_q.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &AuthRolesGroupBy{build: _q}
|
||||
grbuild.flds = &_q.ctx.Fields
|
||||
grbuild.label = authroles.Label
|
||||
grbuild.scan = grbuild.Scan
|
||||
return grbuild
|
||||
@@ -329,55 +329,55 @@ func (arq *AuthRolesQuery) GroupBy(field string, fields ...string) *AuthRolesGro
|
||||
// client.AuthRoles.Query().
|
||||
// Select(authroles.FieldRole).
|
||||
// Scan(ctx, &v)
|
||||
func (arq *AuthRolesQuery) Select(fields ...string) *AuthRolesSelect {
|
||||
arq.ctx.Fields = append(arq.ctx.Fields, fields...)
|
||||
sbuild := &AuthRolesSelect{AuthRolesQuery: arq}
|
||||
func (_q *AuthRolesQuery) Select(fields ...string) *AuthRolesSelect {
|
||||
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
||||
sbuild := &AuthRolesSelect{AuthRolesQuery: _q}
|
||||
sbuild.label = authroles.Label
|
||||
sbuild.flds, sbuild.scan = &arq.ctx.Fields, sbuild.Scan
|
||||
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
|
||||
return sbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a AuthRolesSelect configured with the given aggregations.
|
||||
func (arq *AuthRolesQuery) Aggregate(fns ...AggregateFunc) *AuthRolesSelect {
|
||||
return arq.Select().Aggregate(fns...)
|
||||
func (_q *AuthRolesQuery) Aggregate(fns ...AggregateFunc) *AuthRolesSelect {
|
||||
return _q.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (arq *AuthRolesQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range arq.inters {
|
||||
func (_q *AuthRolesQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range _q.inters {
|
||||
if inter == nil {
|
||||
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
|
||||
}
|
||||
if trv, ok := inter.(Traverser); ok {
|
||||
if err := trv.Traverse(ctx, arq); err != nil {
|
||||
if err := trv.Traverse(ctx, _q); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, f := range arq.ctx.Fields {
|
||||
for _, f := range _q.ctx.Fields {
|
||||
if !authroles.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
}
|
||||
if arq.path != nil {
|
||||
prev, err := arq.path(ctx)
|
||||
if _q.path != nil {
|
||||
prev, err := _q.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
arq.sql = prev
|
||||
_q.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (arq *AuthRolesQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*AuthRoles, error) {
|
||||
func (_q *AuthRolesQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*AuthRoles, error) {
|
||||
var (
|
||||
nodes = []*AuthRoles{}
|
||||
withFKs = arq.withFKs
|
||||
_spec = arq.querySpec()
|
||||
withFKs = _q.withFKs
|
||||
_spec = _q.querySpec()
|
||||
loadedTypes = [1]bool{
|
||||
arq.withToken != nil,
|
||||
_q.withToken != nil,
|
||||
}
|
||||
)
|
||||
if arq.withToken != nil {
|
||||
if _q.withToken != nil {
|
||||
withFKs = true
|
||||
}
|
||||
if withFKs {
|
||||
@@ -387,7 +387,7 @@ func (arq *AuthRolesQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*A
|
||||
return (*AuthRoles).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &AuthRoles{config: arq.config}
|
||||
node := &AuthRoles{config: _q.config}
|
||||
nodes = append(nodes, node)
|
||||
node.Edges.loadedTypes = loadedTypes
|
||||
return node.assignValues(columns, values)
|
||||
@@ -395,14 +395,14 @@ func (arq *AuthRolesQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*A
|
||||
for i := range hooks {
|
||||
hooks[i](ctx, _spec)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, arq.driver, _spec); err != nil {
|
||||
if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
if query := arq.withToken; query != nil {
|
||||
if err := arq.loadToken(ctx, query, nodes, nil,
|
||||
if query := _q.withToken; query != nil {
|
||||
if err := _q.loadToken(ctx, query, nodes, nil,
|
||||
func(n *AuthRoles, e *AuthTokens) { n.Edges.Token = e }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -410,7 +410,7 @@ func (arq *AuthRolesQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*A
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (arq *AuthRolesQuery) loadToken(ctx context.Context, query *AuthTokensQuery, nodes []*AuthRoles, init func(*AuthRoles), assign func(*AuthRoles, *AuthTokens)) error {
|
||||
func (_q *AuthRolesQuery) loadToken(ctx context.Context, query *AuthTokensQuery, nodes []*AuthRoles, init func(*AuthRoles), assign func(*AuthRoles, *AuthTokens)) error {
|
||||
ids := make([]uuid.UUID, 0, len(nodes))
|
||||
nodeids := make(map[uuid.UUID][]*AuthRoles)
|
||||
for i := range nodes {
|
||||
@@ -443,24 +443,24 @@ func (arq *AuthRolesQuery) loadToken(ctx context.Context, query *AuthTokensQuery
|
||||
return nil
|
||||
}
|
||||
|
||||
func (arq *AuthRolesQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := arq.querySpec()
|
||||
_spec.Node.Columns = arq.ctx.Fields
|
||||
if len(arq.ctx.Fields) > 0 {
|
||||
_spec.Unique = arq.ctx.Unique != nil && *arq.ctx.Unique
|
||||
func (_q *AuthRolesQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := _q.querySpec()
|
||||
_spec.Node.Columns = _q.ctx.Fields
|
||||
if len(_q.ctx.Fields) > 0 {
|
||||
_spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, arq.driver, _spec)
|
||||
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
|
||||
}
|
||||
|
||||
func (arq *AuthRolesQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
func (_q *AuthRolesQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := sqlgraph.NewQuerySpec(authroles.Table, authroles.Columns, sqlgraph.NewFieldSpec(authroles.FieldID, field.TypeInt))
|
||||
_spec.From = arq.sql
|
||||
if unique := arq.ctx.Unique; unique != nil {
|
||||
_spec.From = _q.sql
|
||||
if unique := _q.ctx.Unique; unique != nil {
|
||||
_spec.Unique = *unique
|
||||
} else if arq.path != nil {
|
||||
} else if _q.path != nil {
|
||||
_spec.Unique = true
|
||||
}
|
||||
if fields := arq.ctx.Fields; len(fields) > 0 {
|
||||
if fields := _q.ctx.Fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, authroles.FieldID)
|
||||
for i := range fields {
|
||||
@@ -469,20 +469,20 @@ func (arq *AuthRolesQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := arq.predicates; len(ps) > 0 {
|
||||
if ps := _q.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := arq.ctx.Limit; limit != nil {
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := arq.ctx.Offset; offset != nil {
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := arq.order; len(ps) > 0 {
|
||||
if ps := _q.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
@@ -492,33 +492,33 @@ func (arq *AuthRolesQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (arq *AuthRolesQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(arq.driver.Dialect())
|
||||
func (_q *AuthRolesQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(_q.driver.Dialect())
|
||||
t1 := builder.Table(authroles.Table)
|
||||
columns := arq.ctx.Fields
|
||||
columns := _q.ctx.Fields
|
||||
if len(columns) == 0 {
|
||||
columns = authroles.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if arq.sql != nil {
|
||||
selector = arq.sql
|
||||
if _q.sql != nil {
|
||||
selector = _q.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
if arq.ctx.Unique != nil && *arq.ctx.Unique {
|
||||
if _q.ctx.Unique != nil && *_q.ctx.Unique {
|
||||
selector.Distinct()
|
||||
}
|
||||
for _, p := range arq.predicates {
|
||||
for _, p := range _q.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range arq.order {
|
||||
for _, p := range _q.order {
|
||||
p(selector)
|
||||
}
|
||||
if offset := arq.ctx.Offset; offset != nil {
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
// limit is mandatory for offset clause. We start
|
||||
// with default value, and override it below if needed.
|
||||
selector.Offset(*offset).Limit(math.MaxInt32)
|
||||
}
|
||||
if limit := arq.ctx.Limit; limit != nil {
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
@@ -531,41 +531,41 @@ type AuthRolesGroupBy struct {
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (argb *AuthRolesGroupBy) Aggregate(fns ...AggregateFunc) *AuthRolesGroupBy {
|
||||
argb.fns = append(argb.fns, fns...)
|
||||
return argb
|
||||
func (_g *AuthRolesGroupBy) Aggregate(fns ...AggregateFunc) *AuthRolesGroupBy {
|
||||
_g.fns = append(_g.fns, fns...)
|
||||
return _g
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (argb *AuthRolesGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, argb.build.ctx, ent.OpQueryGroupBy)
|
||||
if err := argb.build.prepareQuery(ctx); err != nil {
|
||||
func (_g *AuthRolesGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
|
||||
if err := _g.build.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*AuthRolesQuery, *AuthRolesGroupBy](ctx, argb.build, argb, argb.build.inters, v)
|
||||
return scanWithInterceptors[*AuthRolesQuery, *AuthRolesGroupBy](ctx, _g.build, _g, _g.build.inters, v)
|
||||
}
|
||||
|
||||
func (argb *AuthRolesGroupBy) sqlScan(ctx context.Context, root *AuthRolesQuery, v any) error {
|
||||
func (_g *AuthRolesGroupBy) sqlScan(ctx context.Context, root *AuthRolesQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx).Select()
|
||||
aggregation := make([]string, 0, len(argb.fns))
|
||||
for _, fn := range argb.fns {
|
||||
aggregation := make([]string, 0, len(_g.fns))
|
||||
for _, fn := range _g.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(*argb.flds)+len(argb.fns))
|
||||
for _, f := range *argb.flds {
|
||||
columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
|
||||
for _, f := range *_g.flds {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
columns = append(columns, aggregation...)
|
||||
selector.Select(columns...)
|
||||
}
|
||||
selector.GroupBy(selector.Columns(*argb.flds...)...)
|
||||
selector.GroupBy(selector.Columns(*_g.flds...)...)
|
||||
if err := selector.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := argb.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
@@ -579,27 +579,27 @@ type AuthRolesSelect struct {
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (ars *AuthRolesSelect) Aggregate(fns ...AggregateFunc) *AuthRolesSelect {
|
||||
ars.fns = append(ars.fns, fns...)
|
||||
return ars
|
||||
func (_s *AuthRolesSelect) Aggregate(fns ...AggregateFunc) *AuthRolesSelect {
|
||||
_s.fns = append(_s.fns, fns...)
|
||||
return _s
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (ars *AuthRolesSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, ars.ctx, ent.OpQuerySelect)
|
||||
if err := ars.prepareQuery(ctx); err != nil {
|
||||
func (_s *AuthRolesSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
|
||||
if err := _s.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*AuthRolesQuery, *AuthRolesSelect](ctx, ars.AuthRolesQuery, ars, ars.inters, v)
|
||||
return scanWithInterceptors[*AuthRolesQuery, *AuthRolesSelect](ctx, _s.AuthRolesQuery, _s, _s.inters, v)
|
||||
}
|
||||
|
||||
func (ars *AuthRolesSelect) sqlScan(ctx context.Context, root *AuthRolesQuery, v any) error {
|
||||
func (_s *AuthRolesSelect) sqlScan(ctx context.Context, root *AuthRolesQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx)
|
||||
aggregation := make([]string, 0, len(ars.fns))
|
||||
for _, fn := range ars.fns {
|
||||
aggregation := make([]string, 0, len(_s.fns))
|
||||
for _, fn := range _s.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
switch n := len(*ars.selector.flds); {
|
||||
switch n := len(*_s.selector.flds); {
|
||||
case n == 0 && len(aggregation) > 0:
|
||||
selector.Select(aggregation...)
|
||||
case n != 0 && len(aggregation) > 0:
|
||||
@@ -607,7 +607,7 @@ func (ars *AuthRolesSelect) sqlScan(ctx context.Context, root *AuthRolesQuery, v
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := ars.driver.Query(ctx, query, args, rows); err != nil {
|
||||
if err := _s.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
@@ -24,63 +24,63 @@ type AuthRolesUpdate struct {
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the AuthRolesUpdate builder.
|
||||
func (aru *AuthRolesUpdate) Where(ps ...predicate.AuthRoles) *AuthRolesUpdate {
|
||||
aru.mutation.Where(ps...)
|
||||
return aru
|
||||
func (_u *AuthRolesUpdate) Where(ps ...predicate.AuthRoles) *AuthRolesUpdate {
|
||||
_u.mutation.Where(ps...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetRole sets the "role" field.
|
||||
func (aru *AuthRolesUpdate) SetRole(a authroles.Role) *AuthRolesUpdate {
|
||||
aru.mutation.SetRole(a)
|
||||
return aru
|
||||
func (_u *AuthRolesUpdate) SetRole(v authroles.Role) *AuthRolesUpdate {
|
||||
_u.mutation.SetRole(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableRole sets the "role" field if the given value is not nil.
|
||||
func (aru *AuthRolesUpdate) SetNillableRole(a *authroles.Role) *AuthRolesUpdate {
|
||||
if a != nil {
|
||||
aru.SetRole(*a)
|
||||
func (_u *AuthRolesUpdate) SetNillableRole(v *authroles.Role) *AuthRolesUpdate {
|
||||
if v != nil {
|
||||
_u.SetRole(*v)
|
||||
}
|
||||
return aru
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetTokenID sets the "token" edge to the AuthTokens entity by ID.
|
||||
func (aru *AuthRolesUpdate) SetTokenID(id uuid.UUID) *AuthRolesUpdate {
|
||||
aru.mutation.SetTokenID(id)
|
||||
return aru
|
||||
func (_u *AuthRolesUpdate) SetTokenID(id uuid.UUID) *AuthRolesUpdate {
|
||||
_u.mutation.SetTokenID(id)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableTokenID sets the "token" edge to the AuthTokens entity by ID if the given value is not nil.
|
||||
func (aru *AuthRolesUpdate) SetNillableTokenID(id *uuid.UUID) *AuthRolesUpdate {
|
||||
func (_u *AuthRolesUpdate) SetNillableTokenID(id *uuid.UUID) *AuthRolesUpdate {
|
||||
if id != nil {
|
||||
aru = aru.SetTokenID(*id)
|
||||
_u = _u.SetTokenID(*id)
|
||||
}
|
||||
return aru
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetToken sets the "token" edge to the AuthTokens entity.
|
||||
func (aru *AuthRolesUpdate) SetToken(a *AuthTokens) *AuthRolesUpdate {
|
||||
return aru.SetTokenID(a.ID)
|
||||
func (_u *AuthRolesUpdate) SetToken(v *AuthTokens) *AuthRolesUpdate {
|
||||
return _u.SetTokenID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the AuthRolesMutation object of the builder.
|
||||
func (aru *AuthRolesUpdate) Mutation() *AuthRolesMutation {
|
||||
return aru.mutation
|
||||
func (_u *AuthRolesUpdate) Mutation() *AuthRolesMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// ClearToken clears the "token" edge to the AuthTokens entity.
|
||||
func (aru *AuthRolesUpdate) ClearToken() *AuthRolesUpdate {
|
||||
aru.mutation.ClearToken()
|
||||
return aru
|
||||
func (_u *AuthRolesUpdate) ClearToken() *AuthRolesUpdate {
|
||||
_u.mutation.ClearToken()
|
||||
return _u
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (aru *AuthRolesUpdate) Save(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, aru.sqlSave, aru.mutation, aru.hooks)
|
||||
func (_u *AuthRolesUpdate) 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 (aru *AuthRolesUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := aru.Save(ctx)
|
||||
func (_u *AuthRolesUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -88,21 +88,21 @@ func (aru *AuthRolesUpdate) SaveX(ctx context.Context) int {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (aru *AuthRolesUpdate) Exec(ctx context.Context) error {
|
||||
_, err := aru.Save(ctx)
|
||||
func (_u *AuthRolesUpdate) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (aru *AuthRolesUpdate) ExecX(ctx context.Context) {
|
||||
if err := aru.Exec(ctx); err != nil {
|
||||
func (_u *AuthRolesUpdate) 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 (aru *AuthRolesUpdate) check() error {
|
||||
if v, ok := aru.mutation.Role(); ok {
|
||||
func (_u *AuthRolesUpdate) check() error {
|
||||
if v, ok := _u.mutation.Role(); ok {
|
||||
if err := authroles.RoleValidator(v); err != nil {
|
||||
return &ValidationError{Name: "role", err: fmt.Errorf(`ent: validator failed for field "AuthRoles.role": %w`, err)}
|
||||
}
|
||||
@@ -110,22 +110,22 @@ func (aru *AuthRolesUpdate) check() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (aru *AuthRolesUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
if err := aru.check(); err != nil {
|
||||
return n, err
|
||||
func (_u *AuthRolesUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
if err := _u.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(authroles.Table, authroles.Columns, sqlgraph.NewFieldSpec(authroles.FieldID, field.TypeInt))
|
||||
if ps := aru.mutation.predicates; len(ps) > 0 {
|
||||
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := aru.mutation.Role(); ok {
|
||||
if value, ok := _u.mutation.Role(); ok {
|
||||
_spec.SetField(authroles.FieldRole, field.TypeEnum, value)
|
||||
}
|
||||
if aru.mutation.TokenCleared() {
|
||||
if _u.mutation.TokenCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2O,
|
||||
Inverse: true,
|
||||
@@ -138,7 +138,7 @@ func (aru *AuthRolesUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := aru.mutation.TokenIDs(); len(nodes) > 0 {
|
||||
if nodes := _u.mutation.TokenIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2O,
|
||||
Inverse: true,
|
||||
@@ -154,7 +154,7 @@ func (aru *AuthRolesUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, aru.driver, _spec); err != nil {
|
||||
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{authroles.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
@@ -162,8 +162,8 @@ func (aru *AuthRolesUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
aru.mutation.done = true
|
||||
return n, nil
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
// AuthRolesUpdateOne is the builder for updating a single AuthRoles entity.
|
||||
@@ -175,70 +175,70 @@ type AuthRolesUpdateOne struct {
|
||||
}
|
||||
|
||||
// SetRole sets the "role" field.
|
||||
func (aruo *AuthRolesUpdateOne) SetRole(a authroles.Role) *AuthRolesUpdateOne {
|
||||
aruo.mutation.SetRole(a)
|
||||
return aruo
|
||||
func (_u *AuthRolesUpdateOne) SetRole(v authroles.Role) *AuthRolesUpdateOne {
|
||||
_u.mutation.SetRole(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableRole sets the "role" field if the given value is not nil.
|
||||
func (aruo *AuthRolesUpdateOne) SetNillableRole(a *authroles.Role) *AuthRolesUpdateOne {
|
||||
if a != nil {
|
||||
aruo.SetRole(*a)
|
||||
func (_u *AuthRolesUpdateOne) SetNillableRole(v *authroles.Role) *AuthRolesUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetRole(*v)
|
||||
}
|
||||
return aruo
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetTokenID sets the "token" edge to the AuthTokens entity by ID.
|
||||
func (aruo *AuthRolesUpdateOne) SetTokenID(id uuid.UUID) *AuthRolesUpdateOne {
|
||||
aruo.mutation.SetTokenID(id)
|
||||
return aruo
|
||||
func (_u *AuthRolesUpdateOne) SetTokenID(id uuid.UUID) *AuthRolesUpdateOne {
|
||||
_u.mutation.SetTokenID(id)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableTokenID sets the "token" edge to the AuthTokens entity by ID if the given value is not nil.
|
||||
func (aruo *AuthRolesUpdateOne) SetNillableTokenID(id *uuid.UUID) *AuthRolesUpdateOne {
|
||||
func (_u *AuthRolesUpdateOne) SetNillableTokenID(id *uuid.UUID) *AuthRolesUpdateOne {
|
||||
if id != nil {
|
||||
aruo = aruo.SetTokenID(*id)
|
||||
_u = _u.SetTokenID(*id)
|
||||
}
|
||||
return aruo
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetToken sets the "token" edge to the AuthTokens entity.
|
||||
func (aruo *AuthRolesUpdateOne) SetToken(a *AuthTokens) *AuthRolesUpdateOne {
|
||||
return aruo.SetTokenID(a.ID)
|
||||
func (_u *AuthRolesUpdateOne) SetToken(v *AuthTokens) *AuthRolesUpdateOne {
|
||||
return _u.SetTokenID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the AuthRolesMutation object of the builder.
|
||||
func (aruo *AuthRolesUpdateOne) Mutation() *AuthRolesMutation {
|
||||
return aruo.mutation
|
||||
func (_u *AuthRolesUpdateOne) Mutation() *AuthRolesMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// ClearToken clears the "token" edge to the AuthTokens entity.
|
||||
func (aruo *AuthRolesUpdateOne) ClearToken() *AuthRolesUpdateOne {
|
||||
aruo.mutation.ClearToken()
|
||||
return aruo
|
||||
func (_u *AuthRolesUpdateOne) ClearToken() *AuthRolesUpdateOne {
|
||||
_u.mutation.ClearToken()
|
||||
return _u
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the AuthRolesUpdate builder.
|
||||
func (aruo *AuthRolesUpdateOne) Where(ps ...predicate.AuthRoles) *AuthRolesUpdateOne {
|
||||
aruo.mutation.Where(ps...)
|
||||
return aruo
|
||||
func (_u *AuthRolesUpdateOne) Where(ps ...predicate.AuthRoles) *AuthRolesUpdateOne {
|
||||
_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 (aruo *AuthRolesUpdateOne) Select(field string, fields ...string) *AuthRolesUpdateOne {
|
||||
aruo.fields = append([]string{field}, fields...)
|
||||
return aruo
|
||||
func (_u *AuthRolesUpdateOne) Select(field string, fields ...string) *AuthRolesUpdateOne {
|
||||
_u.fields = append([]string{field}, fields...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated AuthRoles entity.
|
||||
func (aruo *AuthRolesUpdateOne) Save(ctx context.Context) (*AuthRoles, error) {
|
||||
return withHooks(ctx, aruo.sqlSave, aruo.mutation, aruo.hooks)
|
||||
func (_u *AuthRolesUpdateOne) Save(ctx context.Context) (*AuthRoles, error) {
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (aruo *AuthRolesUpdateOne) SaveX(ctx context.Context) *AuthRoles {
|
||||
node, err := aruo.Save(ctx)
|
||||
func (_u *AuthRolesUpdateOne) SaveX(ctx context.Context) *AuthRoles {
|
||||
node, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -246,21 +246,21 @@ func (aruo *AuthRolesUpdateOne) SaveX(ctx context.Context) *AuthRoles {
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (aruo *AuthRolesUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := aruo.Save(ctx)
|
||||
func (_u *AuthRolesUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (aruo *AuthRolesUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := aruo.Exec(ctx); err != nil {
|
||||
func (_u *AuthRolesUpdateOne) 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 (aruo *AuthRolesUpdateOne) check() error {
|
||||
if v, ok := aruo.mutation.Role(); ok {
|
||||
func (_u *AuthRolesUpdateOne) check() error {
|
||||
if v, ok := _u.mutation.Role(); ok {
|
||||
if err := authroles.RoleValidator(v); err != nil {
|
||||
return &ValidationError{Name: "role", err: fmt.Errorf(`ent: validator failed for field "AuthRoles.role": %w`, err)}
|
||||
}
|
||||
@@ -268,17 +268,17 @@ func (aruo *AuthRolesUpdateOne) check() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (aruo *AuthRolesUpdateOne) sqlSave(ctx context.Context) (_node *AuthRoles, err error) {
|
||||
if err := aruo.check(); err != nil {
|
||||
func (_u *AuthRolesUpdateOne) sqlSave(ctx context.Context) (_node *AuthRoles, err error) {
|
||||
if err := _u.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(authroles.Table, authroles.Columns, sqlgraph.NewFieldSpec(authroles.FieldID, field.TypeInt))
|
||||
id, ok := aruo.mutation.ID()
|
||||
id, ok := _u.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "AuthRoles.id" for update`)}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
if fields := aruo.fields; len(fields) > 0 {
|
||||
if fields := _u.fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, authroles.FieldID)
|
||||
for _, f := range fields {
|
||||
@@ -290,17 +290,17 @@ func (aruo *AuthRolesUpdateOne) sqlSave(ctx context.Context) (_node *AuthRoles,
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := aruo.mutation.predicates; len(ps) > 0 {
|
||||
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := aruo.mutation.Role(); ok {
|
||||
if value, ok := _u.mutation.Role(); ok {
|
||||
_spec.SetField(authroles.FieldRole, field.TypeEnum, value)
|
||||
}
|
||||
if aruo.mutation.TokenCleared() {
|
||||
if _u.mutation.TokenCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2O,
|
||||
Inverse: true,
|
||||
@@ -313,7 +313,7 @@ func (aruo *AuthRolesUpdateOne) sqlSave(ctx context.Context) (_node *AuthRoles,
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := aruo.mutation.TokenIDs(); len(nodes) > 0 {
|
||||
if nodes := _u.mutation.TokenIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2O,
|
||||
Inverse: true,
|
||||
@@ -329,10 +329,10 @@ func (aruo *AuthRolesUpdateOne) sqlSave(ctx context.Context) (_node *AuthRoles,
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
_node = &AuthRoles{config: aruo.config}
|
||||
_node = &AuthRoles{config: _u.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
if err = sqlgraph.UpdateNode(ctx, aruo.driver, _spec); err != nil {
|
||||
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{authroles.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
@@ -340,6 +340,6 @@ func (aruo *AuthRolesUpdateOne) sqlSave(ctx context.Context) (_node *AuthRoles,
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
aruo.mutation.done = true
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ func (*AuthTokens) scanValues(columns []string) ([]any, error) {
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the AuthTokens fields.
|
||||
func (at *AuthTokens) assignValues(columns []string, values []any) error {
|
||||
func (_m *AuthTokens) assignValues(columns []string, values []any) error {
|
||||
if m, n := len(values), len(columns); m < n {
|
||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||
}
|
||||
@@ -100,41 +100,41 @@ func (at *AuthTokens) assignValues(columns []string, values []any) error {
|
||||
if value, ok := values[i].(*uuid.UUID); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", values[i])
|
||||
} else if value != nil {
|
||||
at.ID = *value
|
||||
_m.ID = *value
|
||||
}
|
||||
case authtokens.FieldCreatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
||||
} else if value.Valid {
|
||||
at.CreatedAt = value.Time
|
||||
_m.CreatedAt = value.Time
|
||||
}
|
||||
case authtokens.FieldUpdatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
|
||||
} else if value.Valid {
|
||||
at.UpdatedAt = value.Time
|
||||
_m.UpdatedAt = value.Time
|
||||
}
|
||||
case authtokens.FieldToken:
|
||||
if value, ok := values[i].(*[]byte); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field token", values[i])
|
||||
} else if value != nil {
|
||||
at.Token = *value
|
||||
_m.Token = *value
|
||||
}
|
||||
case authtokens.FieldExpiresAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field expires_at", values[i])
|
||||
} else if value.Valid {
|
||||
at.ExpiresAt = value.Time
|
||||
_m.ExpiresAt = value.Time
|
||||
}
|
||||
case authtokens.ForeignKeys[0]:
|
||||
if value, ok := values[i].(*sql.NullScanner); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field user_auth_tokens", values[i])
|
||||
} else if value.Valid {
|
||||
at.user_auth_tokens = new(uuid.UUID)
|
||||
*at.user_auth_tokens = *value.S.(*uuid.UUID)
|
||||
_m.user_auth_tokens = new(uuid.UUID)
|
||||
*_m.user_auth_tokens = *value.S.(*uuid.UUID)
|
||||
}
|
||||
default:
|
||||
at.selectValues.Set(columns[i], values[i])
|
||||
_m.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -142,54 +142,54 @@ func (at *AuthTokens) assignValues(columns []string, values []any) error {
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the AuthTokens.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (at *AuthTokens) Value(name string) (ent.Value, error) {
|
||||
return at.selectValues.Get(name)
|
||||
func (_m *AuthTokens) Value(name string) (ent.Value, error) {
|
||||
return _m.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// QueryUser queries the "user" edge of the AuthTokens entity.
|
||||
func (at *AuthTokens) QueryUser() *UserQuery {
|
||||
return NewAuthTokensClient(at.config).QueryUser(at)
|
||||
func (_m *AuthTokens) QueryUser() *UserQuery {
|
||||
return NewAuthTokensClient(_m.config).QueryUser(_m)
|
||||
}
|
||||
|
||||
// QueryRoles queries the "roles" edge of the AuthTokens entity.
|
||||
func (at *AuthTokens) QueryRoles() *AuthRolesQuery {
|
||||
return NewAuthTokensClient(at.config).QueryRoles(at)
|
||||
func (_m *AuthTokens) QueryRoles() *AuthRolesQuery {
|
||||
return NewAuthTokensClient(_m.config).QueryRoles(_m)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this AuthTokens.
|
||||
// Note that you need to call AuthTokens.Unwrap() before calling this method if this AuthTokens
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (at *AuthTokens) Update() *AuthTokensUpdateOne {
|
||||
return NewAuthTokensClient(at.config).UpdateOne(at)
|
||||
func (_m *AuthTokens) Update() *AuthTokensUpdateOne {
|
||||
return NewAuthTokensClient(_m.config).UpdateOne(_m)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the AuthTokens entity that was returned from a transaction after it was closed,
|
||||
// so that all future queries will be executed through the driver which created the transaction.
|
||||
func (at *AuthTokens) Unwrap() *AuthTokens {
|
||||
_tx, ok := at.config.driver.(*txDriver)
|
||||
func (_m *AuthTokens) Unwrap() *AuthTokens {
|
||||
_tx, ok := _m.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: AuthTokens is not a transactional entity")
|
||||
}
|
||||
at.config.driver = _tx.drv
|
||||
return at
|
||||
_m.config.driver = _tx.drv
|
||||
return _m
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (at *AuthTokens) String() string {
|
||||
func (_m *AuthTokens) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("AuthTokens(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", at.ID))
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||||
builder.WriteString("created_at=")
|
||||
builder.WriteString(at.CreatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("updated_at=")
|
||||
builder.WriteString(at.UpdatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("token=")
|
||||
builder.WriteString(fmt.Sprintf("%v", at.Token))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Token))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("expires_at=")
|
||||
builder.WriteString(at.ExpiresAt.Format(time.ANSIC))
|
||||
builder.WriteString(_m.ExpiresAt.Format(time.ANSIC))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
@@ -24,119 +24,119 @@ type AuthTokensCreate struct {
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (atc *AuthTokensCreate) SetCreatedAt(t time.Time) *AuthTokensCreate {
|
||||
atc.mutation.SetCreatedAt(t)
|
||||
return atc
|
||||
func (_c *AuthTokensCreate) SetCreatedAt(v time.Time) *AuthTokensCreate {
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||
func (atc *AuthTokensCreate) SetNillableCreatedAt(t *time.Time) *AuthTokensCreate {
|
||||
if t != nil {
|
||||
atc.SetCreatedAt(*t)
|
||||
func (_c *AuthTokensCreate) SetNillableCreatedAt(v *time.Time) *AuthTokensCreate {
|
||||
if v != nil {
|
||||
_c.SetCreatedAt(*v)
|
||||
}
|
||||
return atc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (atc *AuthTokensCreate) SetUpdatedAt(t time.Time) *AuthTokensCreate {
|
||||
atc.mutation.SetUpdatedAt(t)
|
||||
return atc
|
||||
func (_c *AuthTokensCreate) SetUpdatedAt(v time.Time) *AuthTokensCreate {
|
||||
_c.mutation.SetUpdatedAt(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
||||
func (atc *AuthTokensCreate) SetNillableUpdatedAt(t *time.Time) *AuthTokensCreate {
|
||||
if t != nil {
|
||||
atc.SetUpdatedAt(*t)
|
||||
func (_c *AuthTokensCreate) SetNillableUpdatedAt(v *time.Time) *AuthTokensCreate {
|
||||
if v != nil {
|
||||
_c.SetUpdatedAt(*v)
|
||||
}
|
||||
return atc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetToken sets the "token" field.
|
||||
func (atc *AuthTokensCreate) SetToken(b []byte) *AuthTokensCreate {
|
||||
atc.mutation.SetToken(b)
|
||||
return atc
|
||||
func (_c *AuthTokensCreate) SetToken(v []byte) *AuthTokensCreate {
|
||||
_c.mutation.SetToken(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetExpiresAt sets the "expires_at" field.
|
||||
func (atc *AuthTokensCreate) SetExpiresAt(t time.Time) *AuthTokensCreate {
|
||||
atc.mutation.SetExpiresAt(t)
|
||||
return atc
|
||||
func (_c *AuthTokensCreate) SetExpiresAt(v time.Time) *AuthTokensCreate {
|
||||
_c.mutation.SetExpiresAt(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableExpiresAt sets the "expires_at" field if the given value is not nil.
|
||||
func (atc *AuthTokensCreate) SetNillableExpiresAt(t *time.Time) *AuthTokensCreate {
|
||||
if t != nil {
|
||||
atc.SetExpiresAt(*t)
|
||||
func (_c *AuthTokensCreate) SetNillableExpiresAt(v *time.Time) *AuthTokensCreate {
|
||||
if v != nil {
|
||||
_c.SetExpiresAt(*v)
|
||||
}
|
||||
return atc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetID sets the "id" field.
|
||||
func (atc *AuthTokensCreate) SetID(u uuid.UUID) *AuthTokensCreate {
|
||||
atc.mutation.SetID(u)
|
||||
return atc
|
||||
func (_c *AuthTokensCreate) SetID(v uuid.UUID) *AuthTokensCreate {
|
||||
_c.mutation.SetID(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableID sets the "id" field if the given value is not nil.
|
||||
func (atc *AuthTokensCreate) SetNillableID(u *uuid.UUID) *AuthTokensCreate {
|
||||
if u != nil {
|
||||
atc.SetID(*u)
|
||||
func (_c *AuthTokensCreate) SetNillableID(v *uuid.UUID) *AuthTokensCreate {
|
||||
if v != nil {
|
||||
_c.SetID(*v)
|
||||
}
|
||||
return atc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetUserID sets the "user" edge to the User entity by ID.
|
||||
func (atc *AuthTokensCreate) SetUserID(id uuid.UUID) *AuthTokensCreate {
|
||||
atc.mutation.SetUserID(id)
|
||||
return atc
|
||||
func (_c *AuthTokensCreate) SetUserID(id uuid.UUID) *AuthTokensCreate {
|
||||
_c.mutation.SetUserID(id)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableUserID sets the "user" edge to the User entity by ID if the given value is not nil.
|
||||
func (atc *AuthTokensCreate) SetNillableUserID(id *uuid.UUID) *AuthTokensCreate {
|
||||
func (_c *AuthTokensCreate) SetNillableUserID(id *uuid.UUID) *AuthTokensCreate {
|
||||
if id != nil {
|
||||
atc = atc.SetUserID(*id)
|
||||
_c = _c.SetUserID(*id)
|
||||
}
|
||||
return atc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetUser sets the "user" edge to the User entity.
|
||||
func (atc *AuthTokensCreate) SetUser(u *User) *AuthTokensCreate {
|
||||
return atc.SetUserID(u.ID)
|
||||
func (_c *AuthTokensCreate) SetUser(v *User) *AuthTokensCreate {
|
||||
return _c.SetUserID(v.ID)
|
||||
}
|
||||
|
||||
// SetRolesID sets the "roles" edge to the AuthRoles entity by ID.
|
||||
func (atc *AuthTokensCreate) SetRolesID(id int) *AuthTokensCreate {
|
||||
atc.mutation.SetRolesID(id)
|
||||
return atc
|
||||
func (_c *AuthTokensCreate) SetRolesID(id int) *AuthTokensCreate {
|
||||
_c.mutation.SetRolesID(id)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableRolesID sets the "roles" edge to the AuthRoles entity by ID if the given value is not nil.
|
||||
func (atc *AuthTokensCreate) SetNillableRolesID(id *int) *AuthTokensCreate {
|
||||
func (_c *AuthTokensCreate) SetNillableRolesID(id *int) *AuthTokensCreate {
|
||||
if id != nil {
|
||||
atc = atc.SetRolesID(*id)
|
||||
_c = _c.SetRolesID(*id)
|
||||
}
|
||||
return atc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetRoles sets the "roles" edge to the AuthRoles entity.
|
||||
func (atc *AuthTokensCreate) SetRoles(a *AuthRoles) *AuthTokensCreate {
|
||||
return atc.SetRolesID(a.ID)
|
||||
func (_c *AuthTokensCreate) SetRoles(v *AuthRoles) *AuthTokensCreate {
|
||||
return _c.SetRolesID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the AuthTokensMutation object of the builder.
|
||||
func (atc *AuthTokensCreate) Mutation() *AuthTokensMutation {
|
||||
return atc.mutation
|
||||
func (_c *AuthTokensCreate) Mutation() *AuthTokensMutation {
|
||||
return _c.mutation
|
||||
}
|
||||
|
||||
// Save creates the AuthTokens in the database.
|
||||
func (atc *AuthTokensCreate) Save(ctx context.Context) (*AuthTokens, error) {
|
||||
atc.defaults()
|
||||
return withHooks(ctx, atc.sqlSave, atc.mutation, atc.hooks)
|
||||
func (_c *AuthTokensCreate) Save(ctx context.Context) (*AuthTokens, error) {
|
||||
_c.defaults()
|
||||
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (atc *AuthTokensCreate) SaveX(ctx context.Context) *AuthTokens {
|
||||
v, err := atc.Save(ctx)
|
||||
func (_c *AuthTokensCreate) SaveX(ctx context.Context) *AuthTokens {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -144,61 +144,61 @@ func (atc *AuthTokensCreate) SaveX(ctx context.Context) *AuthTokens {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (atc *AuthTokensCreate) Exec(ctx context.Context) error {
|
||||
_, err := atc.Save(ctx)
|
||||
func (_c *AuthTokensCreate) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (atc *AuthTokensCreate) ExecX(ctx context.Context) {
|
||||
if err := atc.Exec(ctx); err != nil {
|
||||
func (_c *AuthTokensCreate) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (atc *AuthTokensCreate) defaults() {
|
||||
if _, ok := atc.mutation.CreatedAt(); !ok {
|
||||
func (_c *AuthTokensCreate) defaults() {
|
||||
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||
v := authtokens.DefaultCreatedAt()
|
||||
atc.mutation.SetCreatedAt(v)
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
}
|
||||
if _, ok := atc.mutation.UpdatedAt(); !ok {
|
||||
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
||||
v := authtokens.DefaultUpdatedAt()
|
||||
atc.mutation.SetUpdatedAt(v)
|
||||
_c.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
if _, ok := atc.mutation.ExpiresAt(); !ok {
|
||||
if _, ok := _c.mutation.ExpiresAt(); !ok {
|
||||
v := authtokens.DefaultExpiresAt()
|
||||
atc.mutation.SetExpiresAt(v)
|
||||
_c.mutation.SetExpiresAt(v)
|
||||
}
|
||||
if _, ok := atc.mutation.ID(); !ok {
|
||||
if _, ok := _c.mutation.ID(); !ok {
|
||||
v := authtokens.DefaultID()
|
||||
atc.mutation.SetID(v)
|
||||
_c.mutation.SetID(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (atc *AuthTokensCreate) check() error {
|
||||
if _, ok := atc.mutation.CreatedAt(); !ok {
|
||||
func (_c *AuthTokensCreate) check() error {
|
||||
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "AuthTokens.created_at"`)}
|
||||
}
|
||||
if _, ok := atc.mutation.UpdatedAt(); !ok {
|
||||
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
||||
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "AuthTokens.updated_at"`)}
|
||||
}
|
||||
if _, ok := atc.mutation.Token(); !ok {
|
||||
if _, ok := _c.mutation.Token(); !ok {
|
||||
return &ValidationError{Name: "token", err: errors.New(`ent: missing required field "AuthTokens.token"`)}
|
||||
}
|
||||
if _, ok := atc.mutation.ExpiresAt(); !ok {
|
||||
if _, ok := _c.mutation.ExpiresAt(); !ok {
|
||||
return &ValidationError{Name: "expires_at", err: errors.New(`ent: missing required field "AuthTokens.expires_at"`)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (atc *AuthTokensCreate) sqlSave(ctx context.Context) (*AuthTokens, error) {
|
||||
if err := atc.check(); err != nil {
|
||||
func (_c *AuthTokensCreate) sqlSave(ctx context.Context) (*AuthTokens, error) {
|
||||
if err := _c.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_node, _spec := atc.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, atc.driver, _spec); err != nil {
|
||||
_node, _spec := _c.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
@@ -211,37 +211,37 @@ func (atc *AuthTokensCreate) sqlSave(ctx context.Context) (*AuthTokens, error) {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
atc.mutation.id = &_node.ID
|
||||
atc.mutation.done = true
|
||||
_c.mutation.id = &_node.ID
|
||||
_c.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
func (atc *AuthTokensCreate) createSpec() (*AuthTokens, *sqlgraph.CreateSpec) {
|
||||
func (_c *AuthTokensCreate) createSpec() (*AuthTokens, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &AuthTokens{config: atc.config}
|
||||
_node = &AuthTokens{config: _c.config}
|
||||
_spec = sqlgraph.NewCreateSpec(authtokens.Table, sqlgraph.NewFieldSpec(authtokens.FieldID, field.TypeUUID))
|
||||
)
|
||||
if id, ok := atc.mutation.ID(); ok {
|
||||
if id, ok := _c.mutation.ID(); ok {
|
||||
_node.ID = id
|
||||
_spec.ID.Value = &id
|
||||
}
|
||||
if value, ok := atc.mutation.CreatedAt(); ok {
|
||||
if value, ok := _c.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(authtokens.FieldCreatedAt, field.TypeTime, value)
|
||||
_node.CreatedAt = value
|
||||
}
|
||||
if value, ok := atc.mutation.UpdatedAt(); ok {
|
||||
if value, ok := _c.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(authtokens.FieldUpdatedAt, field.TypeTime, value)
|
||||
_node.UpdatedAt = value
|
||||
}
|
||||
if value, ok := atc.mutation.Token(); ok {
|
||||
if value, ok := _c.mutation.Token(); ok {
|
||||
_spec.SetField(authtokens.FieldToken, field.TypeBytes, value)
|
||||
_node.Token = value
|
||||
}
|
||||
if value, ok := atc.mutation.ExpiresAt(); ok {
|
||||
if value, ok := _c.mutation.ExpiresAt(); ok {
|
||||
_spec.SetField(authtokens.FieldExpiresAt, field.TypeTime, value)
|
||||
_node.ExpiresAt = value
|
||||
}
|
||||
if nodes := atc.mutation.UserIDs(); len(nodes) > 0 {
|
||||
if nodes := _c.mutation.UserIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -258,7 +258,7 @@ func (atc *AuthTokensCreate) createSpec() (*AuthTokens, *sqlgraph.CreateSpec) {
|
||||
_node.user_auth_tokens = &nodes[0]
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
if nodes := atc.mutation.RolesIDs(); len(nodes) > 0 {
|
||||
if nodes := _c.mutation.RolesIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2O,
|
||||
Inverse: false,
|
||||
@@ -285,16 +285,16 @@ type AuthTokensCreateBulk struct {
|
||||
}
|
||||
|
||||
// Save creates the AuthTokens entities in the database.
|
||||
func (atcb *AuthTokensCreateBulk) Save(ctx context.Context) ([]*AuthTokens, error) {
|
||||
if atcb.err != nil {
|
||||
return nil, atcb.err
|
||||
func (_c *AuthTokensCreateBulk) Save(ctx context.Context) ([]*AuthTokens, error) {
|
||||
if _c.err != nil {
|
||||
return nil, _c.err
|
||||
}
|
||||
specs := make([]*sqlgraph.CreateSpec, len(atcb.builders))
|
||||
nodes := make([]*AuthTokens, len(atcb.builders))
|
||||
mutators := make([]Mutator, len(atcb.builders))
|
||||
for i := range atcb.builders {
|
||||
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
||||
nodes := make([]*AuthTokens, len(_c.builders))
|
||||
mutators := make([]Mutator, len(_c.builders))
|
||||
for i := range _c.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := atcb.builders[i]
|
||||
builder := _c.builders[i]
|
||||
builder.defaults()
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*AuthTokensMutation)
|
||||
@@ -308,11 +308,11 @@ func (atcb *AuthTokensCreateBulk) Save(ctx context.Context) ([]*AuthTokens, erro
|
||||
var err error
|
||||
nodes[i], specs[i] = builder.createSpec()
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, atcb.builders[i+1].mutation)
|
||||
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
|
||||
} else {
|
||||
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
||||
// Invoke the actual operation on the latest mutation in the chain.
|
||||
if err = sqlgraph.BatchCreate(ctx, atcb.driver, spec); err != nil {
|
||||
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
@@ -332,7 +332,7 @@ func (atcb *AuthTokensCreateBulk) Save(ctx context.Context) ([]*AuthTokens, erro
|
||||
}(i, ctx)
|
||||
}
|
||||
if len(mutators) > 0 {
|
||||
if _, err := mutators[0].Mutate(ctx, atcb.builders[0].mutation); err != nil {
|
||||
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
@@ -340,8 +340,8 @@ func (atcb *AuthTokensCreateBulk) Save(ctx context.Context) ([]*AuthTokens, erro
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (atcb *AuthTokensCreateBulk) SaveX(ctx context.Context) []*AuthTokens {
|
||||
v, err := atcb.Save(ctx)
|
||||
func (_c *AuthTokensCreateBulk) SaveX(ctx context.Context) []*AuthTokens {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -349,14 +349,14 @@ func (atcb *AuthTokensCreateBulk) SaveX(ctx context.Context) []*AuthTokens {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (atcb *AuthTokensCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := atcb.Save(ctx)
|
||||
func (_c *AuthTokensCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (atcb *AuthTokensCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := atcb.Exec(ctx); err != nil {
|
||||
func (_c *AuthTokensCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,56 +20,56 @@ type AuthTokensDelete struct {
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the AuthTokensDelete builder.
|
||||
func (atd *AuthTokensDelete) Where(ps ...predicate.AuthTokens) *AuthTokensDelete {
|
||||
atd.mutation.Where(ps...)
|
||||
return atd
|
||||
func (_d *AuthTokensDelete) Where(ps ...predicate.AuthTokens) *AuthTokensDelete {
|
||||
_d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (atd *AuthTokensDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, atd.sqlExec, atd.mutation, atd.hooks)
|
||||
func (_d *AuthTokensDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (atd *AuthTokensDelete) ExecX(ctx context.Context) int {
|
||||
n, err := atd.Exec(ctx)
|
||||
func (_d *AuthTokensDelete) ExecX(ctx context.Context) int {
|
||||
n, err := _d.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (atd *AuthTokensDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
func (_d *AuthTokensDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := sqlgraph.NewDeleteSpec(authtokens.Table, sqlgraph.NewFieldSpec(authtokens.FieldID, field.TypeUUID))
|
||||
if ps := atd.mutation.predicates; len(ps) > 0 {
|
||||
if ps := _d.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, atd.driver, _spec)
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec)
|
||||
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
atd.mutation.done = true
|
||||
_d.mutation.done = true
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// AuthTokensDeleteOne is the builder for deleting a single AuthTokens entity.
|
||||
type AuthTokensDeleteOne struct {
|
||||
atd *AuthTokensDelete
|
||||
_d *AuthTokensDelete
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the AuthTokensDelete builder.
|
||||
func (atdo *AuthTokensDeleteOne) Where(ps ...predicate.AuthTokens) *AuthTokensDeleteOne {
|
||||
atdo.atd.mutation.Where(ps...)
|
||||
return atdo
|
||||
func (_d *AuthTokensDeleteOne) Where(ps ...predicate.AuthTokens) *AuthTokensDeleteOne {
|
||||
_d._d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (atdo *AuthTokensDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := atdo.atd.Exec(ctx)
|
||||
func (_d *AuthTokensDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := _d._d.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
@@ -81,8 +81,8 @@ func (atdo *AuthTokensDeleteOne) Exec(ctx context.Context) error {
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (atdo *AuthTokensDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := atdo.Exec(ctx); err != nil {
|
||||
func (_d *AuthTokensDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := _d.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,44 +35,44 @@ type AuthTokensQuery struct {
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the AuthTokensQuery builder.
|
||||
func (atq *AuthTokensQuery) Where(ps ...predicate.AuthTokens) *AuthTokensQuery {
|
||||
atq.predicates = append(atq.predicates, ps...)
|
||||
return atq
|
||||
func (_q *AuthTokensQuery) Where(ps ...predicate.AuthTokens) *AuthTokensQuery {
|
||||
_q.predicates = append(_q.predicates, ps...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// Limit the number of records to be returned by this query.
|
||||
func (atq *AuthTokensQuery) Limit(limit int) *AuthTokensQuery {
|
||||
atq.ctx.Limit = &limit
|
||||
return atq
|
||||
func (_q *AuthTokensQuery) Limit(limit int) *AuthTokensQuery {
|
||||
_q.ctx.Limit = &limit
|
||||
return _q
|
||||
}
|
||||
|
||||
// Offset to start from.
|
||||
func (atq *AuthTokensQuery) Offset(offset int) *AuthTokensQuery {
|
||||
atq.ctx.Offset = &offset
|
||||
return atq
|
||||
func (_q *AuthTokensQuery) Offset(offset int) *AuthTokensQuery {
|
||||
_q.ctx.Offset = &offset
|
||||
return _q
|
||||
}
|
||||
|
||||
// Unique configures the query builder to filter duplicate records on query.
|
||||
// By default, unique is set to true, and can be disabled using this method.
|
||||
func (atq *AuthTokensQuery) Unique(unique bool) *AuthTokensQuery {
|
||||
atq.ctx.Unique = &unique
|
||||
return atq
|
||||
func (_q *AuthTokensQuery) Unique(unique bool) *AuthTokensQuery {
|
||||
_q.ctx.Unique = &unique
|
||||
return _q
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (atq *AuthTokensQuery) Order(o ...authtokens.OrderOption) *AuthTokensQuery {
|
||||
atq.order = append(atq.order, o...)
|
||||
return atq
|
||||
func (_q *AuthTokensQuery) Order(o ...authtokens.OrderOption) *AuthTokensQuery {
|
||||
_q.order = append(_q.order, o...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// QueryUser chains the current query on the "user" edge.
|
||||
func (atq *AuthTokensQuery) QueryUser() *UserQuery {
|
||||
query := (&UserClient{config: atq.config}).Query()
|
||||
func (_q *AuthTokensQuery) QueryUser() *UserQuery {
|
||||
query := (&UserClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := atq.prepareQuery(ctx); err != nil {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := atq.sqlQuery(ctx)
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -81,20 +81,20 @@ func (atq *AuthTokensQuery) QueryUser() *UserQuery {
|
||||
sqlgraph.To(user.Table, user.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, authtokens.UserTable, authtokens.UserColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(atq.driver.Dialect(), step)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryRoles chains the current query on the "roles" edge.
|
||||
func (atq *AuthTokensQuery) QueryRoles() *AuthRolesQuery {
|
||||
query := (&AuthRolesClient{config: atq.config}).Query()
|
||||
func (_q *AuthTokensQuery) QueryRoles() *AuthRolesQuery {
|
||||
query := (&AuthRolesClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := atq.prepareQuery(ctx); err != nil {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := atq.sqlQuery(ctx)
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -103,7 +103,7 @@ func (atq *AuthTokensQuery) QueryRoles() *AuthRolesQuery {
|
||||
sqlgraph.To(authroles.Table, authroles.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2O, false, authtokens.RolesTable, authtokens.RolesColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(atq.driver.Dialect(), step)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
@@ -111,8 +111,8 @@ func (atq *AuthTokensQuery) QueryRoles() *AuthRolesQuery {
|
||||
|
||||
// First returns the first AuthTokens entity from the query.
|
||||
// Returns a *NotFoundError when no AuthTokens was found.
|
||||
func (atq *AuthTokensQuery) First(ctx context.Context) (*AuthTokens, error) {
|
||||
nodes, err := atq.Limit(1).All(setContextOp(ctx, atq.ctx, ent.OpQueryFirst))
|
||||
func (_q *AuthTokensQuery) First(ctx context.Context) (*AuthTokens, error) {
|
||||
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -123,8 +123,8 @@ func (atq *AuthTokensQuery) First(ctx context.Context) (*AuthTokens, error) {
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (atq *AuthTokensQuery) FirstX(ctx context.Context) *AuthTokens {
|
||||
node, err := atq.First(ctx)
|
||||
func (_q *AuthTokensQuery) FirstX(ctx context.Context) *AuthTokens {
|
||||
node, err := _q.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
@@ -133,9 +133,9 @@ func (atq *AuthTokensQuery) FirstX(ctx context.Context) *AuthTokens {
|
||||
|
||||
// FirstID returns the first AuthTokens ID from the query.
|
||||
// Returns a *NotFoundError when no AuthTokens ID was found.
|
||||
func (atq *AuthTokensQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
func (_q *AuthTokensQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
var ids []uuid.UUID
|
||||
if ids, err = atq.Limit(1).IDs(setContextOp(ctx, atq.ctx, ent.OpQueryFirstID)); err != nil {
|
||||
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
@@ -146,8 +146,8 @@ func (atq *AuthTokensQuery) FirstID(ctx context.Context) (id uuid.UUID, err erro
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (atq *AuthTokensQuery) FirstIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := atq.FirstID(ctx)
|
||||
func (_q *AuthTokensQuery) FirstIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := _q.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
@@ -157,8 +157,8 @@ func (atq *AuthTokensQuery) FirstIDX(ctx context.Context) uuid.UUID {
|
||||
// Only returns a single AuthTokens entity found by the query, ensuring it only returns one.
|
||||
// Returns a *NotSingularError when more than one AuthTokens entity is found.
|
||||
// Returns a *NotFoundError when no AuthTokens entities are found.
|
||||
func (atq *AuthTokensQuery) Only(ctx context.Context) (*AuthTokens, error) {
|
||||
nodes, err := atq.Limit(2).All(setContextOp(ctx, atq.ctx, ent.OpQueryOnly))
|
||||
func (_q *AuthTokensQuery) Only(ctx context.Context) (*AuthTokens, error) {
|
||||
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -173,8 +173,8 @@ func (atq *AuthTokensQuery) Only(ctx context.Context) (*AuthTokens, error) {
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (atq *AuthTokensQuery) OnlyX(ctx context.Context) *AuthTokens {
|
||||
node, err := atq.Only(ctx)
|
||||
func (_q *AuthTokensQuery) OnlyX(ctx context.Context) *AuthTokens {
|
||||
node, err := _q.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -184,9 +184,9 @@ func (atq *AuthTokensQuery) OnlyX(ctx context.Context) *AuthTokens {
|
||||
// OnlyID is like Only, but returns the only AuthTokens ID in the query.
|
||||
// Returns a *NotSingularError when more than one AuthTokens ID is found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (atq *AuthTokensQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
func (_q *AuthTokensQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
var ids []uuid.UUID
|
||||
if ids, err = atq.Limit(2).IDs(setContextOp(ctx, atq.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
@@ -201,8 +201,8 @@ func (atq *AuthTokensQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (atq *AuthTokensQuery) OnlyIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := atq.OnlyID(ctx)
|
||||
func (_q *AuthTokensQuery) OnlyIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := _q.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -210,18 +210,18 @@ func (atq *AuthTokensQuery) OnlyIDX(ctx context.Context) uuid.UUID {
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of AuthTokensSlice.
|
||||
func (atq *AuthTokensQuery) All(ctx context.Context) ([]*AuthTokens, error) {
|
||||
ctx = setContextOp(ctx, atq.ctx, ent.OpQueryAll)
|
||||
if err := atq.prepareQuery(ctx); err != nil {
|
||||
func (_q *AuthTokensQuery) All(ctx context.Context) ([]*AuthTokens, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qr := querierAll[[]*AuthTokens, *AuthTokensQuery]()
|
||||
return withInterceptors[[]*AuthTokens](ctx, atq, qr, atq.inters)
|
||||
return withInterceptors[[]*AuthTokens](ctx, _q, qr, _q.inters)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (atq *AuthTokensQuery) AllX(ctx context.Context) []*AuthTokens {
|
||||
nodes, err := atq.All(ctx)
|
||||
func (_q *AuthTokensQuery) AllX(ctx context.Context) []*AuthTokens {
|
||||
nodes, err := _q.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -229,20 +229,20 @@ func (atq *AuthTokensQuery) AllX(ctx context.Context) []*AuthTokens {
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of AuthTokens IDs.
|
||||
func (atq *AuthTokensQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
|
||||
if atq.ctx.Unique == nil && atq.path != nil {
|
||||
atq.Unique(true)
|
||||
func (_q *AuthTokensQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
|
||||
if _q.ctx.Unique == nil && _q.path != nil {
|
||||
_q.Unique(true)
|
||||
}
|
||||
ctx = setContextOp(ctx, atq.ctx, ent.OpQueryIDs)
|
||||
if err = atq.Select(authtokens.FieldID).Scan(ctx, &ids); err != nil {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
|
||||
if err = _q.Select(authtokens.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (atq *AuthTokensQuery) IDsX(ctx context.Context) []uuid.UUID {
|
||||
ids, err := atq.IDs(ctx)
|
||||
func (_q *AuthTokensQuery) IDsX(ctx context.Context) []uuid.UUID {
|
||||
ids, err := _q.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -250,17 +250,17 @@ func (atq *AuthTokensQuery) IDsX(ctx context.Context) []uuid.UUID {
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (atq *AuthTokensQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, atq.ctx, ent.OpQueryCount)
|
||||
if err := atq.prepareQuery(ctx); err != nil {
|
||||
func (_q *AuthTokensQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return withInterceptors[int](ctx, atq, querierCount[*AuthTokensQuery](), atq.inters)
|
||||
return withInterceptors[int](ctx, _q, querierCount[*AuthTokensQuery](), _q.inters)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (atq *AuthTokensQuery) CountX(ctx context.Context) int {
|
||||
count, err := atq.Count(ctx)
|
||||
func (_q *AuthTokensQuery) CountX(ctx context.Context) int {
|
||||
count, err := _q.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -268,9 +268,9 @@ func (atq *AuthTokensQuery) CountX(ctx context.Context) int {
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (atq *AuthTokensQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, atq.ctx, ent.OpQueryExist)
|
||||
switch _, err := atq.FirstID(ctx); {
|
||||
func (_q *AuthTokensQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
|
||||
switch _, err := _q.FirstID(ctx); {
|
||||
case IsNotFound(err):
|
||||
return false, nil
|
||||
case err != nil:
|
||||
@@ -281,8 +281,8 @@ func (atq *AuthTokensQuery) Exist(ctx context.Context) (bool, error) {
|
||||
}
|
||||
|
||||
// ExistX is like Exist, but panics if an error occurs.
|
||||
func (atq *AuthTokensQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := atq.Exist(ctx)
|
||||
func (_q *AuthTokensQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := _q.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -291,44 +291,44 @@ func (atq *AuthTokensQuery) ExistX(ctx context.Context) bool {
|
||||
|
||||
// Clone returns a duplicate of the AuthTokensQuery builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (atq *AuthTokensQuery) Clone() *AuthTokensQuery {
|
||||
if atq == nil {
|
||||
func (_q *AuthTokensQuery) Clone() *AuthTokensQuery {
|
||||
if _q == nil {
|
||||
return nil
|
||||
}
|
||||
return &AuthTokensQuery{
|
||||
config: atq.config,
|
||||
ctx: atq.ctx.Clone(),
|
||||
order: append([]authtokens.OrderOption{}, atq.order...),
|
||||
inters: append([]Interceptor{}, atq.inters...),
|
||||
predicates: append([]predicate.AuthTokens{}, atq.predicates...),
|
||||
withUser: atq.withUser.Clone(),
|
||||
withRoles: atq.withRoles.Clone(),
|
||||
config: _q.config,
|
||||
ctx: _q.ctx.Clone(),
|
||||
order: append([]authtokens.OrderOption{}, _q.order...),
|
||||
inters: append([]Interceptor{}, _q.inters...),
|
||||
predicates: append([]predicate.AuthTokens{}, _q.predicates...),
|
||||
withUser: _q.withUser.Clone(),
|
||||
withRoles: _q.withRoles.Clone(),
|
||||
// clone intermediate query.
|
||||
sql: atq.sql.Clone(),
|
||||
path: atq.path,
|
||||
sql: _q.sql.Clone(),
|
||||
path: _q.path,
|
||||
}
|
||||
}
|
||||
|
||||
// WithUser tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "user" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (atq *AuthTokensQuery) WithUser(opts ...func(*UserQuery)) *AuthTokensQuery {
|
||||
query := (&UserClient{config: atq.config}).Query()
|
||||
func (_q *AuthTokensQuery) WithUser(opts ...func(*UserQuery)) *AuthTokensQuery {
|
||||
query := (&UserClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
atq.withUser = query
|
||||
return atq
|
||||
_q.withUser = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// WithRoles tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "roles" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (atq *AuthTokensQuery) WithRoles(opts ...func(*AuthRolesQuery)) *AuthTokensQuery {
|
||||
query := (&AuthRolesClient{config: atq.config}).Query()
|
||||
func (_q *AuthTokensQuery) WithRoles(opts ...func(*AuthRolesQuery)) *AuthTokensQuery {
|
||||
query := (&AuthRolesClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
atq.withRoles = query
|
||||
return atq
|
||||
_q.withRoles = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// GroupBy is used to group vertices by one or more fields/columns.
|
||||
@@ -345,10 +345,10 @@ func (atq *AuthTokensQuery) WithRoles(opts ...func(*AuthRolesQuery)) *AuthTokens
|
||||
// GroupBy(authtokens.FieldCreatedAt).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (atq *AuthTokensQuery) GroupBy(field string, fields ...string) *AuthTokensGroupBy {
|
||||
atq.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &AuthTokensGroupBy{build: atq}
|
||||
grbuild.flds = &atq.ctx.Fields
|
||||
func (_q *AuthTokensQuery) GroupBy(field string, fields ...string) *AuthTokensGroupBy {
|
||||
_q.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &AuthTokensGroupBy{build: _q}
|
||||
grbuild.flds = &_q.ctx.Fields
|
||||
grbuild.label = authtokens.Label
|
||||
grbuild.scan = grbuild.Scan
|
||||
return grbuild
|
||||
@@ -366,56 +366,56 @@ func (atq *AuthTokensQuery) GroupBy(field string, fields ...string) *AuthTokensG
|
||||
// client.AuthTokens.Query().
|
||||
// Select(authtokens.FieldCreatedAt).
|
||||
// Scan(ctx, &v)
|
||||
func (atq *AuthTokensQuery) Select(fields ...string) *AuthTokensSelect {
|
||||
atq.ctx.Fields = append(atq.ctx.Fields, fields...)
|
||||
sbuild := &AuthTokensSelect{AuthTokensQuery: atq}
|
||||
func (_q *AuthTokensQuery) Select(fields ...string) *AuthTokensSelect {
|
||||
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
||||
sbuild := &AuthTokensSelect{AuthTokensQuery: _q}
|
||||
sbuild.label = authtokens.Label
|
||||
sbuild.flds, sbuild.scan = &atq.ctx.Fields, sbuild.Scan
|
||||
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
|
||||
return sbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a AuthTokensSelect configured with the given aggregations.
|
||||
func (atq *AuthTokensQuery) Aggregate(fns ...AggregateFunc) *AuthTokensSelect {
|
||||
return atq.Select().Aggregate(fns...)
|
||||
func (_q *AuthTokensQuery) Aggregate(fns ...AggregateFunc) *AuthTokensSelect {
|
||||
return _q.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (atq *AuthTokensQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range atq.inters {
|
||||
func (_q *AuthTokensQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range _q.inters {
|
||||
if inter == nil {
|
||||
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
|
||||
}
|
||||
if trv, ok := inter.(Traverser); ok {
|
||||
if err := trv.Traverse(ctx, atq); err != nil {
|
||||
if err := trv.Traverse(ctx, _q); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, f := range atq.ctx.Fields {
|
||||
for _, f := range _q.ctx.Fields {
|
||||
if !authtokens.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
}
|
||||
if atq.path != nil {
|
||||
prev, err := atq.path(ctx)
|
||||
if _q.path != nil {
|
||||
prev, err := _q.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
atq.sql = prev
|
||||
_q.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (atq *AuthTokensQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*AuthTokens, error) {
|
||||
func (_q *AuthTokensQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*AuthTokens, error) {
|
||||
var (
|
||||
nodes = []*AuthTokens{}
|
||||
withFKs = atq.withFKs
|
||||
_spec = atq.querySpec()
|
||||
withFKs = _q.withFKs
|
||||
_spec = _q.querySpec()
|
||||
loadedTypes = [2]bool{
|
||||
atq.withUser != nil,
|
||||
atq.withRoles != nil,
|
||||
_q.withUser != nil,
|
||||
_q.withRoles != nil,
|
||||
}
|
||||
)
|
||||
if atq.withUser != nil {
|
||||
if _q.withUser != nil {
|
||||
withFKs = true
|
||||
}
|
||||
if withFKs {
|
||||
@@ -425,7 +425,7 @@ func (atq *AuthTokensQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*
|
||||
return (*AuthTokens).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &AuthTokens{config: atq.config}
|
||||
node := &AuthTokens{config: _q.config}
|
||||
nodes = append(nodes, node)
|
||||
node.Edges.loadedTypes = loadedTypes
|
||||
return node.assignValues(columns, values)
|
||||
@@ -433,20 +433,20 @@ func (atq *AuthTokensQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*
|
||||
for i := range hooks {
|
||||
hooks[i](ctx, _spec)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, atq.driver, _spec); err != nil {
|
||||
if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
if query := atq.withUser; query != nil {
|
||||
if err := atq.loadUser(ctx, query, nodes, nil,
|
||||
if query := _q.withUser; query != nil {
|
||||
if err := _q.loadUser(ctx, query, nodes, nil,
|
||||
func(n *AuthTokens, e *User) { n.Edges.User = e }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if query := atq.withRoles; query != nil {
|
||||
if err := atq.loadRoles(ctx, query, nodes, nil,
|
||||
if query := _q.withRoles; query != nil {
|
||||
if err := _q.loadRoles(ctx, query, nodes, nil,
|
||||
func(n *AuthTokens, e *AuthRoles) { n.Edges.Roles = e }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -454,7 +454,7 @@ func (atq *AuthTokensQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (atq *AuthTokensQuery) loadUser(ctx context.Context, query *UserQuery, nodes []*AuthTokens, init func(*AuthTokens), assign func(*AuthTokens, *User)) error {
|
||||
func (_q *AuthTokensQuery) loadUser(ctx context.Context, query *UserQuery, nodes []*AuthTokens, init func(*AuthTokens), assign func(*AuthTokens, *User)) error {
|
||||
ids := make([]uuid.UUID, 0, len(nodes))
|
||||
nodeids := make(map[uuid.UUID][]*AuthTokens)
|
||||
for i := range nodes {
|
||||
@@ -486,7 +486,7 @@ func (atq *AuthTokensQuery) loadUser(ctx context.Context, query *UserQuery, node
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (atq *AuthTokensQuery) loadRoles(ctx context.Context, query *AuthRolesQuery, nodes []*AuthTokens, init func(*AuthTokens), assign func(*AuthTokens, *AuthRoles)) error {
|
||||
func (_q *AuthTokensQuery) loadRoles(ctx context.Context, query *AuthRolesQuery, nodes []*AuthTokens, init func(*AuthTokens), assign func(*AuthTokens, *AuthRoles)) error {
|
||||
fks := make([]driver.Value, 0, len(nodes))
|
||||
nodeids := make(map[uuid.UUID]*AuthTokens)
|
||||
for i := range nodes {
|
||||
@@ -515,24 +515,24 @@ func (atq *AuthTokensQuery) loadRoles(ctx context.Context, query *AuthRolesQuery
|
||||
return nil
|
||||
}
|
||||
|
||||
func (atq *AuthTokensQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := atq.querySpec()
|
||||
_spec.Node.Columns = atq.ctx.Fields
|
||||
if len(atq.ctx.Fields) > 0 {
|
||||
_spec.Unique = atq.ctx.Unique != nil && *atq.ctx.Unique
|
||||
func (_q *AuthTokensQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := _q.querySpec()
|
||||
_spec.Node.Columns = _q.ctx.Fields
|
||||
if len(_q.ctx.Fields) > 0 {
|
||||
_spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, atq.driver, _spec)
|
||||
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
|
||||
}
|
||||
|
||||
func (atq *AuthTokensQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
func (_q *AuthTokensQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := sqlgraph.NewQuerySpec(authtokens.Table, authtokens.Columns, sqlgraph.NewFieldSpec(authtokens.FieldID, field.TypeUUID))
|
||||
_spec.From = atq.sql
|
||||
if unique := atq.ctx.Unique; unique != nil {
|
||||
_spec.From = _q.sql
|
||||
if unique := _q.ctx.Unique; unique != nil {
|
||||
_spec.Unique = *unique
|
||||
} else if atq.path != nil {
|
||||
} else if _q.path != nil {
|
||||
_spec.Unique = true
|
||||
}
|
||||
if fields := atq.ctx.Fields; len(fields) > 0 {
|
||||
if fields := _q.ctx.Fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, authtokens.FieldID)
|
||||
for i := range fields {
|
||||
@@ -541,20 +541,20 @@ func (atq *AuthTokensQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := atq.predicates; len(ps) > 0 {
|
||||
if ps := _q.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := atq.ctx.Limit; limit != nil {
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := atq.ctx.Offset; offset != nil {
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := atq.order; len(ps) > 0 {
|
||||
if ps := _q.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
@@ -564,33 +564,33 @@ func (atq *AuthTokensQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (atq *AuthTokensQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(atq.driver.Dialect())
|
||||
func (_q *AuthTokensQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(_q.driver.Dialect())
|
||||
t1 := builder.Table(authtokens.Table)
|
||||
columns := atq.ctx.Fields
|
||||
columns := _q.ctx.Fields
|
||||
if len(columns) == 0 {
|
||||
columns = authtokens.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if atq.sql != nil {
|
||||
selector = atq.sql
|
||||
if _q.sql != nil {
|
||||
selector = _q.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
if atq.ctx.Unique != nil && *atq.ctx.Unique {
|
||||
if _q.ctx.Unique != nil && *_q.ctx.Unique {
|
||||
selector.Distinct()
|
||||
}
|
||||
for _, p := range atq.predicates {
|
||||
for _, p := range _q.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range atq.order {
|
||||
for _, p := range _q.order {
|
||||
p(selector)
|
||||
}
|
||||
if offset := atq.ctx.Offset; offset != nil {
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
// limit is mandatory for offset clause. We start
|
||||
// with default value, and override it below if needed.
|
||||
selector.Offset(*offset).Limit(math.MaxInt32)
|
||||
}
|
||||
if limit := atq.ctx.Limit; limit != nil {
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
@@ -603,41 +603,41 @@ type AuthTokensGroupBy struct {
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (atgb *AuthTokensGroupBy) Aggregate(fns ...AggregateFunc) *AuthTokensGroupBy {
|
||||
atgb.fns = append(atgb.fns, fns...)
|
||||
return atgb
|
||||
func (_g *AuthTokensGroupBy) Aggregate(fns ...AggregateFunc) *AuthTokensGroupBy {
|
||||
_g.fns = append(_g.fns, fns...)
|
||||
return _g
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (atgb *AuthTokensGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, atgb.build.ctx, ent.OpQueryGroupBy)
|
||||
if err := atgb.build.prepareQuery(ctx); err != nil {
|
||||
func (_g *AuthTokensGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
|
||||
if err := _g.build.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*AuthTokensQuery, *AuthTokensGroupBy](ctx, atgb.build, atgb, atgb.build.inters, v)
|
||||
return scanWithInterceptors[*AuthTokensQuery, *AuthTokensGroupBy](ctx, _g.build, _g, _g.build.inters, v)
|
||||
}
|
||||
|
||||
func (atgb *AuthTokensGroupBy) sqlScan(ctx context.Context, root *AuthTokensQuery, v any) error {
|
||||
func (_g *AuthTokensGroupBy) sqlScan(ctx context.Context, root *AuthTokensQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx).Select()
|
||||
aggregation := make([]string, 0, len(atgb.fns))
|
||||
for _, fn := range atgb.fns {
|
||||
aggregation := make([]string, 0, len(_g.fns))
|
||||
for _, fn := range _g.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(*atgb.flds)+len(atgb.fns))
|
||||
for _, f := range *atgb.flds {
|
||||
columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
|
||||
for _, f := range *_g.flds {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
columns = append(columns, aggregation...)
|
||||
selector.Select(columns...)
|
||||
}
|
||||
selector.GroupBy(selector.Columns(*atgb.flds...)...)
|
||||
selector.GroupBy(selector.Columns(*_g.flds...)...)
|
||||
if err := selector.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := atgb.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
@@ -651,27 +651,27 @@ type AuthTokensSelect struct {
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (ats *AuthTokensSelect) Aggregate(fns ...AggregateFunc) *AuthTokensSelect {
|
||||
ats.fns = append(ats.fns, fns...)
|
||||
return ats
|
||||
func (_s *AuthTokensSelect) Aggregate(fns ...AggregateFunc) *AuthTokensSelect {
|
||||
_s.fns = append(_s.fns, fns...)
|
||||
return _s
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (ats *AuthTokensSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, ats.ctx, ent.OpQuerySelect)
|
||||
if err := ats.prepareQuery(ctx); err != nil {
|
||||
func (_s *AuthTokensSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
|
||||
if err := _s.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*AuthTokensQuery, *AuthTokensSelect](ctx, ats.AuthTokensQuery, ats, ats.inters, v)
|
||||
return scanWithInterceptors[*AuthTokensQuery, *AuthTokensSelect](ctx, _s.AuthTokensQuery, _s, _s.inters, v)
|
||||
}
|
||||
|
||||
func (ats *AuthTokensSelect) sqlScan(ctx context.Context, root *AuthTokensQuery, v any) error {
|
||||
func (_s *AuthTokensSelect) sqlScan(ctx context.Context, root *AuthTokensQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx)
|
||||
aggregation := make([]string, 0, len(ats.fns))
|
||||
for _, fn := range ats.fns {
|
||||
aggregation := make([]string, 0, len(_s.fns))
|
||||
for _, fn := range _s.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
switch n := len(*ats.selector.flds); {
|
||||
switch n := len(*_s.selector.flds); {
|
||||
case n == 0 && len(aggregation) > 0:
|
||||
selector.Select(aggregation...)
|
||||
case n != 0 && len(aggregation) > 0:
|
||||
@@ -679,7 +679,7 @@ func (ats *AuthTokensSelect) sqlScan(ctx context.Context, root *AuthTokensQuery,
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := ats.driver.Query(ctx, query, args, rows); err != nil {
|
||||
if err := _s.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
@@ -26,101 +26,101 @@ type AuthTokensUpdate struct {
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the AuthTokensUpdate builder.
|
||||
func (atu *AuthTokensUpdate) Where(ps ...predicate.AuthTokens) *AuthTokensUpdate {
|
||||
atu.mutation.Where(ps...)
|
||||
return atu
|
||||
func (_u *AuthTokensUpdate) Where(ps ...predicate.AuthTokens) *AuthTokensUpdate {
|
||||
_u.mutation.Where(ps...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (atu *AuthTokensUpdate) SetUpdatedAt(t time.Time) *AuthTokensUpdate {
|
||||
atu.mutation.SetUpdatedAt(t)
|
||||
return atu
|
||||
func (_u *AuthTokensUpdate) SetUpdatedAt(v time.Time) *AuthTokensUpdate {
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetToken sets the "token" field.
|
||||
func (atu *AuthTokensUpdate) SetToken(b []byte) *AuthTokensUpdate {
|
||||
atu.mutation.SetToken(b)
|
||||
return atu
|
||||
func (_u *AuthTokensUpdate) SetToken(v []byte) *AuthTokensUpdate {
|
||||
_u.mutation.SetToken(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetExpiresAt sets the "expires_at" field.
|
||||
func (atu *AuthTokensUpdate) SetExpiresAt(t time.Time) *AuthTokensUpdate {
|
||||
atu.mutation.SetExpiresAt(t)
|
||||
return atu
|
||||
func (_u *AuthTokensUpdate) SetExpiresAt(v time.Time) *AuthTokensUpdate {
|
||||
_u.mutation.SetExpiresAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableExpiresAt sets the "expires_at" field if the given value is not nil.
|
||||
func (atu *AuthTokensUpdate) SetNillableExpiresAt(t *time.Time) *AuthTokensUpdate {
|
||||
if t != nil {
|
||||
atu.SetExpiresAt(*t)
|
||||
func (_u *AuthTokensUpdate) SetNillableExpiresAt(v *time.Time) *AuthTokensUpdate {
|
||||
if v != nil {
|
||||
_u.SetExpiresAt(*v)
|
||||
}
|
||||
return atu
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUserID sets the "user" edge to the User entity by ID.
|
||||
func (atu *AuthTokensUpdate) SetUserID(id uuid.UUID) *AuthTokensUpdate {
|
||||
atu.mutation.SetUserID(id)
|
||||
return atu
|
||||
func (_u *AuthTokensUpdate) SetUserID(id uuid.UUID) *AuthTokensUpdate {
|
||||
_u.mutation.SetUserID(id)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableUserID sets the "user" edge to the User entity by ID if the given value is not nil.
|
||||
func (atu *AuthTokensUpdate) SetNillableUserID(id *uuid.UUID) *AuthTokensUpdate {
|
||||
func (_u *AuthTokensUpdate) SetNillableUserID(id *uuid.UUID) *AuthTokensUpdate {
|
||||
if id != nil {
|
||||
atu = atu.SetUserID(*id)
|
||||
_u = _u.SetUserID(*id)
|
||||
}
|
||||
return atu
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUser sets the "user" edge to the User entity.
|
||||
func (atu *AuthTokensUpdate) SetUser(u *User) *AuthTokensUpdate {
|
||||
return atu.SetUserID(u.ID)
|
||||
func (_u *AuthTokensUpdate) SetUser(v *User) *AuthTokensUpdate {
|
||||
return _u.SetUserID(v.ID)
|
||||
}
|
||||
|
||||
// SetRolesID sets the "roles" edge to the AuthRoles entity by ID.
|
||||
func (atu *AuthTokensUpdate) SetRolesID(id int) *AuthTokensUpdate {
|
||||
atu.mutation.SetRolesID(id)
|
||||
return atu
|
||||
func (_u *AuthTokensUpdate) SetRolesID(id int) *AuthTokensUpdate {
|
||||
_u.mutation.SetRolesID(id)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableRolesID sets the "roles" edge to the AuthRoles entity by ID if the given value is not nil.
|
||||
func (atu *AuthTokensUpdate) SetNillableRolesID(id *int) *AuthTokensUpdate {
|
||||
func (_u *AuthTokensUpdate) SetNillableRolesID(id *int) *AuthTokensUpdate {
|
||||
if id != nil {
|
||||
atu = atu.SetRolesID(*id)
|
||||
_u = _u.SetRolesID(*id)
|
||||
}
|
||||
return atu
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetRoles sets the "roles" edge to the AuthRoles entity.
|
||||
func (atu *AuthTokensUpdate) SetRoles(a *AuthRoles) *AuthTokensUpdate {
|
||||
return atu.SetRolesID(a.ID)
|
||||
func (_u *AuthTokensUpdate) SetRoles(v *AuthRoles) *AuthTokensUpdate {
|
||||
return _u.SetRolesID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the AuthTokensMutation object of the builder.
|
||||
func (atu *AuthTokensUpdate) Mutation() *AuthTokensMutation {
|
||||
return atu.mutation
|
||||
func (_u *AuthTokensUpdate) Mutation() *AuthTokensMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// ClearUser clears the "user" edge to the User entity.
|
||||
func (atu *AuthTokensUpdate) ClearUser() *AuthTokensUpdate {
|
||||
atu.mutation.ClearUser()
|
||||
return atu
|
||||
func (_u *AuthTokensUpdate) ClearUser() *AuthTokensUpdate {
|
||||
_u.mutation.ClearUser()
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearRoles clears the "roles" edge to the AuthRoles entity.
|
||||
func (atu *AuthTokensUpdate) ClearRoles() *AuthTokensUpdate {
|
||||
atu.mutation.ClearRoles()
|
||||
return atu
|
||||
func (_u *AuthTokensUpdate) ClearRoles() *AuthTokensUpdate {
|
||||
_u.mutation.ClearRoles()
|
||||
return _u
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (atu *AuthTokensUpdate) Save(ctx context.Context) (int, error) {
|
||||
atu.defaults()
|
||||
return withHooks(ctx, atu.sqlSave, atu.mutation, atu.hooks)
|
||||
func (_u *AuthTokensUpdate) Save(ctx context.Context) (int, error) {
|
||||
_u.defaults()
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (atu *AuthTokensUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := atu.Save(ctx)
|
||||
func (_u *AuthTokensUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -128,45 +128,45 @@ func (atu *AuthTokensUpdate) SaveX(ctx context.Context) int {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (atu *AuthTokensUpdate) Exec(ctx context.Context) error {
|
||||
_, err := atu.Save(ctx)
|
||||
func (_u *AuthTokensUpdate) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (atu *AuthTokensUpdate) ExecX(ctx context.Context) {
|
||||
if err := atu.Exec(ctx); err != nil {
|
||||
func (_u *AuthTokensUpdate) ExecX(ctx context.Context) {
|
||||
if err := _u.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (atu *AuthTokensUpdate) defaults() {
|
||||
if _, ok := atu.mutation.UpdatedAt(); !ok {
|
||||
func (_u *AuthTokensUpdate) defaults() {
|
||||
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
||||
v := authtokens.UpdateDefaultUpdatedAt()
|
||||
atu.mutation.SetUpdatedAt(v)
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
func (atu *AuthTokensUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
func (_u *AuthTokensUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
_spec := sqlgraph.NewUpdateSpec(authtokens.Table, authtokens.Columns, sqlgraph.NewFieldSpec(authtokens.FieldID, field.TypeUUID))
|
||||
if ps := atu.mutation.predicates; len(ps) > 0 {
|
||||
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := atu.mutation.UpdatedAt(); ok {
|
||||
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(authtokens.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := atu.mutation.Token(); ok {
|
||||
if value, ok := _u.mutation.Token(); ok {
|
||||
_spec.SetField(authtokens.FieldToken, field.TypeBytes, value)
|
||||
}
|
||||
if value, ok := atu.mutation.ExpiresAt(); ok {
|
||||
if value, ok := _u.mutation.ExpiresAt(); ok {
|
||||
_spec.SetField(authtokens.FieldExpiresAt, field.TypeTime, value)
|
||||
}
|
||||
if atu.mutation.UserCleared() {
|
||||
if _u.mutation.UserCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -179,7 +179,7 @@ func (atu *AuthTokensUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := atu.mutation.UserIDs(); len(nodes) > 0 {
|
||||
if nodes := _u.mutation.UserIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -195,7 +195,7 @@ func (atu *AuthTokensUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if atu.mutation.RolesCleared() {
|
||||
if _u.mutation.RolesCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2O,
|
||||
Inverse: false,
|
||||
@@ -208,7 +208,7 @@ func (atu *AuthTokensUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := atu.mutation.RolesIDs(); len(nodes) > 0 {
|
||||
if nodes := _u.mutation.RolesIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2O,
|
||||
Inverse: false,
|
||||
@@ -224,7 +224,7 @@ func (atu *AuthTokensUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, atu.driver, _spec); err != nil {
|
||||
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{authtokens.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
@@ -232,8 +232,8 @@ func (atu *AuthTokensUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
atu.mutation.done = true
|
||||
return n, nil
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
// AuthTokensUpdateOne is the builder for updating a single AuthTokens entity.
|
||||
@@ -245,108 +245,108 @@ type AuthTokensUpdateOne struct {
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (atuo *AuthTokensUpdateOne) SetUpdatedAt(t time.Time) *AuthTokensUpdateOne {
|
||||
atuo.mutation.SetUpdatedAt(t)
|
||||
return atuo
|
||||
func (_u *AuthTokensUpdateOne) SetUpdatedAt(v time.Time) *AuthTokensUpdateOne {
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetToken sets the "token" field.
|
||||
func (atuo *AuthTokensUpdateOne) SetToken(b []byte) *AuthTokensUpdateOne {
|
||||
atuo.mutation.SetToken(b)
|
||||
return atuo
|
||||
func (_u *AuthTokensUpdateOne) SetToken(v []byte) *AuthTokensUpdateOne {
|
||||
_u.mutation.SetToken(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetExpiresAt sets the "expires_at" field.
|
||||
func (atuo *AuthTokensUpdateOne) SetExpiresAt(t time.Time) *AuthTokensUpdateOne {
|
||||
atuo.mutation.SetExpiresAt(t)
|
||||
return atuo
|
||||
func (_u *AuthTokensUpdateOne) SetExpiresAt(v time.Time) *AuthTokensUpdateOne {
|
||||
_u.mutation.SetExpiresAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableExpiresAt sets the "expires_at" field if the given value is not nil.
|
||||
func (atuo *AuthTokensUpdateOne) SetNillableExpiresAt(t *time.Time) *AuthTokensUpdateOne {
|
||||
if t != nil {
|
||||
atuo.SetExpiresAt(*t)
|
||||
func (_u *AuthTokensUpdateOne) SetNillableExpiresAt(v *time.Time) *AuthTokensUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetExpiresAt(*v)
|
||||
}
|
||||
return atuo
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUserID sets the "user" edge to the User entity by ID.
|
||||
func (atuo *AuthTokensUpdateOne) SetUserID(id uuid.UUID) *AuthTokensUpdateOne {
|
||||
atuo.mutation.SetUserID(id)
|
||||
return atuo
|
||||
func (_u *AuthTokensUpdateOne) SetUserID(id uuid.UUID) *AuthTokensUpdateOne {
|
||||
_u.mutation.SetUserID(id)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableUserID sets the "user" edge to the User entity by ID if the given value is not nil.
|
||||
func (atuo *AuthTokensUpdateOne) SetNillableUserID(id *uuid.UUID) *AuthTokensUpdateOne {
|
||||
func (_u *AuthTokensUpdateOne) SetNillableUserID(id *uuid.UUID) *AuthTokensUpdateOne {
|
||||
if id != nil {
|
||||
atuo = atuo.SetUserID(*id)
|
||||
_u = _u.SetUserID(*id)
|
||||
}
|
||||
return atuo
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUser sets the "user" edge to the User entity.
|
||||
func (atuo *AuthTokensUpdateOne) SetUser(u *User) *AuthTokensUpdateOne {
|
||||
return atuo.SetUserID(u.ID)
|
||||
func (_u *AuthTokensUpdateOne) SetUser(v *User) *AuthTokensUpdateOne {
|
||||
return _u.SetUserID(v.ID)
|
||||
}
|
||||
|
||||
// SetRolesID sets the "roles" edge to the AuthRoles entity by ID.
|
||||
func (atuo *AuthTokensUpdateOne) SetRolesID(id int) *AuthTokensUpdateOne {
|
||||
atuo.mutation.SetRolesID(id)
|
||||
return atuo
|
||||
func (_u *AuthTokensUpdateOne) SetRolesID(id int) *AuthTokensUpdateOne {
|
||||
_u.mutation.SetRolesID(id)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableRolesID sets the "roles" edge to the AuthRoles entity by ID if the given value is not nil.
|
||||
func (atuo *AuthTokensUpdateOne) SetNillableRolesID(id *int) *AuthTokensUpdateOne {
|
||||
func (_u *AuthTokensUpdateOne) SetNillableRolesID(id *int) *AuthTokensUpdateOne {
|
||||
if id != nil {
|
||||
atuo = atuo.SetRolesID(*id)
|
||||
_u = _u.SetRolesID(*id)
|
||||
}
|
||||
return atuo
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetRoles sets the "roles" edge to the AuthRoles entity.
|
||||
func (atuo *AuthTokensUpdateOne) SetRoles(a *AuthRoles) *AuthTokensUpdateOne {
|
||||
return atuo.SetRolesID(a.ID)
|
||||
func (_u *AuthTokensUpdateOne) SetRoles(v *AuthRoles) *AuthTokensUpdateOne {
|
||||
return _u.SetRolesID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the AuthTokensMutation object of the builder.
|
||||
func (atuo *AuthTokensUpdateOne) Mutation() *AuthTokensMutation {
|
||||
return atuo.mutation
|
||||
func (_u *AuthTokensUpdateOne) Mutation() *AuthTokensMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// ClearUser clears the "user" edge to the User entity.
|
||||
func (atuo *AuthTokensUpdateOne) ClearUser() *AuthTokensUpdateOne {
|
||||
atuo.mutation.ClearUser()
|
||||
return atuo
|
||||
func (_u *AuthTokensUpdateOne) ClearUser() *AuthTokensUpdateOne {
|
||||
_u.mutation.ClearUser()
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearRoles clears the "roles" edge to the AuthRoles entity.
|
||||
func (atuo *AuthTokensUpdateOne) ClearRoles() *AuthTokensUpdateOne {
|
||||
atuo.mutation.ClearRoles()
|
||||
return atuo
|
||||
func (_u *AuthTokensUpdateOne) ClearRoles() *AuthTokensUpdateOne {
|
||||
_u.mutation.ClearRoles()
|
||||
return _u
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the AuthTokensUpdate builder.
|
||||
func (atuo *AuthTokensUpdateOne) Where(ps ...predicate.AuthTokens) *AuthTokensUpdateOne {
|
||||
atuo.mutation.Where(ps...)
|
||||
return atuo
|
||||
func (_u *AuthTokensUpdateOne) Where(ps ...predicate.AuthTokens) *AuthTokensUpdateOne {
|
||||
_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 (atuo *AuthTokensUpdateOne) Select(field string, fields ...string) *AuthTokensUpdateOne {
|
||||
atuo.fields = append([]string{field}, fields...)
|
||||
return atuo
|
||||
func (_u *AuthTokensUpdateOne) Select(field string, fields ...string) *AuthTokensUpdateOne {
|
||||
_u.fields = append([]string{field}, fields...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated AuthTokens entity.
|
||||
func (atuo *AuthTokensUpdateOne) Save(ctx context.Context) (*AuthTokens, error) {
|
||||
atuo.defaults()
|
||||
return withHooks(ctx, atuo.sqlSave, atuo.mutation, atuo.hooks)
|
||||
func (_u *AuthTokensUpdateOne) Save(ctx context.Context) (*AuthTokens, error) {
|
||||
_u.defaults()
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (atuo *AuthTokensUpdateOne) SaveX(ctx context.Context) *AuthTokens {
|
||||
node, err := atuo.Save(ctx)
|
||||
func (_u *AuthTokensUpdateOne) SaveX(ctx context.Context) *AuthTokens {
|
||||
node, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -354,34 +354,34 @@ func (atuo *AuthTokensUpdateOne) SaveX(ctx context.Context) *AuthTokens {
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (atuo *AuthTokensUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := atuo.Save(ctx)
|
||||
func (_u *AuthTokensUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (atuo *AuthTokensUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := atuo.Exec(ctx); err != nil {
|
||||
func (_u *AuthTokensUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := _u.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (atuo *AuthTokensUpdateOne) defaults() {
|
||||
if _, ok := atuo.mutation.UpdatedAt(); !ok {
|
||||
func (_u *AuthTokensUpdateOne) defaults() {
|
||||
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
||||
v := authtokens.UpdateDefaultUpdatedAt()
|
||||
atuo.mutation.SetUpdatedAt(v)
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
func (atuo *AuthTokensUpdateOne) sqlSave(ctx context.Context) (_node *AuthTokens, err error) {
|
||||
func (_u *AuthTokensUpdateOne) sqlSave(ctx context.Context) (_node *AuthTokens, err error) {
|
||||
_spec := sqlgraph.NewUpdateSpec(authtokens.Table, authtokens.Columns, sqlgraph.NewFieldSpec(authtokens.FieldID, field.TypeUUID))
|
||||
id, ok := atuo.mutation.ID()
|
||||
id, ok := _u.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "AuthTokens.id" for update`)}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
if fields := atuo.fields; len(fields) > 0 {
|
||||
if fields := _u.fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, authtokens.FieldID)
|
||||
for _, f := range fields {
|
||||
@@ -393,23 +393,23 @@ func (atuo *AuthTokensUpdateOne) sqlSave(ctx context.Context) (_node *AuthTokens
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := atuo.mutation.predicates; len(ps) > 0 {
|
||||
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := atuo.mutation.UpdatedAt(); ok {
|
||||
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(authtokens.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := atuo.mutation.Token(); ok {
|
||||
if value, ok := _u.mutation.Token(); ok {
|
||||
_spec.SetField(authtokens.FieldToken, field.TypeBytes, value)
|
||||
}
|
||||
if value, ok := atuo.mutation.ExpiresAt(); ok {
|
||||
if value, ok := _u.mutation.ExpiresAt(); ok {
|
||||
_spec.SetField(authtokens.FieldExpiresAt, field.TypeTime, value)
|
||||
}
|
||||
if atuo.mutation.UserCleared() {
|
||||
if _u.mutation.UserCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -422,7 +422,7 @@ func (atuo *AuthTokensUpdateOne) sqlSave(ctx context.Context) (_node *AuthTokens
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := atuo.mutation.UserIDs(); len(nodes) > 0 {
|
||||
if nodes := _u.mutation.UserIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -438,7 +438,7 @@ func (atuo *AuthTokensUpdateOne) sqlSave(ctx context.Context) (_node *AuthTokens
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if atuo.mutation.RolesCleared() {
|
||||
if _u.mutation.RolesCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2O,
|
||||
Inverse: false,
|
||||
@@ -451,7 +451,7 @@ func (atuo *AuthTokensUpdateOne) sqlSave(ctx context.Context) (_node *AuthTokens
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := atuo.mutation.RolesIDs(); len(nodes) > 0 {
|
||||
if nodes := _u.mutation.RolesIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2O,
|
||||
Inverse: false,
|
||||
@@ -467,10 +467,10 @@ func (atuo *AuthTokensUpdateOne) sqlSave(ctx context.Context) (_node *AuthTokens
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
_node = &AuthTokens{config: atuo.config}
|
||||
_node = &AuthTokens{config: _u.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
if err = sqlgraph.UpdateNode(ctx, atuo.driver, _spec); err != nil {
|
||||
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{authtokens.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
@@ -478,6 +478,6 @@ func (atuo *AuthTokensUpdateOne) sqlSave(ctx context.Context) (_node *AuthTokens
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
atuo.mutation.done = true
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
@@ -353,8 +353,8 @@ func (c *AttachmentClient) Update() *AttachmentUpdate {
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *AttachmentClient) UpdateOne(a *Attachment) *AttachmentUpdateOne {
|
||||
mutation := newAttachmentMutation(c.config, OpUpdateOne, withAttachment(a))
|
||||
func (c *AttachmentClient) UpdateOne(_m *Attachment) *AttachmentUpdateOne {
|
||||
mutation := newAttachmentMutation(c.config, OpUpdateOne, withAttachment(_m))
|
||||
return &AttachmentUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
@@ -371,8 +371,8 @@ func (c *AttachmentClient) Delete() *AttachmentDelete {
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *AttachmentClient) DeleteOne(a *Attachment) *AttachmentDeleteOne {
|
||||
return c.DeleteOneID(a.ID)
|
||||
func (c *AttachmentClient) DeleteOne(_m *Attachment) *AttachmentDeleteOne {
|
||||
return c.DeleteOneID(_m.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
@@ -407,32 +407,32 @@ func (c *AttachmentClient) GetX(ctx context.Context, id uuid.UUID) *Attachment {
|
||||
}
|
||||
|
||||
// QueryEntity queries the entity edge of a Attachment.
|
||||
func (c *AttachmentClient) QueryEntity(a *Attachment) *EntityQuery {
|
||||
func (c *AttachmentClient) QueryEntity(_m *Attachment) *EntityQuery {
|
||||
query := (&EntityClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := a.ID
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(attachment.Table, attachment.FieldID, id),
|
||||
sqlgraph.To(entity.Table, entity.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, attachment.EntityTable, attachment.EntityColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(a.driver.Dialect(), step)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryThumbnail queries the thumbnail edge of a Attachment.
|
||||
func (c *AttachmentClient) QueryThumbnail(a *Attachment) *AttachmentQuery {
|
||||
func (c *AttachmentClient) QueryThumbnail(_m *Attachment) *AttachmentQuery {
|
||||
query := (&AttachmentClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := a.ID
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(attachment.Table, attachment.FieldID, id),
|
||||
sqlgraph.To(attachment.Table, attachment.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2O, false, attachment.ThumbnailTable, attachment.ThumbnailColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(a.driver.Dialect(), step)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
@@ -518,8 +518,8 @@ func (c *AuthRolesClient) Update() *AuthRolesUpdate {
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *AuthRolesClient) UpdateOne(ar *AuthRoles) *AuthRolesUpdateOne {
|
||||
mutation := newAuthRolesMutation(c.config, OpUpdateOne, withAuthRoles(ar))
|
||||
func (c *AuthRolesClient) UpdateOne(_m *AuthRoles) *AuthRolesUpdateOne {
|
||||
mutation := newAuthRolesMutation(c.config, OpUpdateOne, withAuthRoles(_m))
|
||||
return &AuthRolesUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
@@ -536,8 +536,8 @@ func (c *AuthRolesClient) Delete() *AuthRolesDelete {
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *AuthRolesClient) DeleteOne(ar *AuthRoles) *AuthRolesDeleteOne {
|
||||
return c.DeleteOneID(ar.ID)
|
||||
func (c *AuthRolesClient) DeleteOne(_m *AuthRoles) *AuthRolesDeleteOne {
|
||||
return c.DeleteOneID(_m.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
@@ -572,16 +572,16 @@ func (c *AuthRolesClient) GetX(ctx context.Context, id int) *AuthRoles {
|
||||
}
|
||||
|
||||
// QueryToken queries the token edge of a AuthRoles.
|
||||
func (c *AuthRolesClient) QueryToken(ar *AuthRoles) *AuthTokensQuery {
|
||||
func (c *AuthRolesClient) QueryToken(_m *AuthRoles) *AuthTokensQuery {
|
||||
query := (&AuthTokensClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := ar.ID
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(authroles.Table, authroles.FieldID, id),
|
||||
sqlgraph.To(authtokens.Table, authtokens.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2O, true, authroles.TokenTable, authroles.TokenColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(ar.driver.Dialect(), step)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
@@ -667,8 +667,8 @@ func (c *AuthTokensClient) Update() *AuthTokensUpdate {
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *AuthTokensClient) UpdateOne(at *AuthTokens) *AuthTokensUpdateOne {
|
||||
mutation := newAuthTokensMutation(c.config, OpUpdateOne, withAuthTokens(at))
|
||||
func (c *AuthTokensClient) UpdateOne(_m *AuthTokens) *AuthTokensUpdateOne {
|
||||
mutation := newAuthTokensMutation(c.config, OpUpdateOne, withAuthTokens(_m))
|
||||
return &AuthTokensUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
@@ -685,8 +685,8 @@ func (c *AuthTokensClient) Delete() *AuthTokensDelete {
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *AuthTokensClient) DeleteOne(at *AuthTokens) *AuthTokensDeleteOne {
|
||||
return c.DeleteOneID(at.ID)
|
||||
func (c *AuthTokensClient) DeleteOne(_m *AuthTokens) *AuthTokensDeleteOne {
|
||||
return c.DeleteOneID(_m.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
@@ -721,32 +721,32 @@ func (c *AuthTokensClient) GetX(ctx context.Context, id uuid.UUID) *AuthTokens {
|
||||
}
|
||||
|
||||
// QueryUser queries the user edge of a AuthTokens.
|
||||
func (c *AuthTokensClient) QueryUser(at *AuthTokens) *UserQuery {
|
||||
func (c *AuthTokensClient) QueryUser(_m *AuthTokens) *UserQuery {
|
||||
query := (&UserClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := at.ID
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(authtokens.Table, authtokens.FieldID, id),
|
||||
sqlgraph.To(user.Table, user.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, authtokens.UserTable, authtokens.UserColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(at.driver.Dialect(), step)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryRoles queries the roles edge of a AuthTokens.
|
||||
func (c *AuthTokensClient) QueryRoles(at *AuthTokens) *AuthRolesQuery {
|
||||
func (c *AuthTokensClient) QueryRoles(_m *AuthTokens) *AuthRolesQuery {
|
||||
query := (&AuthRolesClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := at.ID
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(authtokens.Table, authtokens.FieldID, id),
|
||||
sqlgraph.To(authroles.Table, authroles.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2O, false, authtokens.RolesTable, authtokens.RolesColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(at.driver.Dialect(), step)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
@@ -832,8 +832,8 @@ func (c *EntityClient) Update() *EntityUpdate {
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *EntityClient) UpdateOne(e *Entity) *EntityUpdateOne {
|
||||
mutation := newEntityMutation(c.config, OpUpdateOne, withEntity(e))
|
||||
func (c *EntityClient) UpdateOne(_m *Entity) *EntityUpdateOne {
|
||||
mutation := newEntityMutation(c.config, OpUpdateOne, withEntity(_m))
|
||||
return &EntityUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
@@ -850,8 +850,8 @@ func (c *EntityClient) Delete() *EntityDelete {
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *EntityClient) DeleteOne(e *Entity) *EntityDeleteOne {
|
||||
return c.DeleteOneID(e.ID)
|
||||
func (c *EntityClient) DeleteOne(_m *Entity) *EntityDeleteOne {
|
||||
return c.DeleteOneID(_m.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
@@ -886,160 +886,160 @@ func (c *EntityClient) GetX(ctx context.Context, id uuid.UUID) *Entity {
|
||||
}
|
||||
|
||||
// QueryGroup queries the group edge of a Entity.
|
||||
func (c *EntityClient) QueryGroup(e *Entity) *GroupQuery {
|
||||
func (c *EntityClient) QueryGroup(_m *Entity) *GroupQuery {
|
||||
query := (&GroupClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := e.ID
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(entity.Table, entity.FieldID, id),
|
||||
sqlgraph.To(group.Table, group.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, entity.GroupTable, entity.GroupColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(e.driver.Dialect(), step)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryParent queries the parent edge of a Entity.
|
||||
func (c *EntityClient) QueryParent(e *Entity) *EntityQuery {
|
||||
func (c *EntityClient) QueryParent(_m *Entity) *EntityQuery {
|
||||
query := (&EntityClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := e.ID
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(entity.Table, entity.FieldID, id),
|
||||
sqlgraph.To(entity.Table, entity.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, entity.ParentTable, entity.ParentColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(e.driver.Dialect(), step)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryChildren queries the children edge of a Entity.
|
||||
func (c *EntityClient) QueryChildren(e *Entity) *EntityQuery {
|
||||
func (c *EntityClient) QueryChildren(_m *Entity) *EntityQuery {
|
||||
query := (&EntityClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := e.ID
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(entity.Table, entity.FieldID, id),
|
||||
sqlgraph.To(entity.Table, entity.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, entity.ChildrenTable, entity.ChildrenColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(e.driver.Dialect(), step)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryEntity queries the entity edge of a Entity.
|
||||
func (c *EntityClient) QueryEntity(e *Entity) *EntityQuery {
|
||||
func (c *EntityClient) QueryEntity(_m *Entity) *EntityQuery {
|
||||
query := (&EntityClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := e.ID
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(entity.Table, entity.FieldID, id),
|
||||
sqlgraph.To(entity.Table, entity.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2O, true, entity.EntityTable, entity.EntityColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(e.driver.Dialect(), step)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryLocation queries the location edge of a Entity.
|
||||
func (c *EntityClient) QueryLocation(e *Entity) *EntityQuery {
|
||||
func (c *EntityClient) QueryLocation(_m *Entity) *EntityQuery {
|
||||
query := (&EntityClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := e.ID
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(entity.Table, entity.FieldID, id),
|
||||
sqlgraph.To(entity.Table, entity.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2O, false, entity.LocationTable, entity.LocationColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(e.driver.Dialect(), step)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryLabel queries the label edge of a Entity.
|
||||
func (c *EntityClient) QueryLabel(e *Entity) *LabelQuery {
|
||||
func (c *EntityClient) QueryLabel(_m *Entity) *LabelQuery {
|
||||
query := (&LabelClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := e.ID
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(entity.Table, entity.FieldID, id),
|
||||
sqlgraph.To(label.Table, label.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2M, true, entity.LabelTable, entity.LabelPrimaryKey...),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(e.driver.Dialect(), step)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryType queries the type edge of a Entity.
|
||||
func (c *EntityClient) QueryType(e *Entity) *EntityTypeQuery {
|
||||
func (c *EntityClient) QueryType(_m *Entity) *EntityTypeQuery {
|
||||
query := (&EntityTypeClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := e.ID
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(entity.Table, entity.FieldID, id),
|
||||
sqlgraph.To(entitytype.Table, entitytype.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, entity.TypeTable, entity.TypeColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(e.driver.Dialect(), step)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryFields queries the fields edge of a Entity.
|
||||
func (c *EntityClient) QueryFields(e *Entity) *EntityFieldQuery {
|
||||
func (c *EntityClient) QueryFields(_m *Entity) *EntityFieldQuery {
|
||||
query := (&EntityFieldClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := e.ID
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(entity.Table, entity.FieldID, id),
|
||||
sqlgraph.To(entityfield.Table, entityfield.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, entity.FieldsTable, entity.FieldsColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(e.driver.Dialect(), step)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryMaintenanceEntries queries the maintenance_entries edge of a Entity.
|
||||
func (c *EntityClient) QueryMaintenanceEntries(e *Entity) *MaintenanceEntryQuery {
|
||||
func (c *EntityClient) QueryMaintenanceEntries(_m *Entity) *MaintenanceEntryQuery {
|
||||
query := (&MaintenanceEntryClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := e.ID
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(entity.Table, entity.FieldID, id),
|
||||
sqlgraph.To(maintenanceentry.Table, maintenanceentry.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, entity.MaintenanceEntriesTable, entity.MaintenanceEntriesColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(e.driver.Dialect(), step)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryAttachments queries the attachments edge of a Entity.
|
||||
func (c *EntityClient) QueryAttachments(e *Entity) *AttachmentQuery {
|
||||
func (c *EntityClient) QueryAttachments(_m *Entity) *AttachmentQuery {
|
||||
query := (&AttachmentClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := e.ID
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(entity.Table, entity.FieldID, id),
|
||||
sqlgraph.To(attachment.Table, attachment.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, entity.AttachmentsTable, entity.AttachmentsColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(e.driver.Dialect(), step)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
@@ -1125,8 +1125,8 @@ func (c *EntityFieldClient) Update() *EntityFieldUpdate {
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *EntityFieldClient) UpdateOne(ef *EntityField) *EntityFieldUpdateOne {
|
||||
mutation := newEntityFieldMutation(c.config, OpUpdateOne, withEntityField(ef))
|
||||
func (c *EntityFieldClient) UpdateOne(_m *EntityField) *EntityFieldUpdateOne {
|
||||
mutation := newEntityFieldMutation(c.config, OpUpdateOne, withEntityField(_m))
|
||||
return &EntityFieldUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
@@ -1143,8 +1143,8 @@ func (c *EntityFieldClient) Delete() *EntityFieldDelete {
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *EntityFieldClient) DeleteOne(ef *EntityField) *EntityFieldDeleteOne {
|
||||
return c.DeleteOneID(ef.ID)
|
||||
func (c *EntityFieldClient) DeleteOne(_m *EntityField) *EntityFieldDeleteOne {
|
||||
return c.DeleteOneID(_m.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
@@ -1179,16 +1179,16 @@ func (c *EntityFieldClient) GetX(ctx context.Context, id uuid.UUID) *EntityField
|
||||
}
|
||||
|
||||
// QueryEntity queries the entity edge of a EntityField.
|
||||
func (c *EntityFieldClient) QueryEntity(ef *EntityField) *EntityQuery {
|
||||
func (c *EntityFieldClient) QueryEntity(_m *EntityField) *EntityQuery {
|
||||
query := (&EntityClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := ef.ID
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(entityfield.Table, entityfield.FieldID, id),
|
||||
sqlgraph.To(entity.Table, entity.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, entityfield.EntityTable, entityfield.EntityColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(ef.driver.Dialect(), step)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
@@ -1274,8 +1274,8 @@ func (c *EntityTypeClient) Update() *EntityTypeUpdate {
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *EntityTypeClient) UpdateOne(et *EntityType) *EntityTypeUpdateOne {
|
||||
mutation := newEntityTypeMutation(c.config, OpUpdateOne, withEntityType(et))
|
||||
func (c *EntityTypeClient) UpdateOne(_m *EntityType) *EntityTypeUpdateOne {
|
||||
mutation := newEntityTypeMutation(c.config, OpUpdateOne, withEntityType(_m))
|
||||
return &EntityTypeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
@@ -1292,8 +1292,8 @@ func (c *EntityTypeClient) Delete() *EntityTypeDelete {
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *EntityTypeClient) DeleteOne(et *EntityType) *EntityTypeDeleteOne {
|
||||
return c.DeleteOneID(et.ID)
|
||||
func (c *EntityTypeClient) DeleteOne(_m *EntityType) *EntityTypeDeleteOne {
|
||||
return c.DeleteOneID(_m.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
@@ -1328,32 +1328,32 @@ func (c *EntityTypeClient) GetX(ctx context.Context, id uuid.UUID) *EntityType {
|
||||
}
|
||||
|
||||
// QueryGroup queries the group edge of a EntityType.
|
||||
func (c *EntityTypeClient) QueryGroup(et *EntityType) *GroupQuery {
|
||||
func (c *EntityTypeClient) QueryGroup(_m *EntityType) *GroupQuery {
|
||||
query := (&GroupClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := et.ID
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(entitytype.Table, entitytype.FieldID, id),
|
||||
sqlgraph.To(group.Table, group.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, entitytype.GroupTable, entitytype.GroupColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(et.driver.Dialect(), step)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryEntities queries the entities edge of a EntityType.
|
||||
func (c *EntityTypeClient) QueryEntities(et *EntityType) *EntityQuery {
|
||||
func (c *EntityTypeClient) QueryEntities(_m *EntityType) *EntityQuery {
|
||||
query := (&EntityClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := et.ID
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(entitytype.Table, entitytype.FieldID, id),
|
||||
sqlgraph.To(entity.Table, entity.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, entitytype.EntitiesTable, entitytype.EntitiesColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(et.driver.Dialect(), step)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
@@ -1439,8 +1439,8 @@ func (c *GroupClient) Update() *GroupUpdate {
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *GroupClient) UpdateOne(gr *Group) *GroupUpdateOne {
|
||||
mutation := newGroupMutation(c.config, OpUpdateOne, withGroup(gr))
|
||||
func (c *GroupClient) UpdateOne(_m *Group) *GroupUpdateOne {
|
||||
mutation := newGroupMutation(c.config, OpUpdateOne, withGroup(_m))
|
||||
return &GroupUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
@@ -1457,8 +1457,8 @@ func (c *GroupClient) Delete() *GroupDelete {
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *GroupClient) DeleteOne(gr *Group) *GroupDeleteOne {
|
||||
return c.DeleteOneID(gr.ID)
|
||||
func (c *GroupClient) DeleteOne(_m *Group) *GroupDeleteOne {
|
||||
return c.DeleteOneID(_m.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
@@ -1493,96 +1493,96 @@ func (c *GroupClient) GetX(ctx context.Context, id uuid.UUID) *Group {
|
||||
}
|
||||
|
||||
// QueryUsers queries the users edge of a Group.
|
||||
func (c *GroupClient) QueryUsers(gr *Group) *UserQuery {
|
||||
func (c *GroupClient) QueryUsers(_m *Group) *UserQuery {
|
||||
query := (&UserClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := gr.ID
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(group.Table, group.FieldID, id),
|
||||
sqlgraph.To(user.Table, user.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, group.UsersTable, group.UsersColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(gr.driver.Dialect(), step)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryEntities queries the entities edge of a Group.
|
||||
func (c *GroupClient) QueryEntities(gr *Group) *EntityQuery {
|
||||
func (c *GroupClient) QueryEntities(_m *Group) *EntityQuery {
|
||||
query := (&EntityClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := gr.ID
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(group.Table, group.FieldID, id),
|
||||
sqlgraph.To(entity.Table, entity.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, group.EntitiesTable, group.EntitiesColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(gr.driver.Dialect(), step)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryLabels queries the labels edge of a Group.
|
||||
func (c *GroupClient) QueryLabels(gr *Group) *LabelQuery {
|
||||
func (c *GroupClient) QueryLabels(_m *Group) *LabelQuery {
|
||||
query := (&LabelClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := gr.ID
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(group.Table, group.FieldID, id),
|
||||
sqlgraph.To(label.Table, label.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, group.LabelsTable, group.LabelsColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(gr.driver.Dialect(), step)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryInvitationTokens queries the invitation_tokens edge of a Group.
|
||||
func (c *GroupClient) QueryInvitationTokens(gr *Group) *GroupInvitationTokenQuery {
|
||||
func (c *GroupClient) QueryInvitationTokens(_m *Group) *GroupInvitationTokenQuery {
|
||||
query := (&GroupInvitationTokenClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := gr.ID
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(group.Table, group.FieldID, id),
|
||||
sqlgraph.To(groupinvitationtoken.Table, groupinvitationtoken.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, group.InvitationTokensTable, group.InvitationTokensColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(gr.driver.Dialect(), step)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryNotifiers queries the notifiers edge of a Group.
|
||||
func (c *GroupClient) QueryNotifiers(gr *Group) *NotifierQuery {
|
||||
func (c *GroupClient) QueryNotifiers(_m *Group) *NotifierQuery {
|
||||
query := (&NotifierClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := gr.ID
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(group.Table, group.FieldID, id),
|
||||
sqlgraph.To(notifier.Table, notifier.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, group.NotifiersTable, group.NotifiersColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(gr.driver.Dialect(), step)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryEntityTypes queries the entity_types edge of a Group.
|
||||
func (c *GroupClient) QueryEntityTypes(gr *Group) *EntityTypeQuery {
|
||||
func (c *GroupClient) QueryEntityTypes(_m *Group) *EntityTypeQuery {
|
||||
query := (&EntityTypeClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := gr.ID
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(group.Table, group.FieldID, id),
|
||||
sqlgraph.To(entitytype.Table, entitytype.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, group.EntityTypesTable, group.EntityTypesColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(gr.driver.Dialect(), step)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
@@ -1668,8 +1668,8 @@ func (c *GroupInvitationTokenClient) Update() *GroupInvitationTokenUpdate {
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *GroupInvitationTokenClient) UpdateOne(git *GroupInvitationToken) *GroupInvitationTokenUpdateOne {
|
||||
mutation := newGroupInvitationTokenMutation(c.config, OpUpdateOne, withGroupInvitationToken(git))
|
||||
func (c *GroupInvitationTokenClient) UpdateOne(_m *GroupInvitationToken) *GroupInvitationTokenUpdateOne {
|
||||
mutation := newGroupInvitationTokenMutation(c.config, OpUpdateOne, withGroupInvitationToken(_m))
|
||||
return &GroupInvitationTokenUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
@@ -1686,8 +1686,8 @@ func (c *GroupInvitationTokenClient) Delete() *GroupInvitationTokenDelete {
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *GroupInvitationTokenClient) DeleteOne(git *GroupInvitationToken) *GroupInvitationTokenDeleteOne {
|
||||
return c.DeleteOneID(git.ID)
|
||||
func (c *GroupInvitationTokenClient) DeleteOne(_m *GroupInvitationToken) *GroupInvitationTokenDeleteOne {
|
||||
return c.DeleteOneID(_m.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
@@ -1722,16 +1722,16 @@ func (c *GroupInvitationTokenClient) GetX(ctx context.Context, id uuid.UUID) *Gr
|
||||
}
|
||||
|
||||
// QueryGroup queries the group edge of a GroupInvitationToken.
|
||||
func (c *GroupInvitationTokenClient) QueryGroup(git *GroupInvitationToken) *GroupQuery {
|
||||
func (c *GroupInvitationTokenClient) QueryGroup(_m *GroupInvitationToken) *GroupQuery {
|
||||
query := (&GroupClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := git.ID
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(groupinvitationtoken.Table, groupinvitationtoken.FieldID, id),
|
||||
sqlgraph.To(group.Table, group.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, groupinvitationtoken.GroupTable, groupinvitationtoken.GroupColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(git.driver.Dialect(), step)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
@@ -1817,8 +1817,8 @@ func (c *LabelClient) Update() *LabelUpdate {
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *LabelClient) UpdateOne(l *Label) *LabelUpdateOne {
|
||||
mutation := newLabelMutation(c.config, OpUpdateOne, withLabel(l))
|
||||
func (c *LabelClient) UpdateOne(_m *Label) *LabelUpdateOne {
|
||||
mutation := newLabelMutation(c.config, OpUpdateOne, withLabel(_m))
|
||||
return &LabelUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
@@ -1835,8 +1835,8 @@ func (c *LabelClient) Delete() *LabelDelete {
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *LabelClient) DeleteOne(l *Label) *LabelDeleteOne {
|
||||
return c.DeleteOneID(l.ID)
|
||||
func (c *LabelClient) DeleteOne(_m *Label) *LabelDeleteOne {
|
||||
return c.DeleteOneID(_m.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
@@ -1871,32 +1871,32 @@ func (c *LabelClient) GetX(ctx context.Context, id uuid.UUID) *Label {
|
||||
}
|
||||
|
||||
// QueryGroup queries the group edge of a Label.
|
||||
func (c *LabelClient) QueryGroup(l *Label) *GroupQuery {
|
||||
func (c *LabelClient) QueryGroup(_m *Label) *GroupQuery {
|
||||
query := (&GroupClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := l.ID
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(label.Table, label.FieldID, id),
|
||||
sqlgraph.To(group.Table, group.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, label.GroupTable, label.GroupColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(l.driver.Dialect(), step)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryEntities queries the entities edge of a Label.
|
||||
func (c *LabelClient) QueryEntities(l *Label) *EntityQuery {
|
||||
func (c *LabelClient) QueryEntities(_m *Label) *EntityQuery {
|
||||
query := (&EntityClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := l.ID
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(label.Table, label.FieldID, id),
|
||||
sqlgraph.To(entity.Table, entity.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2M, false, label.EntitiesTable, label.EntitiesPrimaryKey...),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(l.driver.Dialect(), step)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
@@ -1982,8 +1982,8 @@ func (c *MaintenanceEntryClient) Update() *MaintenanceEntryUpdate {
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *MaintenanceEntryClient) UpdateOne(me *MaintenanceEntry) *MaintenanceEntryUpdateOne {
|
||||
mutation := newMaintenanceEntryMutation(c.config, OpUpdateOne, withMaintenanceEntry(me))
|
||||
func (c *MaintenanceEntryClient) UpdateOne(_m *MaintenanceEntry) *MaintenanceEntryUpdateOne {
|
||||
mutation := newMaintenanceEntryMutation(c.config, OpUpdateOne, withMaintenanceEntry(_m))
|
||||
return &MaintenanceEntryUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
@@ -2000,8 +2000,8 @@ func (c *MaintenanceEntryClient) Delete() *MaintenanceEntryDelete {
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *MaintenanceEntryClient) DeleteOne(me *MaintenanceEntry) *MaintenanceEntryDeleteOne {
|
||||
return c.DeleteOneID(me.ID)
|
||||
func (c *MaintenanceEntryClient) DeleteOne(_m *MaintenanceEntry) *MaintenanceEntryDeleteOne {
|
||||
return c.DeleteOneID(_m.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
@@ -2036,16 +2036,16 @@ func (c *MaintenanceEntryClient) GetX(ctx context.Context, id uuid.UUID) *Mainte
|
||||
}
|
||||
|
||||
// QueryEntity queries the entity edge of a MaintenanceEntry.
|
||||
func (c *MaintenanceEntryClient) QueryEntity(me *MaintenanceEntry) *EntityQuery {
|
||||
func (c *MaintenanceEntryClient) QueryEntity(_m *MaintenanceEntry) *EntityQuery {
|
||||
query := (&EntityClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := me.ID
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(maintenanceentry.Table, maintenanceentry.FieldID, id),
|
||||
sqlgraph.To(entity.Table, entity.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, maintenanceentry.EntityTable, maintenanceentry.EntityColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(me.driver.Dialect(), step)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
@@ -2131,8 +2131,8 @@ func (c *NotifierClient) Update() *NotifierUpdate {
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *NotifierClient) UpdateOne(n *Notifier) *NotifierUpdateOne {
|
||||
mutation := newNotifierMutation(c.config, OpUpdateOne, withNotifier(n))
|
||||
func (c *NotifierClient) UpdateOne(_m *Notifier) *NotifierUpdateOne {
|
||||
mutation := newNotifierMutation(c.config, OpUpdateOne, withNotifier(_m))
|
||||
return &NotifierUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
@@ -2149,8 +2149,8 @@ func (c *NotifierClient) Delete() *NotifierDelete {
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *NotifierClient) DeleteOne(n *Notifier) *NotifierDeleteOne {
|
||||
return c.DeleteOneID(n.ID)
|
||||
func (c *NotifierClient) DeleteOne(_m *Notifier) *NotifierDeleteOne {
|
||||
return c.DeleteOneID(_m.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
@@ -2185,32 +2185,32 @@ func (c *NotifierClient) GetX(ctx context.Context, id uuid.UUID) *Notifier {
|
||||
}
|
||||
|
||||
// QueryGroup queries the group edge of a Notifier.
|
||||
func (c *NotifierClient) QueryGroup(n *Notifier) *GroupQuery {
|
||||
func (c *NotifierClient) QueryGroup(_m *Notifier) *GroupQuery {
|
||||
query := (&GroupClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := n.ID
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(notifier.Table, notifier.FieldID, id),
|
||||
sqlgraph.To(group.Table, group.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, notifier.GroupTable, notifier.GroupColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(n.driver.Dialect(), step)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryUser queries the user edge of a Notifier.
|
||||
func (c *NotifierClient) QueryUser(n *Notifier) *UserQuery {
|
||||
func (c *NotifierClient) QueryUser(_m *Notifier) *UserQuery {
|
||||
query := (&UserClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := n.ID
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(notifier.Table, notifier.FieldID, id),
|
||||
sqlgraph.To(user.Table, user.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, notifier.UserTable, notifier.UserColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(n.driver.Dialect(), step)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
@@ -2296,8 +2296,8 @@ func (c *UserClient) Update() *UserUpdate {
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *UserClient) UpdateOne(u *User) *UserUpdateOne {
|
||||
mutation := newUserMutation(c.config, OpUpdateOne, withUser(u))
|
||||
func (c *UserClient) UpdateOne(_m *User) *UserUpdateOne {
|
||||
mutation := newUserMutation(c.config, OpUpdateOne, withUser(_m))
|
||||
return &UserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
@@ -2314,8 +2314,8 @@ func (c *UserClient) Delete() *UserDelete {
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *UserClient) DeleteOne(u *User) *UserDeleteOne {
|
||||
return c.DeleteOneID(u.ID)
|
||||
func (c *UserClient) DeleteOne(_m *User) *UserDeleteOne {
|
||||
return c.DeleteOneID(_m.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
@@ -2350,48 +2350,48 @@ func (c *UserClient) GetX(ctx context.Context, id uuid.UUID) *User {
|
||||
}
|
||||
|
||||
// QueryGroup queries the group edge of a User.
|
||||
func (c *UserClient) QueryGroup(u *User) *GroupQuery {
|
||||
func (c *UserClient) QueryGroup(_m *User) *GroupQuery {
|
||||
query := (&GroupClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := u.ID
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(user.Table, user.FieldID, id),
|
||||
sqlgraph.To(group.Table, group.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, user.GroupTable, user.GroupColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(u.driver.Dialect(), step)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryAuthTokens queries the auth_tokens edge of a User.
|
||||
func (c *UserClient) QueryAuthTokens(u *User) *AuthTokensQuery {
|
||||
func (c *UserClient) QueryAuthTokens(_m *User) *AuthTokensQuery {
|
||||
query := (&AuthTokensClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := u.ID
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(user.Table, user.FieldID, id),
|
||||
sqlgraph.To(authtokens.Table, authtokens.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, user.AuthTokensTable, user.AuthTokensColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(u.driver.Dialect(), step)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryNotifiers queries the notifiers edge of a User.
|
||||
func (c *UserClient) QueryNotifiers(u *User) *NotifierQuery {
|
||||
func (c *UserClient) QueryNotifiers(_m *User) *NotifierQuery {
|
||||
query := (&NotifierClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := u.ID
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(user.Table, user.FieldID, id),
|
||||
sqlgraph.To(notifier.Table, notifier.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, user.NotifiersTable, user.NotifiersColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(u.driver.Dialect(), step)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
|
||||
@@ -81,7 +81,7 @@ var (
|
||||
)
|
||||
|
||||
// checkColumn checks if the column exists in the given table.
|
||||
func checkColumn(table, column string) error {
|
||||
func checkColumn(t, c string) error {
|
||||
initCheck.Do(func() {
|
||||
columnCheck = sql.NewColumnCheck(map[string]func(string) bool{
|
||||
attachment.Table: attachment.ValidColumn,
|
||||
@@ -98,7 +98,7 @@ func checkColumn(table, column string) error {
|
||||
user.Table: user.ValidColumn,
|
||||
})
|
||||
})
|
||||
return columnCheck(table, column)
|
||||
return columnCheck(t, c)
|
||||
}
|
||||
|
||||
// Asc applies the given fields in ASC order.
|
||||
|
||||
@@ -239,7 +239,7 @@ func (*Entity) scanValues(columns []string) ([]any, error) {
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the Entity fields.
|
||||
func (e *Entity) assignValues(columns []string, values []any) error {
|
||||
func (_m *Entity) assignValues(columns []string, values []any) error {
|
||||
if m, n := len(values), len(columns); m < n {
|
||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||
}
|
||||
@@ -249,182 +249,182 @@ func (e *Entity) assignValues(columns []string, values []any) error {
|
||||
if value, ok := values[i].(*uuid.UUID); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", values[i])
|
||||
} else if value != nil {
|
||||
e.ID = *value
|
||||
_m.ID = *value
|
||||
}
|
||||
case entity.FieldCreatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
||||
} else if value.Valid {
|
||||
e.CreatedAt = value.Time
|
||||
_m.CreatedAt = value.Time
|
||||
}
|
||||
case entity.FieldUpdatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
|
||||
} else if value.Valid {
|
||||
e.UpdatedAt = value.Time
|
||||
_m.UpdatedAt = value.Time
|
||||
}
|
||||
case entity.FieldName:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field name", values[i])
|
||||
} else if value.Valid {
|
||||
e.Name = value.String
|
||||
_m.Name = value.String
|
||||
}
|
||||
case entity.FieldDescription:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field description", values[i])
|
||||
} else if value.Valid {
|
||||
e.Description = value.String
|
||||
_m.Description = value.String
|
||||
}
|
||||
case entity.FieldImportRef:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field import_ref", values[i])
|
||||
} else if value.Valid {
|
||||
e.ImportRef = value.String
|
||||
_m.ImportRef = value.String
|
||||
}
|
||||
case entity.FieldNotes:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field notes", values[i])
|
||||
} else if value.Valid {
|
||||
e.Notes = value.String
|
||||
_m.Notes = value.String
|
||||
}
|
||||
case entity.FieldQuantity:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field quantity", values[i])
|
||||
} else if value.Valid {
|
||||
e.Quantity = int(value.Int64)
|
||||
_m.Quantity = int(value.Int64)
|
||||
}
|
||||
case entity.FieldInsured:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field insured", values[i])
|
||||
} else if value.Valid {
|
||||
e.Insured = value.Bool
|
||||
_m.Insured = value.Bool
|
||||
}
|
||||
case entity.FieldArchived:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field archived", values[i])
|
||||
} else if value.Valid {
|
||||
e.Archived = value.Bool
|
||||
_m.Archived = value.Bool
|
||||
}
|
||||
case entity.FieldAssetID:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field asset_id", values[i])
|
||||
} else if value.Valid {
|
||||
e.AssetID = int(value.Int64)
|
||||
_m.AssetID = int(value.Int64)
|
||||
}
|
||||
case entity.FieldSyncChildEntitiesLocations:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field sync_child_entities_locations", values[i])
|
||||
} else if value.Valid {
|
||||
e.SyncChildEntitiesLocations = value.Bool
|
||||
_m.SyncChildEntitiesLocations = value.Bool
|
||||
}
|
||||
case entity.FieldSerialNumber:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field serial_number", values[i])
|
||||
} else if value.Valid {
|
||||
e.SerialNumber = value.String
|
||||
_m.SerialNumber = value.String
|
||||
}
|
||||
case entity.FieldModelNumber:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field model_number", values[i])
|
||||
} else if value.Valid {
|
||||
e.ModelNumber = value.String
|
||||
_m.ModelNumber = value.String
|
||||
}
|
||||
case entity.FieldManufacturer:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field manufacturer", values[i])
|
||||
} else if value.Valid {
|
||||
e.Manufacturer = value.String
|
||||
_m.Manufacturer = value.String
|
||||
}
|
||||
case entity.FieldLifetimeWarranty:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field lifetime_warranty", values[i])
|
||||
} else if value.Valid {
|
||||
e.LifetimeWarranty = value.Bool
|
||||
_m.LifetimeWarranty = value.Bool
|
||||
}
|
||||
case entity.FieldWarrantyExpires:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field warranty_expires", values[i])
|
||||
} else if value.Valid {
|
||||
e.WarrantyExpires = value.Time
|
||||
_m.WarrantyExpires = value.Time
|
||||
}
|
||||
case entity.FieldWarrantyDetails:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field warranty_details", values[i])
|
||||
} else if value.Valid {
|
||||
e.WarrantyDetails = value.String
|
||||
_m.WarrantyDetails = value.String
|
||||
}
|
||||
case entity.FieldPurchaseTime:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field purchase_time", values[i])
|
||||
} else if value.Valid {
|
||||
e.PurchaseTime = value.Time
|
||||
_m.PurchaseTime = value.Time
|
||||
}
|
||||
case entity.FieldPurchaseFrom:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field purchase_from", values[i])
|
||||
} else if value.Valid {
|
||||
e.PurchaseFrom = value.String
|
||||
_m.PurchaseFrom = value.String
|
||||
}
|
||||
case entity.FieldPurchasePrice:
|
||||
if value, ok := values[i].(*sql.NullFloat64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field purchase_price", values[i])
|
||||
} else if value.Valid {
|
||||
e.PurchasePrice = value.Float64
|
||||
_m.PurchasePrice = value.Float64
|
||||
}
|
||||
case entity.FieldSoldTime:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field sold_time", values[i])
|
||||
} else if value.Valid {
|
||||
e.SoldTime = value.Time
|
||||
_m.SoldTime = value.Time
|
||||
}
|
||||
case entity.FieldSoldTo:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field sold_to", values[i])
|
||||
} else if value.Valid {
|
||||
e.SoldTo = value.String
|
||||
_m.SoldTo = value.String
|
||||
}
|
||||
case entity.FieldSoldPrice:
|
||||
if value, ok := values[i].(*sql.NullFloat64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field sold_price", values[i])
|
||||
} else if value.Valid {
|
||||
e.SoldPrice = value.Float64
|
||||
_m.SoldPrice = value.Float64
|
||||
}
|
||||
case entity.FieldSoldNotes:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field sold_notes", values[i])
|
||||
} else if value.Valid {
|
||||
e.SoldNotes = value.String
|
||||
_m.SoldNotes = value.String
|
||||
}
|
||||
case entity.ForeignKeys[0]:
|
||||
if value, ok := values[i].(*sql.NullScanner); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field entity_children", values[i])
|
||||
} else if value.Valid {
|
||||
e.entity_children = new(uuid.UUID)
|
||||
*e.entity_children = *value.S.(*uuid.UUID)
|
||||
_m.entity_children = new(uuid.UUID)
|
||||
*_m.entity_children = *value.S.(*uuid.UUID)
|
||||
}
|
||||
case entity.ForeignKeys[1]:
|
||||
if value, ok := values[i].(*sql.NullScanner); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field entity_location", values[i])
|
||||
} else if value.Valid {
|
||||
e.entity_location = new(uuid.UUID)
|
||||
*e.entity_location = *value.S.(*uuid.UUID)
|
||||
_m.entity_location = new(uuid.UUID)
|
||||
*_m.entity_location = *value.S.(*uuid.UUID)
|
||||
}
|
||||
case entity.ForeignKeys[2]:
|
||||
if value, ok := values[i].(*sql.NullScanner); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field entity_type_entities", values[i])
|
||||
} else if value.Valid {
|
||||
e.entity_type_entities = new(uuid.UUID)
|
||||
*e.entity_type_entities = *value.S.(*uuid.UUID)
|
||||
_m.entity_type_entities = new(uuid.UUID)
|
||||
*_m.entity_type_entities = *value.S.(*uuid.UUID)
|
||||
}
|
||||
case entity.ForeignKeys[3]:
|
||||
if value, ok := values[i].(*sql.NullScanner); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field group_entities", values[i])
|
||||
} else if value.Valid {
|
||||
e.group_entities = new(uuid.UUID)
|
||||
*e.group_entities = *value.S.(*uuid.UUID)
|
||||
_m.group_entities = new(uuid.UUID)
|
||||
*_m.group_entities = *value.S.(*uuid.UUID)
|
||||
}
|
||||
default:
|
||||
e.selectValues.Set(columns[i], values[i])
|
||||
_m.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -432,154 +432,154 @@ func (e *Entity) assignValues(columns []string, values []any) error {
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the Entity.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (e *Entity) Value(name string) (ent.Value, error) {
|
||||
return e.selectValues.Get(name)
|
||||
func (_m *Entity) Value(name string) (ent.Value, error) {
|
||||
return _m.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// QueryGroup queries the "group" edge of the Entity entity.
|
||||
func (e *Entity) QueryGroup() *GroupQuery {
|
||||
return NewEntityClient(e.config).QueryGroup(e)
|
||||
func (_m *Entity) QueryGroup() *GroupQuery {
|
||||
return NewEntityClient(_m.config).QueryGroup(_m)
|
||||
}
|
||||
|
||||
// QueryParent queries the "parent" edge of the Entity entity.
|
||||
func (e *Entity) QueryParent() *EntityQuery {
|
||||
return NewEntityClient(e.config).QueryParent(e)
|
||||
func (_m *Entity) QueryParent() *EntityQuery {
|
||||
return NewEntityClient(_m.config).QueryParent(_m)
|
||||
}
|
||||
|
||||
// QueryChildren queries the "children" edge of the Entity entity.
|
||||
func (e *Entity) QueryChildren() *EntityQuery {
|
||||
return NewEntityClient(e.config).QueryChildren(e)
|
||||
func (_m *Entity) QueryChildren() *EntityQuery {
|
||||
return NewEntityClient(_m.config).QueryChildren(_m)
|
||||
}
|
||||
|
||||
// QueryEntity queries the "entity" edge of the Entity entity.
|
||||
func (e *Entity) QueryEntity() *EntityQuery {
|
||||
return NewEntityClient(e.config).QueryEntity(e)
|
||||
func (_m *Entity) QueryEntity() *EntityQuery {
|
||||
return NewEntityClient(_m.config).QueryEntity(_m)
|
||||
}
|
||||
|
||||
// QueryLocation queries the "location" edge of the Entity entity.
|
||||
func (e *Entity) QueryLocation() *EntityQuery {
|
||||
return NewEntityClient(e.config).QueryLocation(e)
|
||||
func (_m *Entity) QueryLocation() *EntityQuery {
|
||||
return NewEntityClient(_m.config).QueryLocation(_m)
|
||||
}
|
||||
|
||||
// QueryLabel queries the "label" edge of the Entity entity.
|
||||
func (e *Entity) QueryLabel() *LabelQuery {
|
||||
return NewEntityClient(e.config).QueryLabel(e)
|
||||
func (_m *Entity) QueryLabel() *LabelQuery {
|
||||
return NewEntityClient(_m.config).QueryLabel(_m)
|
||||
}
|
||||
|
||||
// QueryType queries the "type" edge of the Entity entity.
|
||||
func (e *Entity) QueryType() *EntityTypeQuery {
|
||||
return NewEntityClient(e.config).QueryType(e)
|
||||
func (_m *Entity) QueryType() *EntityTypeQuery {
|
||||
return NewEntityClient(_m.config).QueryType(_m)
|
||||
}
|
||||
|
||||
// QueryFields queries the "fields" edge of the Entity entity.
|
||||
func (e *Entity) QueryFields() *EntityFieldQuery {
|
||||
return NewEntityClient(e.config).QueryFields(e)
|
||||
func (_m *Entity) QueryFields() *EntityFieldQuery {
|
||||
return NewEntityClient(_m.config).QueryFields(_m)
|
||||
}
|
||||
|
||||
// QueryMaintenanceEntries queries the "maintenance_entries" edge of the Entity entity.
|
||||
func (e *Entity) QueryMaintenanceEntries() *MaintenanceEntryQuery {
|
||||
return NewEntityClient(e.config).QueryMaintenanceEntries(e)
|
||||
func (_m *Entity) QueryMaintenanceEntries() *MaintenanceEntryQuery {
|
||||
return NewEntityClient(_m.config).QueryMaintenanceEntries(_m)
|
||||
}
|
||||
|
||||
// QueryAttachments queries the "attachments" edge of the Entity entity.
|
||||
func (e *Entity) QueryAttachments() *AttachmentQuery {
|
||||
return NewEntityClient(e.config).QueryAttachments(e)
|
||||
func (_m *Entity) QueryAttachments() *AttachmentQuery {
|
||||
return NewEntityClient(_m.config).QueryAttachments(_m)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this Entity.
|
||||
// Note that you need to call Entity.Unwrap() before calling this method if this Entity
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (e *Entity) Update() *EntityUpdateOne {
|
||||
return NewEntityClient(e.config).UpdateOne(e)
|
||||
func (_m *Entity) Update() *EntityUpdateOne {
|
||||
return NewEntityClient(_m.config).UpdateOne(_m)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the Entity entity that was returned from a transaction after it was closed,
|
||||
// so that all future queries will be executed through the driver which created the transaction.
|
||||
func (e *Entity) Unwrap() *Entity {
|
||||
_tx, ok := e.config.driver.(*txDriver)
|
||||
func (_m *Entity) Unwrap() *Entity {
|
||||
_tx, ok := _m.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: Entity is not a transactional entity")
|
||||
}
|
||||
e.config.driver = _tx.drv
|
||||
return e
|
||||
_m.config.driver = _tx.drv
|
||||
return _m
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (e *Entity) String() string {
|
||||
func (_m *Entity) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("Entity(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", e.ID))
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||||
builder.WriteString("created_at=")
|
||||
builder.WriteString(e.CreatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("updated_at=")
|
||||
builder.WriteString(e.UpdatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("name=")
|
||||
builder.WriteString(e.Name)
|
||||
builder.WriteString(_m.Name)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("description=")
|
||||
builder.WriteString(e.Description)
|
||||
builder.WriteString(_m.Description)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("import_ref=")
|
||||
builder.WriteString(e.ImportRef)
|
||||
builder.WriteString(_m.ImportRef)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("notes=")
|
||||
builder.WriteString(e.Notes)
|
||||
builder.WriteString(_m.Notes)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("quantity=")
|
||||
builder.WriteString(fmt.Sprintf("%v", e.Quantity))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Quantity))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("insured=")
|
||||
builder.WriteString(fmt.Sprintf("%v", e.Insured))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Insured))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("archived=")
|
||||
builder.WriteString(fmt.Sprintf("%v", e.Archived))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Archived))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("asset_id=")
|
||||
builder.WriteString(fmt.Sprintf("%v", e.AssetID))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.AssetID))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("sync_child_entities_locations=")
|
||||
builder.WriteString(fmt.Sprintf("%v", e.SyncChildEntitiesLocations))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.SyncChildEntitiesLocations))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("serial_number=")
|
||||
builder.WriteString(e.SerialNumber)
|
||||
builder.WriteString(_m.SerialNumber)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("model_number=")
|
||||
builder.WriteString(e.ModelNumber)
|
||||
builder.WriteString(_m.ModelNumber)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("manufacturer=")
|
||||
builder.WriteString(e.Manufacturer)
|
||||
builder.WriteString(_m.Manufacturer)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("lifetime_warranty=")
|
||||
builder.WriteString(fmt.Sprintf("%v", e.LifetimeWarranty))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.LifetimeWarranty))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("warranty_expires=")
|
||||
builder.WriteString(e.WarrantyExpires.Format(time.ANSIC))
|
||||
builder.WriteString(_m.WarrantyExpires.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("warranty_details=")
|
||||
builder.WriteString(e.WarrantyDetails)
|
||||
builder.WriteString(_m.WarrantyDetails)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("purchase_time=")
|
||||
builder.WriteString(e.PurchaseTime.Format(time.ANSIC))
|
||||
builder.WriteString(_m.PurchaseTime.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("purchase_from=")
|
||||
builder.WriteString(e.PurchaseFrom)
|
||||
builder.WriteString(_m.PurchaseFrom)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("purchase_price=")
|
||||
builder.WriteString(fmt.Sprintf("%v", e.PurchasePrice))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.PurchasePrice))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("sold_time=")
|
||||
builder.WriteString(e.SoldTime.Format(time.ANSIC))
|
||||
builder.WriteString(_m.SoldTime.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("sold_to=")
|
||||
builder.WriteString(e.SoldTo)
|
||||
builder.WriteString(_m.SoldTo)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("sold_price=")
|
||||
builder.WriteString(fmt.Sprintf("%v", e.SoldPrice))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.SoldPrice))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("sold_notes=")
|
||||
builder.WriteString(e.SoldNotes)
|
||||
builder.WriteString(_m.SoldNotes)
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -20,56 +20,56 @@ type EntityDelete struct {
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the EntityDelete builder.
|
||||
func (ed *EntityDelete) Where(ps ...predicate.Entity) *EntityDelete {
|
||||
ed.mutation.Where(ps...)
|
||||
return ed
|
||||
func (_d *EntityDelete) Where(ps ...predicate.Entity) *EntityDelete {
|
||||
_d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (ed *EntityDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, ed.sqlExec, ed.mutation, ed.hooks)
|
||||
func (_d *EntityDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (ed *EntityDelete) ExecX(ctx context.Context) int {
|
||||
n, err := ed.Exec(ctx)
|
||||
func (_d *EntityDelete) ExecX(ctx context.Context) int {
|
||||
n, err := _d.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (ed *EntityDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
func (_d *EntityDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := sqlgraph.NewDeleteSpec(entity.Table, sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID))
|
||||
if ps := ed.mutation.predicates; len(ps) > 0 {
|
||||
if ps := _d.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, ed.driver, _spec)
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec)
|
||||
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
ed.mutation.done = true
|
||||
_d.mutation.done = true
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// EntityDeleteOne is the builder for deleting a single Entity entity.
|
||||
type EntityDeleteOne struct {
|
||||
ed *EntityDelete
|
||||
_d *EntityDelete
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the EntityDelete builder.
|
||||
func (edo *EntityDeleteOne) Where(ps ...predicate.Entity) *EntityDeleteOne {
|
||||
edo.ed.mutation.Where(ps...)
|
||||
return edo
|
||||
func (_d *EntityDeleteOne) Where(ps ...predicate.Entity) *EntityDeleteOne {
|
||||
_d._d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (edo *EntityDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := edo.ed.Exec(ctx)
|
||||
func (_d *EntityDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := _d._d.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
@@ -81,8 +81,8 @@ func (edo *EntityDeleteOne) Exec(ctx context.Context) error {
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (edo *EntityDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := edo.Exec(ctx); err != nil {
|
||||
func (_d *EntityDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := _d.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -90,7 +90,7 @@ func (*EntityField) scanValues(columns []string) ([]any, error) {
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the EntityField fields.
|
||||
func (ef *EntityField) assignValues(columns []string, values []any) error {
|
||||
func (_m *EntityField) assignValues(columns []string, values []any) error {
|
||||
if m, n := len(values), len(columns); m < n {
|
||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||
}
|
||||
@@ -100,71 +100,71 @@ func (ef *EntityField) assignValues(columns []string, values []any) error {
|
||||
if value, ok := values[i].(*uuid.UUID); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", values[i])
|
||||
} else if value != nil {
|
||||
ef.ID = *value
|
||||
_m.ID = *value
|
||||
}
|
||||
case entityfield.FieldCreatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
||||
} else if value.Valid {
|
||||
ef.CreatedAt = value.Time
|
||||
_m.CreatedAt = value.Time
|
||||
}
|
||||
case entityfield.FieldUpdatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
|
||||
} else if value.Valid {
|
||||
ef.UpdatedAt = value.Time
|
||||
_m.UpdatedAt = value.Time
|
||||
}
|
||||
case entityfield.FieldName:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field name", values[i])
|
||||
} else if value.Valid {
|
||||
ef.Name = value.String
|
||||
_m.Name = value.String
|
||||
}
|
||||
case entityfield.FieldDescription:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field description", values[i])
|
||||
} else if value.Valid {
|
||||
ef.Description = value.String
|
||||
_m.Description = value.String
|
||||
}
|
||||
case entityfield.FieldType:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field type", values[i])
|
||||
} else if value.Valid {
|
||||
ef.Type = entityfield.Type(value.String)
|
||||
_m.Type = entityfield.Type(value.String)
|
||||
}
|
||||
case entityfield.FieldTextValue:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field text_value", values[i])
|
||||
} else if value.Valid {
|
||||
ef.TextValue = value.String
|
||||
_m.TextValue = value.String
|
||||
}
|
||||
case entityfield.FieldNumberValue:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field number_value", values[i])
|
||||
} else if value.Valid {
|
||||
ef.NumberValue = int(value.Int64)
|
||||
_m.NumberValue = int(value.Int64)
|
||||
}
|
||||
case entityfield.FieldBooleanValue:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field boolean_value", values[i])
|
||||
} else if value.Valid {
|
||||
ef.BooleanValue = value.Bool
|
||||
_m.BooleanValue = value.Bool
|
||||
}
|
||||
case entityfield.FieldTimeValue:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field time_value", values[i])
|
||||
} else if value.Valid {
|
||||
ef.TimeValue = value.Time
|
||||
_m.TimeValue = value.Time
|
||||
}
|
||||
case entityfield.ForeignKeys[0]:
|
||||
if value, ok := values[i].(*sql.NullScanner); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field entity_fields", values[i])
|
||||
} else if value.Valid {
|
||||
ef.entity_fields = new(uuid.UUID)
|
||||
*ef.entity_fields = *value.S.(*uuid.UUID)
|
||||
_m.entity_fields = new(uuid.UUID)
|
||||
*_m.entity_fields = *value.S.(*uuid.UUID)
|
||||
}
|
||||
default:
|
||||
ef.selectValues.Set(columns[i], values[i])
|
||||
_m.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -172,64 +172,64 @@ func (ef *EntityField) assignValues(columns []string, values []any) error {
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the EntityField.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (ef *EntityField) Value(name string) (ent.Value, error) {
|
||||
return ef.selectValues.Get(name)
|
||||
func (_m *EntityField) Value(name string) (ent.Value, error) {
|
||||
return _m.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// QueryEntity queries the "entity" edge of the EntityField entity.
|
||||
func (ef *EntityField) QueryEntity() *EntityQuery {
|
||||
return NewEntityFieldClient(ef.config).QueryEntity(ef)
|
||||
func (_m *EntityField) QueryEntity() *EntityQuery {
|
||||
return NewEntityFieldClient(_m.config).QueryEntity(_m)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this EntityField.
|
||||
// Note that you need to call EntityField.Unwrap() before calling this method if this EntityField
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (ef *EntityField) Update() *EntityFieldUpdateOne {
|
||||
return NewEntityFieldClient(ef.config).UpdateOne(ef)
|
||||
func (_m *EntityField) Update() *EntityFieldUpdateOne {
|
||||
return NewEntityFieldClient(_m.config).UpdateOne(_m)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the EntityField entity that was returned from a transaction after it was closed,
|
||||
// so that all future queries will be executed through the driver which created the transaction.
|
||||
func (ef *EntityField) Unwrap() *EntityField {
|
||||
_tx, ok := ef.config.driver.(*txDriver)
|
||||
func (_m *EntityField) Unwrap() *EntityField {
|
||||
_tx, ok := _m.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: EntityField is not a transactional entity")
|
||||
}
|
||||
ef.config.driver = _tx.drv
|
||||
return ef
|
||||
_m.config.driver = _tx.drv
|
||||
return _m
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (ef *EntityField) String() string {
|
||||
func (_m *EntityField) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("EntityField(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", ef.ID))
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||||
builder.WriteString("created_at=")
|
||||
builder.WriteString(ef.CreatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("updated_at=")
|
||||
builder.WriteString(ef.UpdatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("name=")
|
||||
builder.WriteString(ef.Name)
|
||||
builder.WriteString(_m.Name)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("description=")
|
||||
builder.WriteString(ef.Description)
|
||||
builder.WriteString(_m.Description)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("type=")
|
||||
builder.WriteString(fmt.Sprintf("%v", ef.Type))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Type))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("text_value=")
|
||||
builder.WriteString(ef.TextValue)
|
||||
builder.WriteString(_m.TextValue)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("number_value=")
|
||||
builder.WriteString(fmt.Sprintf("%v", ef.NumberValue))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.NumberValue))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("boolean_value=")
|
||||
builder.WriteString(fmt.Sprintf("%v", ef.BooleanValue))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.BooleanValue))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("time_value=")
|
||||
builder.WriteString(ef.TimeValue.Format(time.ANSIC))
|
||||
builder.WriteString(_m.TimeValue.Format(time.ANSIC))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
@@ -23,162 +23,162 @@ type EntityFieldCreate struct {
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (efc *EntityFieldCreate) SetCreatedAt(t time.Time) *EntityFieldCreate {
|
||||
efc.mutation.SetCreatedAt(t)
|
||||
return efc
|
||||
func (_c *EntityFieldCreate) SetCreatedAt(v time.Time) *EntityFieldCreate {
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||
func (efc *EntityFieldCreate) SetNillableCreatedAt(t *time.Time) *EntityFieldCreate {
|
||||
if t != nil {
|
||||
efc.SetCreatedAt(*t)
|
||||
func (_c *EntityFieldCreate) SetNillableCreatedAt(v *time.Time) *EntityFieldCreate {
|
||||
if v != nil {
|
||||
_c.SetCreatedAt(*v)
|
||||
}
|
||||
return efc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (efc *EntityFieldCreate) SetUpdatedAt(t time.Time) *EntityFieldCreate {
|
||||
efc.mutation.SetUpdatedAt(t)
|
||||
return efc
|
||||
func (_c *EntityFieldCreate) SetUpdatedAt(v time.Time) *EntityFieldCreate {
|
||||
_c.mutation.SetUpdatedAt(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
||||
func (efc *EntityFieldCreate) SetNillableUpdatedAt(t *time.Time) *EntityFieldCreate {
|
||||
if t != nil {
|
||||
efc.SetUpdatedAt(*t)
|
||||
func (_c *EntityFieldCreate) SetNillableUpdatedAt(v *time.Time) *EntityFieldCreate {
|
||||
if v != nil {
|
||||
_c.SetUpdatedAt(*v)
|
||||
}
|
||||
return efc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (efc *EntityFieldCreate) SetName(s string) *EntityFieldCreate {
|
||||
efc.mutation.SetName(s)
|
||||
return efc
|
||||
func (_c *EntityFieldCreate) SetName(v string) *EntityFieldCreate {
|
||||
_c.mutation.SetName(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetDescription sets the "description" field.
|
||||
func (efc *EntityFieldCreate) SetDescription(s string) *EntityFieldCreate {
|
||||
efc.mutation.SetDescription(s)
|
||||
return efc
|
||||
func (_c *EntityFieldCreate) SetDescription(v string) *EntityFieldCreate {
|
||||
_c.mutation.SetDescription(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableDescription sets the "description" field if the given value is not nil.
|
||||
func (efc *EntityFieldCreate) SetNillableDescription(s *string) *EntityFieldCreate {
|
||||
if s != nil {
|
||||
efc.SetDescription(*s)
|
||||
func (_c *EntityFieldCreate) SetNillableDescription(v *string) *EntityFieldCreate {
|
||||
if v != nil {
|
||||
_c.SetDescription(*v)
|
||||
}
|
||||
return efc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetType sets the "type" field.
|
||||
func (efc *EntityFieldCreate) SetType(e entityfield.Type) *EntityFieldCreate {
|
||||
efc.mutation.SetType(e)
|
||||
return efc
|
||||
func (_c *EntityFieldCreate) SetType(v entityfield.Type) *EntityFieldCreate {
|
||||
_c.mutation.SetType(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetTextValue sets the "text_value" field.
|
||||
func (efc *EntityFieldCreate) SetTextValue(s string) *EntityFieldCreate {
|
||||
efc.mutation.SetTextValue(s)
|
||||
return efc
|
||||
func (_c *EntityFieldCreate) SetTextValue(v string) *EntityFieldCreate {
|
||||
_c.mutation.SetTextValue(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableTextValue sets the "text_value" field if the given value is not nil.
|
||||
func (efc *EntityFieldCreate) SetNillableTextValue(s *string) *EntityFieldCreate {
|
||||
if s != nil {
|
||||
efc.SetTextValue(*s)
|
||||
func (_c *EntityFieldCreate) SetNillableTextValue(v *string) *EntityFieldCreate {
|
||||
if v != nil {
|
||||
_c.SetTextValue(*v)
|
||||
}
|
||||
return efc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNumberValue sets the "number_value" field.
|
||||
func (efc *EntityFieldCreate) SetNumberValue(i int) *EntityFieldCreate {
|
||||
efc.mutation.SetNumberValue(i)
|
||||
return efc
|
||||
func (_c *EntityFieldCreate) SetNumberValue(v int) *EntityFieldCreate {
|
||||
_c.mutation.SetNumberValue(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableNumberValue sets the "number_value" field if the given value is not nil.
|
||||
func (efc *EntityFieldCreate) SetNillableNumberValue(i *int) *EntityFieldCreate {
|
||||
if i != nil {
|
||||
efc.SetNumberValue(*i)
|
||||
func (_c *EntityFieldCreate) SetNillableNumberValue(v *int) *EntityFieldCreate {
|
||||
if v != nil {
|
||||
_c.SetNumberValue(*v)
|
||||
}
|
||||
return efc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetBooleanValue sets the "boolean_value" field.
|
||||
func (efc *EntityFieldCreate) SetBooleanValue(b bool) *EntityFieldCreate {
|
||||
efc.mutation.SetBooleanValue(b)
|
||||
return efc
|
||||
func (_c *EntityFieldCreate) SetBooleanValue(v bool) *EntityFieldCreate {
|
||||
_c.mutation.SetBooleanValue(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableBooleanValue sets the "boolean_value" field if the given value is not nil.
|
||||
func (efc *EntityFieldCreate) SetNillableBooleanValue(b *bool) *EntityFieldCreate {
|
||||
if b != nil {
|
||||
efc.SetBooleanValue(*b)
|
||||
func (_c *EntityFieldCreate) SetNillableBooleanValue(v *bool) *EntityFieldCreate {
|
||||
if v != nil {
|
||||
_c.SetBooleanValue(*v)
|
||||
}
|
||||
return efc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetTimeValue sets the "time_value" field.
|
||||
func (efc *EntityFieldCreate) SetTimeValue(t time.Time) *EntityFieldCreate {
|
||||
efc.mutation.SetTimeValue(t)
|
||||
return efc
|
||||
func (_c *EntityFieldCreate) SetTimeValue(v time.Time) *EntityFieldCreate {
|
||||
_c.mutation.SetTimeValue(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableTimeValue sets the "time_value" field if the given value is not nil.
|
||||
func (efc *EntityFieldCreate) SetNillableTimeValue(t *time.Time) *EntityFieldCreate {
|
||||
if t != nil {
|
||||
efc.SetTimeValue(*t)
|
||||
func (_c *EntityFieldCreate) SetNillableTimeValue(v *time.Time) *EntityFieldCreate {
|
||||
if v != nil {
|
||||
_c.SetTimeValue(*v)
|
||||
}
|
||||
return efc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetID sets the "id" field.
|
||||
func (efc *EntityFieldCreate) SetID(u uuid.UUID) *EntityFieldCreate {
|
||||
efc.mutation.SetID(u)
|
||||
return efc
|
||||
func (_c *EntityFieldCreate) SetID(v uuid.UUID) *EntityFieldCreate {
|
||||
_c.mutation.SetID(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableID sets the "id" field if the given value is not nil.
|
||||
func (efc *EntityFieldCreate) SetNillableID(u *uuid.UUID) *EntityFieldCreate {
|
||||
if u != nil {
|
||||
efc.SetID(*u)
|
||||
func (_c *EntityFieldCreate) SetNillableID(v *uuid.UUID) *EntityFieldCreate {
|
||||
if v != nil {
|
||||
_c.SetID(*v)
|
||||
}
|
||||
return efc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetEntityID sets the "entity" edge to the Entity entity by ID.
|
||||
func (efc *EntityFieldCreate) SetEntityID(id uuid.UUID) *EntityFieldCreate {
|
||||
efc.mutation.SetEntityID(id)
|
||||
return efc
|
||||
func (_c *EntityFieldCreate) SetEntityID(id uuid.UUID) *EntityFieldCreate {
|
||||
_c.mutation.SetEntityID(id)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableEntityID sets the "entity" edge to the Entity entity by ID if the given value is not nil.
|
||||
func (efc *EntityFieldCreate) SetNillableEntityID(id *uuid.UUID) *EntityFieldCreate {
|
||||
func (_c *EntityFieldCreate) SetNillableEntityID(id *uuid.UUID) *EntityFieldCreate {
|
||||
if id != nil {
|
||||
efc = efc.SetEntityID(*id)
|
||||
_c = _c.SetEntityID(*id)
|
||||
}
|
||||
return efc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetEntity sets the "entity" edge to the Entity entity.
|
||||
func (efc *EntityFieldCreate) SetEntity(e *Entity) *EntityFieldCreate {
|
||||
return efc.SetEntityID(e.ID)
|
||||
func (_c *EntityFieldCreate) SetEntity(v *Entity) *EntityFieldCreate {
|
||||
return _c.SetEntityID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the EntityFieldMutation object of the builder.
|
||||
func (efc *EntityFieldCreate) Mutation() *EntityFieldMutation {
|
||||
return efc.mutation
|
||||
func (_c *EntityFieldCreate) Mutation() *EntityFieldMutation {
|
||||
return _c.mutation
|
||||
}
|
||||
|
||||
// Save creates the EntityField in the database.
|
||||
func (efc *EntityFieldCreate) Save(ctx context.Context) (*EntityField, error) {
|
||||
efc.defaults()
|
||||
return withHooks(ctx, efc.sqlSave, efc.mutation, efc.hooks)
|
||||
func (_c *EntityFieldCreate) Save(ctx context.Context) (*EntityField, error) {
|
||||
_c.defaults()
|
||||
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (efc *EntityFieldCreate) SaveX(ctx context.Context) *EntityField {
|
||||
v, err := efc.Save(ctx)
|
||||
func (_c *EntityFieldCreate) SaveX(ctx context.Context) *EntityField {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -186,91 +186,91 @@ func (efc *EntityFieldCreate) SaveX(ctx context.Context) *EntityField {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (efc *EntityFieldCreate) Exec(ctx context.Context) error {
|
||||
_, err := efc.Save(ctx)
|
||||
func (_c *EntityFieldCreate) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (efc *EntityFieldCreate) ExecX(ctx context.Context) {
|
||||
if err := efc.Exec(ctx); err != nil {
|
||||
func (_c *EntityFieldCreate) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (efc *EntityFieldCreate) defaults() {
|
||||
if _, ok := efc.mutation.CreatedAt(); !ok {
|
||||
func (_c *EntityFieldCreate) defaults() {
|
||||
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||
v := entityfield.DefaultCreatedAt()
|
||||
efc.mutation.SetCreatedAt(v)
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
}
|
||||
if _, ok := efc.mutation.UpdatedAt(); !ok {
|
||||
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
||||
v := entityfield.DefaultUpdatedAt()
|
||||
efc.mutation.SetUpdatedAt(v)
|
||||
_c.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
if _, ok := efc.mutation.BooleanValue(); !ok {
|
||||
if _, ok := _c.mutation.BooleanValue(); !ok {
|
||||
v := entityfield.DefaultBooleanValue
|
||||
efc.mutation.SetBooleanValue(v)
|
||||
_c.mutation.SetBooleanValue(v)
|
||||
}
|
||||
if _, ok := efc.mutation.TimeValue(); !ok {
|
||||
if _, ok := _c.mutation.TimeValue(); !ok {
|
||||
v := entityfield.DefaultTimeValue()
|
||||
efc.mutation.SetTimeValue(v)
|
||||
_c.mutation.SetTimeValue(v)
|
||||
}
|
||||
if _, ok := efc.mutation.ID(); !ok {
|
||||
if _, ok := _c.mutation.ID(); !ok {
|
||||
v := entityfield.DefaultID()
|
||||
efc.mutation.SetID(v)
|
||||
_c.mutation.SetID(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (efc *EntityFieldCreate) check() error {
|
||||
if _, ok := efc.mutation.CreatedAt(); !ok {
|
||||
func (_c *EntityFieldCreate) check() error {
|
||||
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "EntityField.created_at"`)}
|
||||
}
|
||||
if _, ok := efc.mutation.UpdatedAt(); !ok {
|
||||
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
||||
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "EntityField.updated_at"`)}
|
||||
}
|
||||
if _, ok := efc.mutation.Name(); !ok {
|
||||
if _, ok := _c.mutation.Name(); !ok {
|
||||
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "EntityField.name"`)}
|
||||
}
|
||||
if v, ok := efc.mutation.Name(); ok {
|
||||
if v, ok := _c.mutation.Name(); ok {
|
||||
if err := entityfield.NameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "EntityField.name": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := efc.mutation.Description(); ok {
|
||||
if v, ok := _c.mutation.Description(); ok {
|
||||
if err := entityfield.DescriptionValidator(v); err != nil {
|
||||
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "EntityField.description": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := efc.mutation.GetType(); !ok {
|
||||
if _, ok := _c.mutation.GetType(); !ok {
|
||||
return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "EntityField.type"`)}
|
||||
}
|
||||
if v, ok := efc.mutation.GetType(); ok {
|
||||
if v, ok := _c.mutation.GetType(); ok {
|
||||
if err := entityfield.TypeValidator(v); err != nil {
|
||||
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "EntityField.type": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := efc.mutation.TextValue(); ok {
|
||||
if v, ok := _c.mutation.TextValue(); ok {
|
||||
if err := entityfield.TextValueValidator(v); err != nil {
|
||||
return &ValidationError{Name: "text_value", err: fmt.Errorf(`ent: validator failed for field "EntityField.text_value": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := efc.mutation.BooleanValue(); !ok {
|
||||
if _, ok := _c.mutation.BooleanValue(); !ok {
|
||||
return &ValidationError{Name: "boolean_value", err: errors.New(`ent: missing required field "EntityField.boolean_value"`)}
|
||||
}
|
||||
if _, ok := efc.mutation.TimeValue(); !ok {
|
||||
if _, ok := _c.mutation.TimeValue(); !ok {
|
||||
return &ValidationError{Name: "time_value", err: errors.New(`ent: missing required field "EntityField.time_value"`)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (efc *EntityFieldCreate) sqlSave(ctx context.Context) (*EntityField, error) {
|
||||
if err := efc.check(); err != nil {
|
||||
func (_c *EntityFieldCreate) sqlSave(ctx context.Context) (*EntityField, error) {
|
||||
if err := _c.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_node, _spec := efc.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, efc.driver, _spec); err != nil {
|
||||
_node, _spec := _c.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
@@ -283,57 +283,57 @@ func (efc *EntityFieldCreate) sqlSave(ctx context.Context) (*EntityField, error)
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
efc.mutation.id = &_node.ID
|
||||
efc.mutation.done = true
|
||||
_c.mutation.id = &_node.ID
|
||||
_c.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
func (efc *EntityFieldCreate) createSpec() (*EntityField, *sqlgraph.CreateSpec) {
|
||||
func (_c *EntityFieldCreate) createSpec() (*EntityField, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &EntityField{config: efc.config}
|
||||
_node = &EntityField{config: _c.config}
|
||||
_spec = sqlgraph.NewCreateSpec(entityfield.Table, sqlgraph.NewFieldSpec(entityfield.FieldID, field.TypeUUID))
|
||||
)
|
||||
if id, ok := efc.mutation.ID(); ok {
|
||||
if id, ok := _c.mutation.ID(); ok {
|
||||
_node.ID = id
|
||||
_spec.ID.Value = &id
|
||||
}
|
||||
if value, ok := efc.mutation.CreatedAt(); ok {
|
||||
if value, ok := _c.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(entityfield.FieldCreatedAt, field.TypeTime, value)
|
||||
_node.CreatedAt = value
|
||||
}
|
||||
if value, ok := efc.mutation.UpdatedAt(); ok {
|
||||
if value, ok := _c.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(entityfield.FieldUpdatedAt, field.TypeTime, value)
|
||||
_node.UpdatedAt = value
|
||||
}
|
||||
if value, ok := efc.mutation.Name(); ok {
|
||||
if value, ok := _c.mutation.Name(); ok {
|
||||
_spec.SetField(entityfield.FieldName, field.TypeString, value)
|
||||
_node.Name = value
|
||||
}
|
||||
if value, ok := efc.mutation.Description(); ok {
|
||||
if value, ok := _c.mutation.Description(); ok {
|
||||
_spec.SetField(entityfield.FieldDescription, field.TypeString, value)
|
||||
_node.Description = value
|
||||
}
|
||||
if value, ok := efc.mutation.GetType(); ok {
|
||||
if value, ok := _c.mutation.GetType(); ok {
|
||||
_spec.SetField(entityfield.FieldType, field.TypeEnum, value)
|
||||
_node.Type = value
|
||||
}
|
||||
if value, ok := efc.mutation.TextValue(); ok {
|
||||
if value, ok := _c.mutation.TextValue(); ok {
|
||||
_spec.SetField(entityfield.FieldTextValue, field.TypeString, value)
|
||||
_node.TextValue = value
|
||||
}
|
||||
if value, ok := efc.mutation.NumberValue(); ok {
|
||||
if value, ok := _c.mutation.NumberValue(); ok {
|
||||
_spec.SetField(entityfield.FieldNumberValue, field.TypeInt, value)
|
||||
_node.NumberValue = value
|
||||
}
|
||||
if value, ok := efc.mutation.BooleanValue(); ok {
|
||||
if value, ok := _c.mutation.BooleanValue(); ok {
|
||||
_spec.SetField(entityfield.FieldBooleanValue, field.TypeBool, value)
|
||||
_node.BooleanValue = value
|
||||
}
|
||||
if value, ok := efc.mutation.TimeValue(); ok {
|
||||
if value, ok := _c.mutation.TimeValue(); ok {
|
||||
_spec.SetField(entityfield.FieldTimeValue, field.TypeTime, value)
|
||||
_node.TimeValue = value
|
||||
}
|
||||
if nodes := efc.mutation.EntityIDs(); len(nodes) > 0 {
|
||||
if nodes := _c.mutation.EntityIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -361,16 +361,16 @@ type EntityFieldCreateBulk struct {
|
||||
}
|
||||
|
||||
// Save creates the EntityField entities in the database.
|
||||
func (efcb *EntityFieldCreateBulk) Save(ctx context.Context) ([]*EntityField, error) {
|
||||
if efcb.err != nil {
|
||||
return nil, efcb.err
|
||||
func (_c *EntityFieldCreateBulk) Save(ctx context.Context) ([]*EntityField, error) {
|
||||
if _c.err != nil {
|
||||
return nil, _c.err
|
||||
}
|
||||
specs := make([]*sqlgraph.CreateSpec, len(efcb.builders))
|
||||
nodes := make([]*EntityField, len(efcb.builders))
|
||||
mutators := make([]Mutator, len(efcb.builders))
|
||||
for i := range efcb.builders {
|
||||
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
||||
nodes := make([]*EntityField, len(_c.builders))
|
||||
mutators := make([]Mutator, len(_c.builders))
|
||||
for i := range _c.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := efcb.builders[i]
|
||||
builder := _c.builders[i]
|
||||
builder.defaults()
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*EntityFieldMutation)
|
||||
@@ -384,11 +384,11 @@ func (efcb *EntityFieldCreateBulk) Save(ctx context.Context) ([]*EntityField, er
|
||||
var err error
|
||||
nodes[i], specs[i] = builder.createSpec()
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, efcb.builders[i+1].mutation)
|
||||
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
|
||||
} else {
|
||||
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
||||
// Invoke the actual operation on the latest mutation in the chain.
|
||||
if err = sqlgraph.BatchCreate(ctx, efcb.driver, spec); err != nil {
|
||||
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
@@ -408,7 +408,7 @@ func (efcb *EntityFieldCreateBulk) Save(ctx context.Context) ([]*EntityField, er
|
||||
}(i, ctx)
|
||||
}
|
||||
if len(mutators) > 0 {
|
||||
if _, err := mutators[0].Mutate(ctx, efcb.builders[0].mutation); err != nil {
|
||||
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
@@ -416,8 +416,8 @@ func (efcb *EntityFieldCreateBulk) Save(ctx context.Context) ([]*EntityField, er
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (efcb *EntityFieldCreateBulk) SaveX(ctx context.Context) []*EntityField {
|
||||
v, err := efcb.Save(ctx)
|
||||
func (_c *EntityFieldCreateBulk) SaveX(ctx context.Context) []*EntityField {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -425,14 +425,14 @@ func (efcb *EntityFieldCreateBulk) SaveX(ctx context.Context) []*EntityField {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (efcb *EntityFieldCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := efcb.Save(ctx)
|
||||
func (_c *EntityFieldCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (efcb *EntityFieldCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := efcb.Exec(ctx); err != nil {
|
||||
func (_c *EntityFieldCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,56 +20,56 @@ type EntityFieldDelete struct {
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the EntityFieldDelete builder.
|
||||
func (efd *EntityFieldDelete) Where(ps ...predicate.EntityField) *EntityFieldDelete {
|
||||
efd.mutation.Where(ps...)
|
||||
return efd
|
||||
func (_d *EntityFieldDelete) Where(ps ...predicate.EntityField) *EntityFieldDelete {
|
||||
_d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (efd *EntityFieldDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, efd.sqlExec, efd.mutation, efd.hooks)
|
||||
func (_d *EntityFieldDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (efd *EntityFieldDelete) ExecX(ctx context.Context) int {
|
||||
n, err := efd.Exec(ctx)
|
||||
func (_d *EntityFieldDelete) ExecX(ctx context.Context) int {
|
||||
n, err := _d.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (efd *EntityFieldDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
func (_d *EntityFieldDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := sqlgraph.NewDeleteSpec(entityfield.Table, sqlgraph.NewFieldSpec(entityfield.FieldID, field.TypeUUID))
|
||||
if ps := efd.mutation.predicates; len(ps) > 0 {
|
||||
if ps := _d.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, efd.driver, _spec)
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec)
|
||||
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
efd.mutation.done = true
|
||||
_d.mutation.done = true
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// EntityFieldDeleteOne is the builder for deleting a single EntityField entity.
|
||||
type EntityFieldDeleteOne struct {
|
||||
efd *EntityFieldDelete
|
||||
_d *EntityFieldDelete
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the EntityFieldDelete builder.
|
||||
func (efdo *EntityFieldDeleteOne) Where(ps ...predicate.EntityField) *EntityFieldDeleteOne {
|
||||
efdo.efd.mutation.Where(ps...)
|
||||
return efdo
|
||||
func (_d *EntityFieldDeleteOne) Where(ps ...predicate.EntityField) *EntityFieldDeleteOne {
|
||||
_d._d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (efdo *EntityFieldDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := efdo.efd.Exec(ctx)
|
||||
func (_d *EntityFieldDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := _d._d.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
@@ -81,8 +81,8 @@ func (efdo *EntityFieldDeleteOne) Exec(ctx context.Context) error {
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (efdo *EntityFieldDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := efdo.Exec(ctx); err != nil {
|
||||
func (_d *EntityFieldDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := _d.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,44 +32,44 @@ type EntityFieldQuery struct {
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the EntityFieldQuery builder.
|
||||
func (efq *EntityFieldQuery) Where(ps ...predicate.EntityField) *EntityFieldQuery {
|
||||
efq.predicates = append(efq.predicates, ps...)
|
||||
return efq
|
||||
func (_q *EntityFieldQuery) Where(ps ...predicate.EntityField) *EntityFieldQuery {
|
||||
_q.predicates = append(_q.predicates, ps...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// Limit the number of records to be returned by this query.
|
||||
func (efq *EntityFieldQuery) Limit(limit int) *EntityFieldQuery {
|
||||
efq.ctx.Limit = &limit
|
||||
return efq
|
||||
func (_q *EntityFieldQuery) Limit(limit int) *EntityFieldQuery {
|
||||
_q.ctx.Limit = &limit
|
||||
return _q
|
||||
}
|
||||
|
||||
// Offset to start from.
|
||||
func (efq *EntityFieldQuery) Offset(offset int) *EntityFieldQuery {
|
||||
efq.ctx.Offset = &offset
|
||||
return efq
|
||||
func (_q *EntityFieldQuery) Offset(offset int) *EntityFieldQuery {
|
||||
_q.ctx.Offset = &offset
|
||||
return _q
|
||||
}
|
||||
|
||||
// Unique configures the query builder to filter duplicate records on query.
|
||||
// By default, unique is set to true, and can be disabled using this method.
|
||||
func (efq *EntityFieldQuery) Unique(unique bool) *EntityFieldQuery {
|
||||
efq.ctx.Unique = &unique
|
||||
return efq
|
||||
func (_q *EntityFieldQuery) Unique(unique bool) *EntityFieldQuery {
|
||||
_q.ctx.Unique = &unique
|
||||
return _q
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (efq *EntityFieldQuery) Order(o ...entityfield.OrderOption) *EntityFieldQuery {
|
||||
efq.order = append(efq.order, o...)
|
||||
return efq
|
||||
func (_q *EntityFieldQuery) Order(o ...entityfield.OrderOption) *EntityFieldQuery {
|
||||
_q.order = append(_q.order, o...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// QueryEntity chains the current query on the "entity" edge.
|
||||
func (efq *EntityFieldQuery) QueryEntity() *EntityQuery {
|
||||
query := (&EntityClient{config: efq.config}).Query()
|
||||
func (_q *EntityFieldQuery) QueryEntity() *EntityQuery {
|
||||
query := (&EntityClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := efq.prepareQuery(ctx); err != nil {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := efq.sqlQuery(ctx)
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -78,7 +78,7 @@ func (efq *EntityFieldQuery) QueryEntity() *EntityQuery {
|
||||
sqlgraph.To(entity.Table, entity.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, entityfield.EntityTable, entityfield.EntityColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(efq.driver.Dialect(), step)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
@@ -86,8 +86,8 @@ func (efq *EntityFieldQuery) QueryEntity() *EntityQuery {
|
||||
|
||||
// First returns the first EntityField entity from the query.
|
||||
// Returns a *NotFoundError when no EntityField was found.
|
||||
func (efq *EntityFieldQuery) First(ctx context.Context) (*EntityField, error) {
|
||||
nodes, err := efq.Limit(1).All(setContextOp(ctx, efq.ctx, ent.OpQueryFirst))
|
||||
func (_q *EntityFieldQuery) First(ctx context.Context) (*EntityField, error) {
|
||||
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -98,8 +98,8 @@ func (efq *EntityFieldQuery) First(ctx context.Context) (*EntityField, error) {
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (efq *EntityFieldQuery) FirstX(ctx context.Context) *EntityField {
|
||||
node, err := efq.First(ctx)
|
||||
func (_q *EntityFieldQuery) FirstX(ctx context.Context) *EntityField {
|
||||
node, err := _q.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
@@ -108,9 +108,9 @@ func (efq *EntityFieldQuery) FirstX(ctx context.Context) *EntityField {
|
||||
|
||||
// FirstID returns the first EntityField ID from the query.
|
||||
// Returns a *NotFoundError when no EntityField ID was found.
|
||||
func (efq *EntityFieldQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
func (_q *EntityFieldQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
var ids []uuid.UUID
|
||||
if ids, err = efq.Limit(1).IDs(setContextOp(ctx, efq.ctx, ent.OpQueryFirstID)); err != nil {
|
||||
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
@@ -121,8 +121,8 @@ func (efq *EntityFieldQuery) FirstID(ctx context.Context) (id uuid.UUID, err err
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (efq *EntityFieldQuery) FirstIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := efq.FirstID(ctx)
|
||||
func (_q *EntityFieldQuery) FirstIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := _q.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
@@ -132,8 +132,8 @@ func (efq *EntityFieldQuery) FirstIDX(ctx context.Context) uuid.UUID {
|
||||
// Only returns a single EntityField entity found by the query, ensuring it only returns one.
|
||||
// Returns a *NotSingularError when more than one EntityField entity is found.
|
||||
// Returns a *NotFoundError when no EntityField entities are found.
|
||||
func (efq *EntityFieldQuery) Only(ctx context.Context) (*EntityField, error) {
|
||||
nodes, err := efq.Limit(2).All(setContextOp(ctx, efq.ctx, ent.OpQueryOnly))
|
||||
func (_q *EntityFieldQuery) Only(ctx context.Context) (*EntityField, error) {
|
||||
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -148,8 +148,8 @@ func (efq *EntityFieldQuery) Only(ctx context.Context) (*EntityField, error) {
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (efq *EntityFieldQuery) OnlyX(ctx context.Context) *EntityField {
|
||||
node, err := efq.Only(ctx)
|
||||
func (_q *EntityFieldQuery) OnlyX(ctx context.Context) *EntityField {
|
||||
node, err := _q.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -159,9 +159,9 @@ func (efq *EntityFieldQuery) OnlyX(ctx context.Context) *EntityField {
|
||||
// OnlyID is like Only, but returns the only EntityField ID in the query.
|
||||
// Returns a *NotSingularError when more than one EntityField ID is found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (efq *EntityFieldQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
func (_q *EntityFieldQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
var ids []uuid.UUID
|
||||
if ids, err = efq.Limit(2).IDs(setContextOp(ctx, efq.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
@@ -176,8 +176,8 @@ func (efq *EntityFieldQuery) OnlyID(ctx context.Context) (id uuid.UUID, err erro
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (efq *EntityFieldQuery) OnlyIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := efq.OnlyID(ctx)
|
||||
func (_q *EntityFieldQuery) OnlyIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := _q.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -185,18 +185,18 @@ func (efq *EntityFieldQuery) OnlyIDX(ctx context.Context) uuid.UUID {
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of EntityFields.
|
||||
func (efq *EntityFieldQuery) All(ctx context.Context) ([]*EntityField, error) {
|
||||
ctx = setContextOp(ctx, efq.ctx, ent.OpQueryAll)
|
||||
if err := efq.prepareQuery(ctx); err != nil {
|
||||
func (_q *EntityFieldQuery) All(ctx context.Context) ([]*EntityField, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qr := querierAll[[]*EntityField, *EntityFieldQuery]()
|
||||
return withInterceptors[[]*EntityField](ctx, efq, qr, efq.inters)
|
||||
return withInterceptors[[]*EntityField](ctx, _q, qr, _q.inters)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (efq *EntityFieldQuery) AllX(ctx context.Context) []*EntityField {
|
||||
nodes, err := efq.All(ctx)
|
||||
func (_q *EntityFieldQuery) AllX(ctx context.Context) []*EntityField {
|
||||
nodes, err := _q.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -204,20 +204,20 @@ func (efq *EntityFieldQuery) AllX(ctx context.Context) []*EntityField {
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of EntityField IDs.
|
||||
func (efq *EntityFieldQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
|
||||
if efq.ctx.Unique == nil && efq.path != nil {
|
||||
efq.Unique(true)
|
||||
func (_q *EntityFieldQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
|
||||
if _q.ctx.Unique == nil && _q.path != nil {
|
||||
_q.Unique(true)
|
||||
}
|
||||
ctx = setContextOp(ctx, efq.ctx, ent.OpQueryIDs)
|
||||
if err = efq.Select(entityfield.FieldID).Scan(ctx, &ids); err != nil {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
|
||||
if err = _q.Select(entityfield.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (efq *EntityFieldQuery) IDsX(ctx context.Context) []uuid.UUID {
|
||||
ids, err := efq.IDs(ctx)
|
||||
func (_q *EntityFieldQuery) IDsX(ctx context.Context) []uuid.UUID {
|
||||
ids, err := _q.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -225,17 +225,17 @@ func (efq *EntityFieldQuery) IDsX(ctx context.Context) []uuid.UUID {
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (efq *EntityFieldQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, efq.ctx, ent.OpQueryCount)
|
||||
if err := efq.prepareQuery(ctx); err != nil {
|
||||
func (_q *EntityFieldQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return withInterceptors[int](ctx, efq, querierCount[*EntityFieldQuery](), efq.inters)
|
||||
return withInterceptors[int](ctx, _q, querierCount[*EntityFieldQuery](), _q.inters)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (efq *EntityFieldQuery) CountX(ctx context.Context) int {
|
||||
count, err := efq.Count(ctx)
|
||||
func (_q *EntityFieldQuery) CountX(ctx context.Context) int {
|
||||
count, err := _q.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -243,9 +243,9 @@ func (efq *EntityFieldQuery) CountX(ctx context.Context) int {
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (efq *EntityFieldQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, efq.ctx, ent.OpQueryExist)
|
||||
switch _, err := efq.FirstID(ctx); {
|
||||
func (_q *EntityFieldQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
|
||||
switch _, err := _q.FirstID(ctx); {
|
||||
case IsNotFound(err):
|
||||
return false, nil
|
||||
case err != nil:
|
||||
@@ -256,8 +256,8 @@ func (efq *EntityFieldQuery) Exist(ctx context.Context) (bool, error) {
|
||||
}
|
||||
|
||||
// ExistX is like Exist, but panics if an error occurs.
|
||||
func (efq *EntityFieldQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := efq.Exist(ctx)
|
||||
func (_q *EntityFieldQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := _q.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -266,32 +266,32 @@ func (efq *EntityFieldQuery) ExistX(ctx context.Context) bool {
|
||||
|
||||
// Clone returns a duplicate of the EntityFieldQuery builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (efq *EntityFieldQuery) Clone() *EntityFieldQuery {
|
||||
if efq == nil {
|
||||
func (_q *EntityFieldQuery) Clone() *EntityFieldQuery {
|
||||
if _q == nil {
|
||||
return nil
|
||||
}
|
||||
return &EntityFieldQuery{
|
||||
config: efq.config,
|
||||
ctx: efq.ctx.Clone(),
|
||||
order: append([]entityfield.OrderOption{}, efq.order...),
|
||||
inters: append([]Interceptor{}, efq.inters...),
|
||||
predicates: append([]predicate.EntityField{}, efq.predicates...),
|
||||
withEntity: efq.withEntity.Clone(),
|
||||
config: _q.config,
|
||||
ctx: _q.ctx.Clone(),
|
||||
order: append([]entityfield.OrderOption{}, _q.order...),
|
||||
inters: append([]Interceptor{}, _q.inters...),
|
||||
predicates: append([]predicate.EntityField{}, _q.predicates...),
|
||||
withEntity: _q.withEntity.Clone(),
|
||||
// clone intermediate query.
|
||||
sql: efq.sql.Clone(),
|
||||
path: efq.path,
|
||||
sql: _q.sql.Clone(),
|
||||
path: _q.path,
|
||||
}
|
||||
}
|
||||
|
||||
// WithEntity tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "entity" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (efq *EntityFieldQuery) WithEntity(opts ...func(*EntityQuery)) *EntityFieldQuery {
|
||||
query := (&EntityClient{config: efq.config}).Query()
|
||||
func (_q *EntityFieldQuery) WithEntity(opts ...func(*EntityQuery)) *EntityFieldQuery {
|
||||
query := (&EntityClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
efq.withEntity = query
|
||||
return efq
|
||||
_q.withEntity = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// GroupBy is used to group vertices by one or more fields/columns.
|
||||
@@ -308,10 +308,10 @@ func (efq *EntityFieldQuery) WithEntity(opts ...func(*EntityQuery)) *EntityField
|
||||
// GroupBy(entityfield.FieldCreatedAt).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (efq *EntityFieldQuery) GroupBy(field string, fields ...string) *EntityFieldGroupBy {
|
||||
efq.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &EntityFieldGroupBy{build: efq}
|
||||
grbuild.flds = &efq.ctx.Fields
|
||||
func (_q *EntityFieldQuery) GroupBy(field string, fields ...string) *EntityFieldGroupBy {
|
||||
_q.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &EntityFieldGroupBy{build: _q}
|
||||
grbuild.flds = &_q.ctx.Fields
|
||||
grbuild.label = entityfield.Label
|
||||
grbuild.scan = grbuild.Scan
|
||||
return grbuild
|
||||
@@ -329,55 +329,55 @@ func (efq *EntityFieldQuery) GroupBy(field string, fields ...string) *EntityFiel
|
||||
// client.EntityField.Query().
|
||||
// Select(entityfield.FieldCreatedAt).
|
||||
// Scan(ctx, &v)
|
||||
func (efq *EntityFieldQuery) Select(fields ...string) *EntityFieldSelect {
|
||||
efq.ctx.Fields = append(efq.ctx.Fields, fields...)
|
||||
sbuild := &EntityFieldSelect{EntityFieldQuery: efq}
|
||||
func (_q *EntityFieldQuery) Select(fields ...string) *EntityFieldSelect {
|
||||
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
||||
sbuild := &EntityFieldSelect{EntityFieldQuery: _q}
|
||||
sbuild.label = entityfield.Label
|
||||
sbuild.flds, sbuild.scan = &efq.ctx.Fields, sbuild.Scan
|
||||
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
|
||||
return sbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a EntityFieldSelect configured with the given aggregations.
|
||||
func (efq *EntityFieldQuery) Aggregate(fns ...AggregateFunc) *EntityFieldSelect {
|
||||
return efq.Select().Aggregate(fns...)
|
||||
func (_q *EntityFieldQuery) Aggregate(fns ...AggregateFunc) *EntityFieldSelect {
|
||||
return _q.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (efq *EntityFieldQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range efq.inters {
|
||||
func (_q *EntityFieldQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range _q.inters {
|
||||
if inter == nil {
|
||||
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
|
||||
}
|
||||
if trv, ok := inter.(Traverser); ok {
|
||||
if err := trv.Traverse(ctx, efq); err != nil {
|
||||
if err := trv.Traverse(ctx, _q); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, f := range efq.ctx.Fields {
|
||||
for _, f := range _q.ctx.Fields {
|
||||
if !entityfield.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
}
|
||||
if efq.path != nil {
|
||||
prev, err := efq.path(ctx)
|
||||
if _q.path != nil {
|
||||
prev, err := _q.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
efq.sql = prev
|
||||
_q.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (efq *EntityFieldQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*EntityField, error) {
|
||||
func (_q *EntityFieldQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*EntityField, error) {
|
||||
var (
|
||||
nodes = []*EntityField{}
|
||||
withFKs = efq.withFKs
|
||||
_spec = efq.querySpec()
|
||||
withFKs = _q.withFKs
|
||||
_spec = _q.querySpec()
|
||||
loadedTypes = [1]bool{
|
||||
efq.withEntity != nil,
|
||||
_q.withEntity != nil,
|
||||
}
|
||||
)
|
||||
if efq.withEntity != nil {
|
||||
if _q.withEntity != nil {
|
||||
withFKs = true
|
||||
}
|
||||
if withFKs {
|
||||
@@ -387,7 +387,7 @@ func (efq *EntityFieldQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]
|
||||
return (*EntityField).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &EntityField{config: efq.config}
|
||||
node := &EntityField{config: _q.config}
|
||||
nodes = append(nodes, node)
|
||||
node.Edges.loadedTypes = loadedTypes
|
||||
return node.assignValues(columns, values)
|
||||
@@ -395,14 +395,14 @@ func (efq *EntityFieldQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]
|
||||
for i := range hooks {
|
||||
hooks[i](ctx, _spec)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, efq.driver, _spec); err != nil {
|
||||
if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
if query := efq.withEntity; query != nil {
|
||||
if err := efq.loadEntity(ctx, query, nodes, nil,
|
||||
if query := _q.withEntity; query != nil {
|
||||
if err := _q.loadEntity(ctx, query, nodes, nil,
|
||||
func(n *EntityField, e *Entity) { n.Edges.Entity = e }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -410,7 +410,7 @@ func (efq *EntityFieldQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (efq *EntityFieldQuery) loadEntity(ctx context.Context, query *EntityQuery, nodes []*EntityField, init func(*EntityField), assign func(*EntityField, *Entity)) error {
|
||||
func (_q *EntityFieldQuery) loadEntity(ctx context.Context, query *EntityQuery, nodes []*EntityField, init func(*EntityField), assign func(*EntityField, *Entity)) error {
|
||||
ids := make([]uuid.UUID, 0, len(nodes))
|
||||
nodeids := make(map[uuid.UUID][]*EntityField)
|
||||
for i := range nodes {
|
||||
@@ -443,24 +443,24 @@ func (efq *EntityFieldQuery) loadEntity(ctx context.Context, query *EntityQuery,
|
||||
return nil
|
||||
}
|
||||
|
||||
func (efq *EntityFieldQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := efq.querySpec()
|
||||
_spec.Node.Columns = efq.ctx.Fields
|
||||
if len(efq.ctx.Fields) > 0 {
|
||||
_spec.Unique = efq.ctx.Unique != nil && *efq.ctx.Unique
|
||||
func (_q *EntityFieldQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := _q.querySpec()
|
||||
_spec.Node.Columns = _q.ctx.Fields
|
||||
if len(_q.ctx.Fields) > 0 {
|
||||
_spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, efq.driver, _spec)
|
||||
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
|
||||
}
|
||||
|
||||
func (efq *EntityFieldQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
func (_q *EntityFieldQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := sqlgraph.NewQuerySpec(entityfield.Table, entityfield.Columns, sqlgraph.NewFieldSpec(entityfield.FieldID, field.TypeUUID))
|
||||
_spec.From = efq.sql
|
||||
if unique := efq.ctx.Unique; unique != nil {
|
||||
_spec.From = _q.sql
|
||||
if unique := _q.ctx.Unique; unique != nil {
|
||||
_spec.Unique = *unique
|
||||
} else if efq.path != nil {
|
||||
} else if _q.path != nil {
|
||||
_spec.Unique = true
|
||||
}
|
||||
if fields := efq.ctx.Fields; len(fields) > 0 {
|
||||
if fields := _q.ctx.Fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, entityfield.FieldID)
|
||||
for i := range fields {
|
||||
@@ -469,20 +469,20 @@ func (efq *EntityFieldQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := efq.predicates; len(ps) > 0 {
|
||||
if ps := _q.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := efq.ctx.Limit; limit != nil {
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := efq.ctx.Offset; offset != nil {
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := efq.order; len(ps) > 0 {
|
||||
if ps := _q.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
@@ -492,33 +492,33 @@ func (efq *EntityFieldQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (efq *EntityFieldQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(efq.driver.Dialect())
|
||||
func (_q *EntityFieldQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(_q.driver.Dialect())
|
||||
t1 := builder.Table(entityfield.Table)
|
||||
columns := efq.ctx.Fields
|
||||
columns := _q.ctx.Fields
|
||||
if len(columns) == 0 {
|
||||
columns = entityfield.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if efq.sql != nil {
|
||||
selector = efq.sql
|
||||
if _q.sql != nil {
|
||||
selector = _q.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
if efq.ctx.Unique != nil && *efq.ctx.Unique {
|
||||
if _q.ctx.Unique != nil && *_q.ctx.Unique {
|
||||
selector.Distinct()
|
||||
}
|
||||
for _, p := range efq.predicates {
|
||||
for _, p := range _q.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range efq.order {
|
||||
for _, p := range _q.order {
|
||||
p(selector)
|
||||
}
|
||||
if offset := efq.ctx.Offset; offset != nil {
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
// limit is mandatory for offset clause. We start
|
||||
// with default value, and override it below if needed.
|
||||
selector.Offset(*offset).Limit(math.MaxInt32)
|
||||
}
|
||||
if limit := efq.ctx.Limit; limit != nil {
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
@@ -531,41 +531,41 @@ type EntityFieldGroupBy struct {
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (efgb *EntityFieldGroupBy) Aggregate(fns ...AggregateFunc) *EntityFieldGroupBy {
|
||||
efgb.fns = append(efgb.fns, fns...)
|
||||
return efgb
|
||||
func (_g *EntityFieldGroupBy) Aggregate(fns ...AggregateFunc) *EntityFieldGroupBy {
|
||||
_g.fns = append(_g.fns, fns...)
|
||||
return _g
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (efgb *EntityFieldGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, efgb.build.ctx, ent.OpQueryGroupBy)
|
||||
if err := efgb.build.prepareQuery(ctx); err != nil {
|
||||
func (_g *EntityFieldGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
|
||||
if err := _g.build.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*EntityFieldQuery, *EntityFieldGroupBy](ctx, efgb.build, efgb, efgb.build.inters, v)
|
||||
return scanWithInterceptors[*EntityFieldQuery, *EntityFieldGroupBy](ctx, _g.build, _g, _g.build.inters, v)
|
||||
}
|
||||
|
||||
func (efgb *EntityFieldGroupBy) sqlScan(ctx context.Context, root *EntityFieldQuery, v any) error {
|
||||
func (_g *EntityFieldGroupBy) sqlScan(ctx context.Context, root *EntityFieldQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx).Select()
|
||||
aggregation := make([]string, 0, len(efgb.fns))
|
||||
for _, fn := range efgb.fns {
|
||||
aggregation := make([]string, 0, len(_g.fns))
|
||||
for _, fn := range _g.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(*efgb.flds)+len(efgb.fns))
|
||||
for _, f := range *efgb.flds {
|
||||
columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
|
||||
for _, f := range *_g.flds {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
columns = append(columns, aggregation...)
|
||||
selector.Select(columns...)
|
||||
}
|
||||
selector.GroupBy(selector.Columns(*efgb.flds...)...)
|
||||
selector.GroupBy(selector.Columns(*_g.flds...)...)
|
||||
if err := selector.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := efgb.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
@@ -579,27 +579,27 @@ type EntityFieldSelect struct {
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (efs *EntityFieldSelect) Aggregate(fns ...AggregateFunc) *EntityFieldSelect {
|
||||
efs.fns = append(efs.fns, fns...)
|
||||
return efs
|
||||
func (_s *EntityFieldSelect) Aggregate(fns ...AggregateFunc) *EntityFieldSelect {
|
||||
_s.fns = append(_s.fns, fns...)
|
||||
return _s
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (efs *EntityFieldSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, efs.ctx, ent.OpQuerySelect)
|
||||
if err := efs.prepareQuery(ctx); err != nil {
|
||||
func (_s *EntityFieldSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
|
||||
if err := _s.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*EntityFieldQuery, *EntityFieldSelect](ctx, efs.EntityFieldQuery, efs, efs.inters, v)
|
||||
return scanWithInterceptors[*EntityFieldQuery, *EntityFieldSelect](ctx, _s.EntityFieldQuery, _s, _s.inters, v)
|
||||
}
|
||||
|
||||
func (efs *EntityFieldSelect) sqlScan(ctx context.Context, root *EntityFieldQuery, v any) error {
|
||||
func (_s *EntityFieldSelect) sqlScan(ctx context.Context, root *EntityFieldQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx)
|
||||
aggregation := make([]string, 0, len(efs.fns))
|
||||
for _, fn := range efs.fns {
|
||||
aggregation := make([]string, 0, len(_s.fns))
|
||||
for _, fn := range _s.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
switch n := len(*efs.selector.flds); {
|
||||
switch n := len(*_s.selector.flds); {
|
||||
case n == 0 && len(aggregation) > 0:
|
||||
selector.Select(aggregation...)
|
||||
case n != 0 && len(aggregation) > 0:
|
||||
@@ -607,7 +607,7 @@ func (efs *EntityFieldSelect) sqlScan(ctx context.Context, root *EntityFieldQuer
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := efs.driver.Query(ctx, query, args, rows); err != nil {
|
||||
if err := _s.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
@@ -25,179 +25,179 @@ type EntityFieldUpdate struct {
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the EntityFieldUpdate builder.
|
||||
func (efu *EntityFieldUpdate) Where(ps ...predicate.EntityField) *EntityFieldUpdate {
|
||||
efu.mutation.Where(ps...)
|
||||
return efu
|
||||
func (_u *EntityFieldUpdate) Where(ps ...predicate.EntityField) *EntityFieldUpdate {
|
||||
_u.mutation.Where(ps...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (efu *EntityFieldUpdate) SetUpdatedAt(t time.Time) *EntityFieldUpdate {
|
||||
efu.mutation.SetUpdatedAt(t)
|
||||
return efu
|
||||
func (_u *EntityFieldUpdate) SetUpdatedAt(v time.Time) *EntityFieldUpdate {
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (efu *EntityFieldUpdate) SetName(s string) *EntityFieldUpdate {
|
||||
efu.mutation.SetName(s)
|
||||
return efu
|
||||
func (_u *EntityFieldUpdate) SetName(v string) *EntityFieldUpdate {
|
||||
_u.mutation.SetName(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableName sets the "name" field if the given value is not nil.
|
||||
func (efu *EntityFieldUpdate) SetNillableName(s *string) *EntityFieldUpdate {
|
||||
if s != nil {
|
||||
efu.SetName(*s)
|
||||
func (_u *EntityFieldUpdate) SetNillableName(v *string) *EntityFieldUpdate {
|
||||
if v != nil {
|
||||
_u.SetName(*v)
|
||||
}
|
||||
return efu
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetDescription sets the "description" field.
|
||||
func (efu *EntityFieldUpdate) SetDescription(s string) *EntityFieldUpdate {
|
||||
efu.mutation.SetDescription(s)
|
||||
return efu
|
||||
func (_u *EntityFieldUpdate) SetDescription(v string) *EntityFieldUpdate {
|
||||
_u.mutation.SetDescription(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableDescription sets the "description" field if the given value is not nil.
|
||||
func (efu *EntityFieldUpdate) SetNillableDescription(s *string) *EntityFieldUpdate {
|
||||
if s != nil {
|
||||
efu.SetDescription(*s)
|
||||
func (_u *EntityFieldUpdate) SetNillableDescription(v *string) *EntityFieldUpdate {
|
||||
if v != nil {
|
||||
_u.SetDescription(*v)
|
||||
}
|
||||
return efu
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearDescription clears the value of the "description" field.
|
||||
func (efu *EntityFieldUpdate) ClearDescription() *EntityFieldUpdate {
|
||||
efu.mutation.ClearDescription()
|
||||
return efu
|
||||
func (_u *EntityFieldUpdate) ClearDescription() *EntityFieldUpdate {
|
||||
_u.mutation.ClearDescription()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetType sets the "type" field.
|
||||
func (efu *EntityFieldUpdate) SetType(e entityfield.Type) *EntityFieldUpdate {
|
||||
efu.mutation.SetType(e)
|
||||
return efu
|
||||
func (_u *EntityFieldUpdate) SetType(v entityfield.Type) *EntityFieldUpdate {
|
||||
_u.mutation.SetType(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableType sets the "type" field if the given value is not nil.
|
||||
func (efu *EntityFieldUpdate) SetNillableType(e *entityfield.Type) *EntityFieldUpdate {
|
||||
if e != nil {
|
||||
efu.SetType(*e)
|
||||
func (_u *EntityFieldUpdate) SetNillableType(v *entityfield.Type) *EntityFieldUpdate {
|
||||
if v != nil {
|
||||
_u.SetType(*v)
|
||||
}
|
||||
return efu
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetTextValue sets the "text_value" field.
|
||||
func (efu *EntityFieldUpdate) SetTextValue(s string) *EntityFieldUpdate {
|
||||
efu.mutation.SetTextValue(s)
|
||||
return efu
|
||||
func (_u *EntityFieldUpdate) SetTextValue(v string) *EntityFieldUpdate {
|
||||
_u.mutation.SetTextValue(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableTextValue sets the "text_value" field if the given value is not nil.
|
||||
func (efu *EntityFieldUpdate) SetNillableTextValue(s *string) *EntityFieldUpdate {
|
||||
if s != nil {
|
||||
efu.SetTextValue(*s)
|
||||
func (_u *EntityFieldUpdate) SetNillableTextValue(v *string) *EntityFieldUpdate {
|
||||
if v != nil {
|
||||
_u.SetTextValue(*v)
|
||||
}
|
||||
return efu
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearTextValue clears the value of the "text_value" field.
|
||||
func (efu *EntityFieldUpdate) ClearTextValue() *EntityFieldUpdate {
|
||||
efu.mutation.ClearTextValue()
|
||||
return efu
|
||||
func (_u *EntityFieldUpdate) ClearTextValue() *EntityFieldUpdate {
|
||||
_u.mutation.ClearTextValue()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNumberValue sets the "number_value" field.
|
||||
func (efu *EntityFieldUpdate) SetNumberValue(i int) *EntityFieldUpdate {
|
||||
efu.mutation.ResetNumberValue()
|
||||
efu.mutation.SetNumberValue(i)
|
||||
return efu
|
||||
func (_u *EntityFieldUpdate) SetNumberValue(v int) *EntityFieldUpdate {
|
||||
_u.mutation.ResetNumberValue()
|
||||
_u.mutation.SetNumberValue(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableNumberValue sets the "number_value" field if the given value is not nil.
|
||||
func (efu *EntityFieldUpdate) SetNillableNumberValue(i *int) *EntityFieldUpdate {
|
||||
if i != nil {
|
||||
efu.SetNumberValue(*i)
|
||||
func (_u *EntityFieldUpdate) SetNillableNumberValue(v *int) *EntityFieldUpdate {
|
||||
if v != nil {
|
||||
_u.SetNumberValue(*v)
|
||||
}
|
||||
return efu
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddNumberValue adds i to the "number_value" field.
|
||||
func (efu *EntityFieldUpdate) AddNumberValue(i int) *EntityFieldUpdate {
|
||||
efu.mutation.AddNumberValue(i)
|
||||
return efu
|
||||
// AddNumberValue adds value to the "number_value" field.
|
||||
func (_u *EntityFieldUpdate) AddNumberValue(v int) *EntityFieldUpdate {
|
||||
_u.mutation.AddNumberValue(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearNumberValue clears the value of the "number_value" field.
|
||||
func (efu *EntityFieldUpdate) ClearNumberValue() *EntityFieldUpdate {
|
||||
efu.mutation.ClearNumberValue()
|
||||
return efu
|
||||
func (_u *EntityFieldUpdate) ClearNumberValue() *EntityFieldUpdate {
|
||||
_u.mutation.ClearNumberValue()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetBooleanValue sets the "boolean_value" field.
|
||||
func (efu *EntityFieldUpdate) SetBooleanValue(b bool) *EntityFieldUpdate {
|
||||
efu.mutation.SetBooleanValue(b)
|
||||
return efu
|
||||
func (_u *EntityFieldUpdate) SetBooleanValue(v bool) *EntityFieldUpdate {
|
||||
_u.mutation.SetBooleanValue(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableBooleanValue sets the "boolean_value" field if the given value is not nil.
|
||||
func (efu *EntityFieldUpdate) SetNillableBooleanValue(b *bool) *EntityFieldUpdate {
|
||||
if b != nil {
|
||||
efu.SetBooleanValue(*b)
|
||||
func (_u *EntityFieldUpdate) SetNillableBooleanValue(v *bool) *EntityFieldUpdate {
|
||||
if v != nil {
|
||||
_u.SetBooleanValue(*v)
|
||||
}
|
||||
return efu
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetTimeValue sets the "time_value" field.
|
||||
func (efu *EntityFieldUpdate) SetTimeValue(t time.Time) *EntityFieldUpdate {
|
||||
efu.mutation.SetTimeValue(t)
|
||||
return efu
|
||||
func (_u *EntityFieldUpdate) SetTimeValue(v time.Time) *EntityFieldUpdate {
|
||||
_u.mutation.SetTimeValue(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableTimeValue sets the "time_value" field if the given value is not nil.
|
||||
func (efu *EntityFieldUpdate) SetNillableTimeValue(t *time.Time) *EntityFieldUpdate {
|
||||
if t != nil {
|
||||
efu.SetTimeValue(*t)
|
||||
func (_u *EntityFieldUpdate) SetNillableTimeValue(v *time.Time) *EntityFieldUpdate {
|
||||
if v != nil {
|
||||
_u.SetTimeValue(*v)
|
||||
}
|
||||
return efu
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetEntityID sets the "entity" edge to the Entity entity by ID.
|
||||
func (efu *EntityFieldUpdate) SetEntityID(id uuid.UUID) *EntityFieldUpdate {
|
||||
efu.mutation.SetEntityID(id)
|
||||
return efu
|
||||
func (_u *EntityFieldUpdate) SetEntityID(id uuid.UUID) *EntityFieldUpdate {
|
||||
_u.mutation.SetEntityID(id)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableEntityID sets the "entity" edge to the Entity entity by ID if the given value is not nil.
|
||||
func (efu *EntityFieldUpdate) SetNillableEntityID(id *uuid.UUID) *EntityFieldUpdate {
|
||||
func (_u *EntityFieldUpdate) SetNillableEntityID(id *uuid.UUID) *EntityFieldUpdate {
|
||||
if id != nil {
|
||||
efu = efu.SetEntityID(*id)
|
||||
_u = _u.SetEntityID(*id)
|
||||
}
|
||||
return efu
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetEntity sets the "entity" edge to the Entity entity.
|
||||
func (efu *EntityFieldUpdate) SetEntity(e *Entity) *EntityFieldUpdate {
|
||||
return efu.SetEntityID(e.ID)
|
||||
func (_u *EntityFieldUpdate) SetEntity(v *Entity) *EntityFieldUpdate {
|
||||
return _u.SetEntityID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the EntityFieldMutation object of the builder.
|
||||
func (efu *EntityFieldUpdate) Mutation() *EntityFieldMutation {
|
||||
return efu.mutation
|
||||
func (_u *EntityFieldUpdate) Mutation() *EntityFieldMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// ClearEntity clears the "entity" edge to the Entity entity.
|
||||
func (efu *EntityFieldUpdate) ClearEntity() *EntityFieldUpdate {
|
||||
efu.mutation.ClearEntity()
|
||||
return efu
|
||||
func (_u *EntityFieldUpdate) ClearEntity() *EntityFieldUpdate {
|
||||
_u.mutation.ClearEntity()
|
||||
return _u
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (efu *EntityFieldUpdate) Save(ctx context.Context) (int, error) {
|
||||
efu.defaults()
|
||||
return withHooks(ctx, efu.sqlSave, efu.mutation, efu.hooks)
|
||||
func (_u *EntityFieldUpdate) Save(ctx context.Context) (int, error) {
|
||||
_u.defaults()
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (efu *EntityFieldUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := efu.Save(ctx)
|
||||
func (_u *EntityFieldUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -205,44 +205,44 @@ func (efu *EntityFieldUpdate) SaveX(ctx context.Context) int {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (efu *EntityFieldUpdate) Exec(ctx context.Context) error {
|
||||
_, err := efu.Save(ctx)
|
||||
func (_u *EntityFieldUpdate) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (efu *EntityFieldUpdate) ExecX(ctx context.Context) {
|
||||
if err := efu.Exec(ctx); err != nil {
|
||||
func (_u *EntityFieldUpdate) ExecX(ctx context.Context) {
|
||||
if err := _u.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (efu *EntityFieldUpdate) defaults() {
|
||||
if _, ok := efu.mutation.UpdatedAt(); !ok {
|
||||
func (_u *EntityFieldUpdate) defaults() {
|
||||
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
||||
v := entityfield.UpdateDefaultUpdatedAt()
|
||||
efu.mutation.SetUpdatedAt(v)
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (efu *EntityFieldUpdate) check() error {
|
||||
if v, ok := efu.mutation.Name(); ok {
|
||||
func (_u *EntityFieldUpdate) check() error {
|
||||
if v, ok := _u.mutation.Name(); ok {
|
||||
if err := entityfield.NameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "EntityField.name": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := efu.mutation.Description(); ok {
|
||||
if v, ok := _u.mutation.Description(); ok {
|
||||
if err := entityfield.DescriptionValidator(v); err != nil {
|
||||
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "EntityField.description": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := efu.mutation.GetType(); ok {
|
||||
if v, ok := _u.mutation.GetType(); ok {
|
||||
if err := entityfield.TypeValidator(v); err != nil {
|
||||
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "EntityField.type": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := efu.mutation.TextValue(); ok {
|
||||
if v, ok := _u.mutation.TextValue(); ok {
|
||||
if err := entityfield.TextValueValidator(v); err != nil {
|
||||
return &ValidationError{Name: "text_value", err: fmt.Errorf(`ent: validator failed for field "EntityField.text_value": %w`, err)}
|
||||
}
|
||||
@@ -250,55 +250,55 @@ func (efu *EntityFieldUpdate) check() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (efu *EntityFieldUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
if err := efu.check(); err != nil {
|
||||
return n, err
|
||||
func (_u *EntityFieldUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
if err := _u.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(entityfield.Table, entityfield.Columns, sqlgraph.NewFieldSpec(entityfield.FieldID, field.TypeUUID))
|
||||
if ps := efu.mutation.predicates; len(ps) > 0 {
|
||||
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := efu.mutation.UpdatedAt(); ok {
|
||||
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(entityfield.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := efu.mutation.Name(); ok {
|
||||
if value, ok := _u.mutation.Name(); ok {
|
||||
_spec.SetField(entityfield.FieldName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := efu.mutation.Description(); ok {
|
||||
if value, ok := _u.mutation.Description(); ok {
|
||||
_spec.SetField(entityfield.FieldDescription, field.TypeString, value)
|
||||
}
|
||||
if efu.mutation.DescriptionCleared() {
|
||||
if _u.mutation.DescriptionCleared() {
|
||||
_spec.ClearField(entityfield.FieldDescription, field.TypeString)
|
||||
}
|
||||
if value, ok := efu.mutation.GetType(); ok {
|
||||
if value, ok := _u.mutation.GetType(); ok {
|
||||
_spec.SetField(entityfield.FieldType, field.TypeEnum, value)
|
||||
}
|
||||
if value, ok := efu.mutation.TextValue(); ok {
|
||||
if value, ok := _u.mutation.TextValue(); ok {
|
||||
_spec.SetField(entityfield.FieldTextValue, field.TypeString, value)
|
||||
}
|
||||
if efu.mutation.TextValueCleared() {
|
||||
if _u.mutation.TextValueCleared() {
|
||||
_spec.ClearField(entityfield.FieldTextValue, field.TypeString)
|
||||
}
|
||||
if value, ok := efu.mutation.NumberValue(); ok {
|
||||
if value, ok := _u.mutation.NumberValue(); ok {
|
||||
_spec.SetField(entityfield.FieldNumberValue, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := efu.mutation.AddedNumberValue(); ok {
|
||||
if value, ok := _u.mutation.AddedNumberValue(); ok {
|
||||
_spec.AddField(entityfield.FieldNumberValue, field.TypeInt, value)
|
||||
}
|
||||
if efu.mutation.NumberValueCleared() {
|
||||
if _u.mutation.NumberValueCleared() {
|
||||
_spec.ClearField(entityfield.FieldNumberValue, field.TypeInt)
|
||||
}
|
||||
if value, ok := efu.mutation.BooleanValue(); ok {
|
||||
if value, ok := _u.mutation.BooleanValue(); ok {
|
||||
_spec.SetField(entityfield.FieldBooleanValue, field.TypeBool, value)
|
||||
}
|
||||
if value, ok := efu.mutation.TimeValue(); ok {
|
||||
if value, ok := _u.mutation.TimeValue(); ok {
|
||||
_spec.SetField(entityfield.FieldTimeValue, field.TypeTime, value)
|
||||
}
|
||||
if efu.mutation.EntityCleared() {
|
||||
if _u.mutation.EntityCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -311,7 +311,7 @@ func (efu *EntityFieldUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := efu.mutation.EntityIDs(); len(nodes) > 0 {
|
||||
if nodes := _u.mutation.EntityIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -327,7 +327,7 @@ func (efu *EntityFieldUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, efu.driver, _spec); err != nil {
|
||||
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{entityfield.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
@@ -335,8 +335,8 @@ func (efu *EntityFieldUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
efu.mutation.done = true
|
||||
return n, nil
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
// EntityFieldUpdateOne is the builder for updating a single EntityField entity.
|
||||
@@ -348,186 +348,186 @@ type EntityFieldUpdateOne struct {
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (efuo *EntityFieldUpdateOne) SetUpdatedAt(t time.Time) *EntityFieldUpdateOne {
|
||||
efuo.mutation.SetUpdatedAt(t)
|
||||
return efuo
|
||||
func (_u *EntityFieldUpdateOne) SetUpdatedAt(v time.Time) *EntityFieldUpdateOne {
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (efuo *EntityFieldUpdateOne) SetName(s string) *EntityFieldUpdateOne {
|
||||
efuo.mutation.SetName(s)
|
||||
return efuo
|
||||
func (_u *EntityFieldUpdateOne) SetName(v string) *EntityFieldUpdateOne {
|
||||
_u.mutation.SetName(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableName sets the "name" field if the given value is not nil.
|
||||
func (efuo *EntityFieldUpdateOne) SetNillableName(s *string) *EntityFieldUpdateOne {
|
||||
if s != nil {
|
||||
efuo.SetName(*s)
|
||||
func (_u *EntityFieldUpdateOne) SetNillableName(v *string) *EntityFieldUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetName(*v)
|
||||
}
|
||||
return efuo
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetDescription sets the "description" field.
|
||||
func (efuo *EntityFieldUpdateOne) SetDescription(s string) *EntityFieldUpdateOne {
|
||||
efuo.mutation.SetDescription(s)
|
||||
return efuo
|
||||
func (_u *EntityFieldUpdateOne) SetDescription(v string) *EntityFieldUpdateOne {
|
||||
_u.mutation.SetDescription(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableDescription sets the "description" field if the given value is not nil.
|
||||
func (efuo *EntityFieldUpdateOne) SetNillableDescription(s *string) *EntityFieldUpdateOne {
|
||||
if s != nil {
|
||||
efuo.SetDescription(*s)
|
||||
func (_u *EntityFieldUpdateOne) SetNillableDescription(v *string) *EntityFieldUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetDescription(*v)
|
||||
}
|
||||
return efuo
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearDescription clears the value of the "description" field.
|
||||
func (efuo *EntityFieldUpdateOne) ClearDescription() *EntityFieldUpdateOne {
|
||||
efuo.mutation.ClearDescription()
|
||||
return efuo
|
||||
func (_u *EntityFieldUpdateOne) ClearDescription() *EntityFieldUpdateOne {
|
||||
_u.mutation.ClearDescription()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetType sets the "type" field.
|
||||
func (efuo *EntityFieldUpdateOne) SetType(e entityfield.Type) *EntityFieldUpdateOne {
|
||||
efuo.mutation.SetType(e)
|
||||
return efuo
|
||||
func (_u *EntityFieldUpdateOne) SetType(v entityfield.Type) *EntityFieldUpdateOne {
|
||||
_u.mutation.SetType(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableType sets the "type" field if the given value is not nil.
|
||||
func (efuo *EntityFieldUpdateOne) SetNillableType(e *entityfield.Type) *EntityFieldUpdateOne {
|
||||
if e != nil {
|
||||
efuo.SetType(*e)
|
||||
func (_u *EntityFieldUpdateOne) SetNillableType(v *entityfield.Type) *EntityFieldUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetType(*v)
|
||||
}
|
||||
return efuo
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetTextValue sets the "text_value" field.
|
||||
func (efuo *EntityFieldUpdateOne) SetTextValue(s string) *EntityFieldUpdateOne {
|
||||
efuo.mutation.SetTextValue(s)
|
||||
return efuo
|
||||
func (_u *EntityFieldUpdateOne) SetTextValue(v string) *EntityFieldUpdateOne {
|
||||
_u.mutation.SetTextValue(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableTextValue sets the "text_value" field if the given value is not nil.
|
||||
func (efuo *EntityFieldUpdateOne) SetNillableTextValue(s *string) *EntityFieldUpdateOne {
|
||||
if s != nil {
|
||||
efuo.SetTextValue(*s)
|
||||
func (_u *EntityFieldUpdateOne) SetNillableTextValue(v *string) *EntityFieldUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetTextValue(*v)
|
||||
}
|
||||
return efuo
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearTextValue clears the value of the "text_value" field.
|
||||
func (efuo *EntityFieldUpdateOne) ClearTextValue() *EntityFieldUpdateOne {
|
||||
efuo.mutation.ClearTextValue()
|
||||
return efuo
|
||||
func (_u *EntityFieldUpdateOne) ClearTextValue() *EntityFieldUpdateOne {
|
||||
_u.mutation.ClearTextValue()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNumberValue sets the "number_value" field.
|
||||
func (efuo *EntityFieldUpdateOne) SetNumberValue(i int) *EntityFieldUpdateOne {
|
||||
efuo.mutation.ResetNumberValue()
|
||||
efuo.mutation.SetNumberValue(i)
|
||||
return efuo
|
||||
func (_u *EntityFieldUpdateOne) SetNumberValue(v int) *EntityFieldUpdateOne {
|
||||
_u.mutation.ResetNumberValue()
|
||||
_u.mutation.SetNumberValue(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableNumberValue sets the "number_value" field if the given value is not nil.
|
||||
func (efuo *EntityFieldUpdateOne) SetNillableNumberValue(i *int) *EntityFieldUpdateOne {
|
||||
if i != nil {
|
||||
efuo.SetNumberValue(*i)
|
||||
func (_u *EntityFieldUpdateOne) SetNillableNumberValue(v *int) *EntityFieldUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetNumberValue(*v)
|
||||
}
|
||||
return efuo
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddNumberValue adds i to the "number_value" field.
|
||||
func (efuo *EntityFieldUpdateOne) AddNumberValue(i int) *EntityFieldUpdateOne {
|
||||
efuo.mutation.AddNumberValue(i)
|
||||
return efuo
|
||||
// AddNumberValue adds value to the "number_value" field.
|
||||
func (_u *EntityFieldUpdateOne) AddNumberValue(v int) *EntityFieldUpdateOne {
|
||||
_u.mutation.AddNumberValue(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearNumberValue clears the value of the "number_value" field.
|
||||
func (efuo *EntityFieldUpdateOne) ClearNumberValue() *EntityFieldUpdateOne {
|
||||
efuo.mutation.ClearNumberValue()
|
||||
return efuo
|
||||
func (_u *EntityFieldUpdateOne) ClearNumberValue() *EntityFieldUpdateOne {
|
||||
_u.mutation.ClearNumberValue()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetBooleanValue sets the "boolean_value" field.
|
||||
func (efuo *EntityFieldUpdateOne) SetBooleanValue(b bool) *EntityFieldUpdateOne {
|
||||
efuo.mutation.SetBooleanValue(b)
|
||||
return efuo
|
||||
func (_u *EntityFieldUpdateOne) SetBooleanValue(v bool) *EntityFieldUpdateOne {
|
||||
_u.mutation.SetBooleanValue(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableBooleanValue sets the "boolean_value" field if the given value is not nil.
|
||||
func (efuo *EntityFieldUpdateOne) SetNillableBooleanValue(b *bool) *EntityFieldUpdateOne {
|
||||
if b != nil {
|
||||
efuo.SetBooleanValue(*b)
|
||||
func (_u *EntityFieldUpdateOne) SetNillableBooleanValue(v *bool) *EntityFieldUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetBooleanValue(*v)
|
||||
}
|
||||
return efuo
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetTimeValue sets the "time_value" field.
|
||||
func (efuo *EntityFieldUpdateOne) SetTimeValue(t time.Time) *EntityFieldUpdateOne {
|
||||
efuo.mutation.SetTimeValue(t)
|
||||
return efuo
|
||||
func (_u *EntityFieldUpdateOne) SetTimeValue(v time.Time) *EntityFieldUpdateOne {
|
||||
_u.mutation.SetTimeValue(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableTimeValue sets the "time_value" field if the given value is not nil.
|
||||
func (efuo *EntityFieldUpdateOne) SetNillableTimeValue(t *time.Time) *EntityFieldUpdateOne {
|
||||
if t != nil {
|
||||
efuo.SetTimeValue(*t)
|
||||
func (_u *EntityFieldUpdateOne) SetNillableTimeValue(v *time.Time) *EntityFieldUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetTimeValue(*v)
|
||||
}
|
||||
return efuo
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetEntityID sets the "entity" edge to the Entity entity by ID.
|
||||
func (efuo *EntityFieldUpdateOne) SetEntityID(id uuid.UUID) *EntityFieldUpdateOne {
|
||||
efuo.mutation.SetEntityID(id)
|
||||
return efuo
|
||||
func (_u *EntityFieldUpdateOne) SetEntityID(id uuid.UUID) *EntityFieldUpdateOne {
|
||||
_u.mutation.SetEntityID(id)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableEntityID sets the "entity" edge to the Entity entity by ID if the given value is not nil.
|
||||
func (efuo *EntityFieldUpdateOne) SetNillableEntityID(id *uuid.UUID) *EntityFieldUpdateOne {
|
||||
func (_u *EntityFieldUpdateOne) SetNillableEntityID(id *uuid.UUID) *EntityFieldUpdateOne {
|
||||
if id != nil {
|
||||
efuo = efuo.SetEntityID(*id)
|
||||
_u = _u.SetEntityID(*id)
|
||||
}
|
||||
return efuo
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetEntity sets the "entity" edge to the Entity entity.
|
||||
func (efuo *EntityFieldUpdateOne) SetEntity(e *Entity) *EntityFieldUpdateOne {
|
||||
return efuo.SetEntityID(e.ID)
|
||||
func (_u *EntityFieldUpdateOne) SetEntity(v *Entity) *EntityFieldUpdateOne {
|
||||
return _u.SetEntityID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the EntityFieldMutation object of the builder.
|
||||
func (efuo *EntityFieldUpdateOne) Mutation() *EntityFieldMutation {
|
||||
return efuo.mutation
|
||||
func (_u *EntityFieldUpdateOne) Mutation() *EntityFieldMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// ClearEntity clears the "entity" edge to the Entity entity.
|
||||
func (efuo *EntityFieldUpdateOne) ClearEntity() *EntityFieldUpdateOne {
|
||||
efuo.mutation.ClearEntity()
|
||||
return efuo
|
||||
func (_u *EntityFieldUpdateOne) ClearEntity() *EntityFieldUpdateOne {
|
||||
_u.mutation.ClearEntity()
|
||||
return _u
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the EntityFieldUpdate builder.
|
||||
func (efuo *EntityFieldUpdateOne) Where(ps ...predicate.EntityField) *EntityFieldUpdateOne {
|
||||
efuo.mutation.Where(ps...)
|
||||
return efuo
|
||||
func (_u *EntityFieldUpdateOne) Where(ps ...predicate.EntityField) *EntityFieldUpdateOne {
|
||||
_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 (efuo *EntityFieldUpdateOne) Select(field string, fields ...string) *EntityFieldUpdateOne {
|
||||
efuo.fields = append([]string{field}, fields...)
|
||||
return efuo
|
||||
func (_u *EntityFieldUpdateOne) Select(field string, fields ...string) *EntityFieldUpdateOne {
|
||||
_u.fields = append([]string{field}, fields...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated EntityField entity.
|
||||
func (efuo *EntityFieldUpdateOne) Save(ctx context.Context) (*EntityField, error) {
|
||||
efuo.defaults()
|
||||
return withHooks(ctx, efuo.sqlSave, efuo.mutation, efuo.hooks)
|
||||
func (_u *EntityFieldUpdateOne) Save(ctx context.Context) (*EntityField, error) {
|
||||
_u.defaults()
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (efuo *EntityFieldUpdateOne) SaveX(ctx context.Context) *EntityField {
|
||||
node, err := efuo.Save(ctx)
|
||||
func (_u *EntityFieldUpdateOne) SaveX(ctx context.Context) *EntityField {
|
||||
node, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -535,44 +535,44 @@ func (efuo *EntityFieldUpdateOne) SaveX(ctx context.Context) *EntityField {
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (efuo *EntityFieldUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := efuo.Save(ctx)
|
||||
func (_u *EntityFieldUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (efuo *EntityFieldUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := efuo.Exec(ctx); err != nil {
|
||||
func (_u *EntityFieldUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := _u.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (efuo *EntityFieldUpdateOne) defaults() {
|
||||
if _, ok := efuo.mutation.UpdatedAt(); !ok {
|
||||
func (_u *EntityFieldUpdateOne) defaults() {
|
||||
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
||||
v := entityfield.UpdateDefaultUpdatedAt()
|
||||
efuo.mutation.SetUpdatedAt(v)
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (efuo *EntityFieldUpdateOne) check() error {
|
||||
if v, ok := efuo.mutation.Name(); ok {
|
||||
func (_u *EntityFieldUpdateOne) check() error {
|
||||
if v, ok := _u.mutation.Name(); ok {
|
||||
if err := entityfield.NameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "EntityField.name": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := efuo.mutation.Description(); ok {
|
||||
if v, ok := _u.mutation.Description(); ok {
|
||||
if err := entityfield.DescriptionValidator(v); err != nil {
|
||||
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "EntityField.description": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := efuo.mutation.GetType(); ok {
|
||||
if v, ok := _u.mutation.GetType(); ok {
|
||||
if err := entityfield.TypeValidator(v); err != nil {
|
||||
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "EntityField.type": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := efuo.mutation.TextValue(); ok {
|
||||
if v, ok := _u.mutation.TextValue(); ok {
|
||||
if err := entityfield.TextValueValidator(v); err != nil {
|
||||
return &ValidationError{Name: "text_value", err: fmt.Errorf(`ent: validator failed for field "EntityField.text_value": %w`, err)}
|
||||
}
|
||||
@@ -580,17 +580,17 @@ func (efuo *EntityFieldUpdateOne) check() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (efuo *EntityFieldUpdateOne) sqlSave(ctx context.Context) (_node *EntityField, err error) {
|
||||
if err := efuo.check(); err != nil {
|
||||
func (_u *EntityFieldUpdateOne) sqlSave(ctx context.Context) (_node *EntityField, err error) {
|
||||
if err := _u.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(entityfield.Table, entityfield.Columns, sqlgraph.NewFieldSpec(entityfield.FieldID, field.TypeUUID))
|
||||
id, ok := efuo.mutation.ID()
|
||||
id, ok := _u.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "EntityField.id" for update`)}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
if fields := efuo.fields; len(fields) > 0 {
|
||||
if fields := _u.fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, entityfield.FieldID)
|
||||
for _, f := range fields {
|
||||
@@ -602,50 +602,50 @@ func (efuo *EntityFieldUpdateOne) sqlSave(ctx context.Context) (_node *EntityFie
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := efuo.mutation.predicates; len(ps) > 0 {
|
||||
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := efuo.mutation.UpdatedAt(); ok {
|
||||
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(entityfield.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := efuo.mutation.Name(); ok {
|
||||
if value, ok := _u.mutation.Name(); ok {
|
||||
_spec.SetField(entityfield.FieldName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := efuo.mutation.Description(); ok {
|
||||
if value, ok := _u.mutation.Description(); ok {
|
||||
_spec.SetField(entityfield.FieldDescription, field.TypeString, value)
|
||||
}
|
||||
if efuo.mutation.DescriptionCleared() {
|
||||
if _u.mutation.DescriptionCleared() {
|
||||
_spec.ClearField(entityfield.FieldDescription, field.TypeString)
|
||||
}
|
||||
if value, ok := efuo.mutation.GetType(); ok {
|
||||
if value, ok := _u.mutation.GetType(); ok {
|
||||
_spec.SetField(entityfield.FieldType, field.TypeEnum, value)
|
||||
}
|
||||
if value, ok := efuo.mutation.TextValue(); ok {
|
||||
if value, ok := _u.mutation.TextValue(); ok {
|
||||
_spec.SetField(entityfield.FieldTextValue, field.TypeString, value)
|
||||
}
|
||||
if efuo.mutation.TextValueCleared() {
|
||||
if _u.mutation.TextValueCleared() {
|
||||
_spec.ClearField(entityfield.FieldTextValue, field.TypeString)
|
||||
}
|
||||
if value, ok := efuo.mutation.NumberValue(); ok {
|
||||
if value, ok := _u.mutation.NumberValue(); ok {
|
||||
_spec.SetField(entityfield.FieldNumberValue, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := efuo.mutation.AddedNumberValue(); ok {
|
||||
if value, ok := _u.mutation.AddedNumberValue(); ok {
|
||||
_spec.AddField(entityfield.FieldNumberValue, field.TypeInt, value)
|
||||
}
|
||||
if efuo.mutation.NumberValueCleared() {
|
||||
if _u.mutation.NumberValueCleared() {
|
||||
_spec.ClearField(entityfield.FieldNumberValue, field.TypeInt)
|
||||
}
|
||||
if value, ok := efuo.mutation.BooleanValue(); ok {
|
||||
if value, ok := _u.mutation.BooleanValue(); ok {
|
||||
_spec.SetField(entityfield.FieldBooleanValue, field.TypeBool, value)
|
||||
}
|
||||
if value, ok := efuo.mutation.TimeValue(); ok {
|
||||
if value, ok := _u.mutation.TimeValue(); ok {
|
||||
_spec.SetField(entityfield.FieldTimeValue, field.TypeTime, value)
|
||||
}
|
||||
if efuo.mutation.EntityCleared() {
|
||||
if _u.mutation.EntityCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -658,7 +658,7 @@ func (efuo *EntityFieldUpdateOne) sqlSave(ctx context.Context) (_node *EntityFie
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := efuo.mutation.EntityIDs(); len(nodes) > 0 {
|
||||
if nodes := _u.mutation.EntityIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -674,10 +674,10 @@ func (efuo *EntityFieldUpdateOne) sqlSave(ctx context.Context) (_node *EntityFie
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
_node = &EntityField{config: efuo.config}
|
||||
_node = &EntityField{config: _u.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
if err = sqlgraph.UpdateNode(ctx, efuo.driver, _spec); err != nil {
|
||||
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{entityfield.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
@@ -685,6 +685,6 @@ func (efuo *EntityFieldUpdateOne) sqlSave(ctx context.Context) (_node *EntityFie
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
efuo.mutation.done = true
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ func (*EntityType) scanValues(columns []string) ([]any, error) {
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the EntityType fields.
|
||||
func (et *EntityType) assignValues(columns []string, values []any) error {
|
||||
func (_m *EntityType) assignValues(columns []string, values []any) error {
|
||||
if m, n := len(values), len(columns); m < n {
|
||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||
}
|
||||
@@ -105,59 +105,59 @@ func (et *EntityType) assignValues(columns []string, values []any) error {
|
||||
if value, ok := values[i].(*uuid.UUID); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", values[i])
|
||||
} else if value != nil {
|
||||
et.ID = *value
|
||||
_m.ID = *value
|
||||
}
|
||||
case entitytype.FieldCreatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
||||
} else if value.Valid {
|
||||
et.CreatedAt = value.Time
|
||||
_m.CreatedAt = value.Time
|
||||
}
|
||||
case entitytype.FieldUpdatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
|
||||
} else if value.Valid {
|
||||
et.UpdatedAt = value.Time
|
||||
_m.UpdatedAt = value.Time
|
||||
}
|
||||
case entitytype.FieldName:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field name", values[i])
|
||||
} else if value.Valid {
|
||||
et.Name = value.String
|
||||
_m.Name = value.String
|
||||
}
|
||||
case entitytype.FieldDescription:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field description", values[i])
|
||||
} else if value.Valid {
|
||||
et.Description = value.String
|
||||
_m.Description = value.String
|
||||
}
|
||||
case entitytype.FieldIcon:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field icon", values[i])
|
||||
} else if value.Valid {
|
||||
et.Icon = value.String
|
||||
_m.Icon = value.String
|
||||
}
|
||||
case entitytype.FieldColor:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field color", values[i])
|
||||
} else if value.Valid {
|
||||
et.Color = value.String
|
||||
_m.Color = value.String
|
||||
}
|
||||
case entitytype.FieldIsLocation:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field is_location", values[i])
|
||||
} else if value.Valid {
|
||||
et.IsLocation = value.Bool
|
||||
_m.IsLocation = value.Bool
|
||||
}
|
||||
case entitytype.ForeignKeys[0]:
|
||||
if value, ok := values[i].(*sql.NullScanner); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field group_entity_types", values[i])
|
||||
} else if value.Valid {
|
||||
et.group_entity_types = new(uuid.UUID)
|
||||
*et.group_entity_types = *value.S.(*uuid.UUID)
|
||||
_m.group_entity_types = new(uuid.UUID)
|
||||
*_m.group_entity_types = *value.S.(*uuid.UUID)
|
||||
}
|
||||
default:
|
||||
et.selectValues.Set(columns[i], values[i])
|
||||
_m.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -165,63 +165,63 @@ func (et *EntityType) assignValues(columns []string, values []any) error {
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the EntityType.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (et *EntityType) Value(name string) (ent.Value, error) {
|
||||
return et.selectValues.Get(name)
|
||||
func (_m *EntityType) Value(name string) (ent.Value, error) {
|
||||
return _m.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// QueryGroup queries the "group" edge of the EntityType entity.
|
||||
func (et *EntityType) QueryGroup() *GroupQuery {
|
||||
return NewEntityTypeClient(et.config).QueryGroup(et)
|
||||
func (_m *EntityType) QueryGroup() *GroupQuery {
|
||||
return NewEntityTypeClient(_m.config).QueryGroup(_m)
|
||||
}
|
||||
|
||||
// QueryEntities queries the "entities" edge of the EntityType entity.
|
||||
func (et *EntityType) QueryEntities() *EntityQuery {
|
||||
return NewEntityTypeClient(et.config).QueryEntities(et)
|
||||
func (_m *EntityType) QueryEntities() *EntityQuery {
|
||||
return NewEntityTypeClient(_m.config).QueryEntities(_m)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this EntityType.
|
||||
// Note that you need to call EntityType.Unwrap() before calling this method if this EntityType
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (et *EntityType) Update() *EntityTypeUpdateOne {
|
||||
return NewEntityTypeClient(et.config).UpdateOne(et)
|
||||
func (_m *EntityType) Update() *EntityTypeUpdateOne {
|
||||
return NewEntityTypeClient(_m.config).UpdateOne(_m)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the EntityType entity that was returned from a transaction after it was closed,
|
||||
// so that all future queries will be executed through the driver which created the transaction.
|
||||
func (et *EntityType) Unwrap() *EntityType {
|
||||
_tx, ok := et.config.driver.(*txDriver)
|
||||
func (_m *EntityType) Unwrap() *EntityType {
|
||||
_tx, ok := _m.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: EntityType is not a transactional entity")
|
||||
}
|
||||
et.config.driver = _tx.drv
|
||||
return et
|
||||
_m.config.driver = _tx.drv
|
||||
return _m
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (et *EntityType) String() string {
|
||||
func (_m *EntityType) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("EntityType(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", et.ID))
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||||
builder.WriteString("created_at=")
|
||||
builder.WriteString(et.CreatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("updated_at=")
|
||||
builder.WriteString(et.UpdatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("name=")
|
||||
builder.WriteString(et.Name)
|
||||
builder.WriteString(_m.Name)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("description=")
|
||||
builder.WriteString(et.Description)
|
||||
builder.WriteString(_m.Description)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("icon=")
|
||||
builder.WriteString(et.Icon)
|
||||
builder.WriteString(_m.Icon)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("color=")
|
||||
builder.WriteString(et.Color)
|
||||
builder.WriteString(_m.Color)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("is_location=")
|
||||
builder.WriteString(fmt.Sprintf("%v", et.IsLocation))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.IsLocation))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
@@ -24,149 +24,149 @@ type EntityTypeCreate struct {
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (etc *EntityTypeCreate) SetCreatedAt(t time.Time) *EntityTypeCreate {
|
||||
etc.mutation.SetCreatedAt(t)
|
||||
return etc
|
||||
func (_c *EntityTypeCreate) SetCreatedAt(v time.Time) *EntityTypeCreate {
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||
func (etc *EntityTypeCreate) SetNillableCreatedAt(t *time.Time) *EntityTypeCreate {
|
||||
if t != nil {
|
||||
etc.SetCreatedAt(*t)
|
||||
func (_c *EntityTypeCreate) SetNillableCreatedAt(v *time.Time) *EntityTypeCreate {
|
||||
if v != nil {
|
||||
_c.SetCreatedAt(*v)
|
||||
}
|
||||
return etc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (etc *EntityTypeCreate) SetUpdatedAt(t time.Time) *EntityTypeCreate {
|
||||
etc.mutation.SetUpdatedAt(t)
|
||||
return etc
|
||||
func (_c *EntityTypeCreate) SetUpdatedAt(v time.Time) *EntityTypeCreate {
|
||||
_c.mutation.SetUpdatedAt(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
||||
func (etc *EntityTypeCreate) SetNillableUpdatedAt(t *time.Time) *EntityTypeCreate {
|
||||
if t != nil {
|
||||
etc.SetUpdatedAt(*t)
|
||||
func (_c *EntityTypeCreate) SetNillableUpdatedAt(v *time.Time) *EntityTypeCreate {
|
||||
if v != nil {
|
||||
_c.SetUpdatedAt(*v)
|
||||
}
|
||||
return etc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (etc *EntityTypeCreate) SetName(s string) *EntityTypeCreate {
|
||||
etc.mutation.SetName(s)
|
||||
return etc
|
||||
func (_c *EntityTypeCreate) SetName(v string) *EntityTypeCreate {
|
||||
_c.mutation.SetName(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetDescription sets the "description" field.
|
||||
func (etc *EntityTypeCreate) SetDescription(s string) *EntityTypeCreate {
|
||||
etc.mutation.SetDescription(s)
|
||||
return etc
|
||||
func (_c *EntityTypeCreate) SetDescription(v string) *EntityTypeCreate {
|
||||
_c.mutation.SetDescription(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableDescription sets the "description" field if the given value is not nil.
|
||||
func (etc *EntityTypeCreate) SetNillableDescription(s *string) *EntityTypeCreate {
|
||||
if s != nil {
|
||||
etc.SetDescription(*s)
|
||||
func (_c *EntityTypeCreate) SetNillableDescription(v *string) *EntityTypeCreate {
|
||||
if v != nil {
|
||||
_c.SetDescription(*v)
|
||||
}
|
||||
return etc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetIcon sets the "icon" field.
|
||||
func (etc *EntityTypeCreate) SetIcon(s string) *EntityTypeCreate {
|
||||
etc.mutation.SetIcon(s)
|
||||
return etc
|
||||
func (_c *EntityTypeCreate) SetIcon(v string) *EntityTypeCreate {
|
||||
_c.mutation.SetIcon(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableIcon sets the "icon" field if the given value is not nil.
|
||||
func (etc *EntityTypeCreate) SetNillableIcon(s *string) *EntityTypeCreate {
|
||||
if s != nil {
|
||||
etc.SetIcon(*s)
|
||||
func (_c *EntityTypeCreate) SetNillableIcon(v *string) *EntityTypeCreate {
|
||||
if v != nil {
|
||||
_c.SetIcon(*v)
|
||||
}
|
||||
return etc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetColor sets the "color" field.
|
||||
func (etc *EntityTypeCreate) SetColor(s string) *EntityTypeCreate {
|
||||
etc.mutation.SetColor(s)
|
||||
return etc
|
||||
func (_c *EntityTypeCreate) SetColor(v string) *EntityTypeCreate {
|
||||
_c.mutation.SetColor(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableColor sets the "color" field if the given value is not nil.
|
||||
func (etc *EntityTypeCreate) SetNillableColor(s *string) *EntityTypeCreate {
|
||||
if s != nil {
|
||||
etc.SetColor(*s)
|
||||
func (_c *EntityTypeCreate) SetNillableColor(v *string) *EntityTypeCreate {
|
||||
if v != nil {
|
||||
_c.SetColor(*v)
|
||||
}
|
||||
return etc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetIsLocation sets the "is_location" field.
|
||||
func (etc *EntityTypeCreate) SetIsLocation(b bool) *EntityTypeCreate {
|
||||
etc.mutation.SetIsLocation(b)
|
||||
return etc
|
||||
func (_c *EntityTypeCreate) SetIsLocation(v bool) *EntityTypeCreate {
|
||||
_c.mutation.SetIsLocation(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableIsLocation sets the "is_location" field if the given value is not nil.
|
||||
func (etc *EntityTypeCreate) SetNillableIsLocation(b *bool) *EntityTypeCreate {
|
||||
if b != nil {
|
||||
etc.SetIsLocation(*b)
|
||||
func (_c *EntityTypeCreate) SetNillableIsLocation(v *bool) *EntityTypeCreate {
|
||||
if v != nil {
|
||||
_c.SetIsLocation(*v)
|
||||
}
|
||||
return etc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetID sets the "id" field.
|
||||
func (etc *EntityTypeCreate) SetID(u uuid.UUID) *EntityTypeCreate {
|
||||
etc.mutation.SetID(u)
|
||||
return etc
|
||||
func (_c *EntityTypeCreate) SetID(v uuid.UUID) *EntityTypeCreate {
|
||||
_c.mutation.SetID(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableID sets the "id" field if the given value is not nil.
|
||||
func (etc *EntityTypeCreate) SetNillableID(u *uuid.UUID) *EntityTypeCreate {
|
||||
if u != nil {
|
||||
etc.SetID(*u)
|
||||
func (_c *EntityTypeCreate) SetNillableID(v *uuid.UUID) *EntityTypeCreate {
|
||||
if v != nil {
|
||||
_c.SetID(*v)
|
||||
}
|
||||
return etc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetGroupID sets the "group" edge to the Group entity by ID.
|
||||
func (etc *EntityTypeCreate) SetGroupID(id uuid.UUID) *EntityTypeCreate {
|
||||
etc.mutation.SetGroupID(id)
|
||||
return etc
|
||||
func (_c *EntityTypeCreate) SetGroupID(id uuid.UUID) *EntityTypeCreate {
|
||||
_c.mutation.SetGroupID(id)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetGroup sets the "group" edge to the Group entity.
|
||||
func (etc *EntityTypeCreate) SetGroup(g *Group) *EntityTypeCreate {
|
||||
return etc.SetGroupID(g.ID)
|
||||
func (_c *EntityTypeCreate) SetGroup(v *Group) *EntityTypeCreate {
|
||||
return _c.SetGroupID(v.ID)
|
||||
}
|
||||
|
||||
// AddEntityIDs adds the "entities" edge to the Entity entity by IDs.
|
||||
func (etc *EntityTypeCreate) AddEntityIDs(ids ...uuid.UUID) *EntityTypeCreate {
|
||||
etc.mutation.AddEntityIDs(ids...)
|
||||
return etc
|
||||
func (_c *EntityTypeCreate) AddEntityIDs(ids ...uuid.UUID) *EntityTypeCreate {
|
||||
_c.mutation.AddEntityIDs(ids...)
|
||||
return _c
|
||||
}
|
||||
|
||||
// AddEntities adds the "entities" edges to the Entity entity.
|
||||
func (etc *EntityTypeCreate) AddEntities(e ...*Entity) *EntityTypeCreate {
|
||||
ids := make([]uuid.UUID, len(e))
|
||||
for i := range e {
|
||||
ids[i] = e[i].ID
|
||||
func (_c *EntityTypeCreate) AddEntities(v ...*Entity) *EntityTypeCreate {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return etc.AddEntityIDs(ids...)
|
||||
return _c.AddEntityIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the EntityTypeMutation object of the builder.
|
||||
func (etc *EntityTypeCreate) Mutation() *EntityTypeMutation {
|
||||
return etc.mutation
|
||||
func (_c *EntityTypeCreate) Mutation() *EntityTypeMutation {
|
||||
return _c.mutation
|
||||
}
|
||||
|
||||
// Save creates the EntityType in the database.
|
||||
func (etc *EntityTypeCreate) Save(ctx context.Context) (*EntityType, error) {
|
||||
etc.defaults()
|
||||
return withHooks(ctx, etc.sqlSave, etc.mutation, etc.hooks)
|
||||
func (_c *EntityTypeCreate) Save(ctx context.Context) (*EntityType, error) {
|
||||
_c.defaults()
|
||||
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (etc *EntityTypeCreate) SaveX(ctx context.Context) *EntityType {
|
||||
v, err := etc.Save(ctx)
|
||||
func (_c *EntityTypeCreate) SaveX(ctx context.Context) *EntityType {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -174,84 +174,84 @@ func (etc *EntityTypeCreate) SaveX(ctx context.Context) *EntityType {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (etc *EntityTypeCreate) Exec(ctx context.Context) error {
|
||||
_, err := etc.Save(ctx)
|
||||
func (_c *EntityTypeCreate) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (etc *EntityTypeCreate) ExecX(ctx context.Context) {
|
||||
if err := etc.Exec(ctx); err != nil {
|
||||
func (_c *EntityTypeCreate) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (etc *EntityTypeCreate) defaults() {
|
||||
if _, ok := etc.mutation.CreatedAt(); !ok {
|
||||
func (_c *EntityTypeCreate) defaults() {
|
||||
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||
v := entitytype.DefaultCreatedAt()
|
||||
etc.mutation.SetCreatedAt(v)
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
}
|
||||
if _, ok := etc.mutation.UpdatedAt(); !ok {
|
||||
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
||||
v := entitytype.DefaultUpdatedAt()
|
||||
etc.mutation.SetUpdatedAt(v)
|
||||
_c.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
if _, ok := etc.mutation.IsLocation(); !ok {
|
||||
if _, ok := _c.mutation.IsLocation(); !ok {
|
||||
v := entitytype.DefaultIsLocation
|
||||
etc.mutation.SetIsLocation(v)
|
||||
_c.mutation.SetIsLocation(v)
|
||||
}
|
||||
if _, ok := etc.mutation.ID(); !ok {
|
||||
if _, ok := _c.mutation.ID(); !ok {
|
||||
v := entitytype.DefaultID()
|
||||
etc.mutation.SetID(v)
|
||||
_c.mutation.SetID(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (etc *EntityTypeCreate) check() error {
|
||||
if _, ok := etc.mutation.CreatedAt(); !ok {
|
||||
func (_c *EntityTypeCreate) check() error {
|
||||
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "EntityType.created_at"`)}
|
||||
}
|
||||
if _, ok := etc.mutation.UpdatedAt(); !ok {
|
||||
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
||||
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "EntityType.updated_at"`)}
|
||||
}
|
||||
if _, ok := etc.mutation.Name(); !ok {
|
||||
if _, ok := _c.mutation.Name(); !ok {
|
||||
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "EntityType.name"`)}
|
||||
}
|
||||
if v, ok := etc.mutation.Name(); ok {
|
||||
if v, ok := _c.mutation.Name(); ok {
|
||||
if err := entitytype.NameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "EntityType.name": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := etc.mutation.Description(); ok {
|
||||
if v, ok := _c.mutation.Description(); ok {
|
||||
if err := entitytype.DescriptionValidator(v); err != nil {
|
||||
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "EntityType.description": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := etc.mutation.Icon(); ok {
|
||||
if v, ok := _c.mutation.Icon(); ok {
|
||||
if err := entitytype.IconValidator(v); err != nil {
|
||||
return &ValidationError{Name: "icon", err: fmt.Errorf(`ent: validator failed for field "EntityType.icon": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := etc.mutation.Color(); ok {
|
||||
if v, ok := _c.mutation.Color(); ok {
|
||||
if err := entitytype.ColorValidator(v); err != nil {
|
||||
return &ValidationError{Name: "color", err: fmt.Errorf(`ent: validator failed for field "EntityType.color": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := etc.mutation.IsLocation(); !ok {
|
||||
if _, ok := _c.mutation.IsLocation(); !ok {
|
||||
return &ValidationError{Name: "is_location", err: errors.New(`ent: missing required field "EntityType.is_location"`)}
|
||||
}
|
||||
if len(etc.mutation.GroupIDs()) == 0 {
|
||||
if len(_c.mutation.GroupIDs()) == 0 {
|
||||
return &ValidationError{Name: "group", err: errors.New(`ent: missing required edge "EntityType.group"`)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (etc *EntityTypeCreate) sqlSave(ctx context.Context) (*EntityType, error) {
|
||||
if err := etc.check(); err != nil {
|
||||
func (_c *EntityTypeCreate) sqlSave(ctx context.Context) (*EntityType, error) {
|
||||
if err := _c.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_node, _spec := etc.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, etc.driver, _spec); err != nil {
|
||||
_node, _spec := _c.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
@@ -264,49 +264,49 @@ func (etc *EntityTypeCreate) sqlSave(ctx context.Context) (*EntityType, error) {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
etc.mutation.id = &_node.ID
|
||||
etc.mutation.done = true
|
||||
_c.mutation.id = &_node.ID
|
||||
_c.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
func (etc *EntityTypeCreate) createSpec() (*EntityType, *sqlgraph.CreateSpec) {
|
||||
func (_c *EntityTypeCreate) createSpec() (*EntityType, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &EntityType{config: etc.config}
|
||||
_node = &EntityType{config: _c.config}
|
||||
_spec = sqlgraph.NewCreateSpec(entitytype.Table, sqlgraph.NewFieldSpec(entitytype.FieldID, field.TypeUUID))
|
||||
)
|
||||
if id, ok := etc.mutation.ID(); ok {
|
||||
if id, ok := _c.mutation.ID(); ok {
|
||||
_node.ID = id
|
||||
_spec.ID.Value = &id
|
||||
}
|
||||
if value, ok := etc.mutation.CreatedAt(); ok {
|
||||
if value, ok := _c.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(entitytype.FieldCreatedAt, field.TypeTime, value)
|
||||
_node.CreatedAt = value
|
||||
}
|
||||
if value, ok := etc.mutation.UpdatedAt(); ok {
|
||||
if value, ok := _c.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(entitytype.FieldUpdatedAt, field.TypeTime, value)
|
||||
_node.UpdatedAt = value
|
||||
}
|
||||
if value, ok := etc.mutation.Name(); ok {
|
||||
if value, ok := _c.mutation.Name(); ok {
|
||||
_spec.SetField(entitytype.FieldName, field.TypeString, value)
|
||||
_node.Name = value
|
||||
}
|
||||
if value, ok := etc.mutation.Description(); ok {
|
||||
if value, ok := _c.mutation.Description(); ok {
|
||||
_spec.SetField(entitytype.FieldDescription, field.TypeString, value)
|
||||
_node.Description = value
|
||||
}
|
||||
if value, ok := etc.mutation.Icon(); ok {
|
||||
if value, ok := _c.mutation.Icon(); ok {
|
||||
_spec.SetField(entitytype.FieldIcon, field.TypeString, value)
|
||||
_node.Icon = value
|
||||
}
|
||||
if value, ok := etc.mutation.Color(); ok {
|
||||
if value, ok := _c.mutation.Color(); ok {
|
||||
_spec.SetField(entitytype.FieldColor, field.TypeString, value)
|
||||
_node.Color = value
|
||||
}
|
||||
if value, ok := etc.mutation.IsLocation(); ok {
|
||||
if value, ok := _c.mutation.IsLocation(); ok {
|
||||
_spec.SetField(entitytype.FieldIsLocation, field.TypeBool, value)
|
||||
_node.IsLocation = value
|
||||
}
|
||||
if nodes := etc.mutation.GroupIDs(); len(nodes) > 0 {
|
||||
if nodes := _c.mutation.GroupIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -323,7 +323,7 @@ func (etc *EntityTypeCreate) createSpec() (*EntityType, *sqlgraph.CreateSpec) {
|
||||
_node.group_entity_types = &nodes[0]
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
if nodes := etc.mutation.EntitiesIDs(); len(nodes) > 0 {
|
||||
if nodes := _c.mutation.EntitiesIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
@@ -350,16 +350,16 @@ type EntityTypeCreateBulk struct {
|
||||
}
|
||||
|
||||
// Save creates the EntityType entities in the database.
|
||||
func (etcb *EntityTypeCreateBulk) Save(ctx context.Context) ([]*EntityType, error) {
|
||||
if etcb.err != nil {
|
||||
return nil, etcb.err
|
||||
func (_c *EntityTypeCreateBulk) Save(ctx context.Context) ([]*EntityType, error) {
|
||||
if _c.err != nil {
|
||||
return nil, _c.err
|
||||
}
|
||||
specs := make([]*sqlgraph.CreateSpec, len(etcb.builders))
|
||||
nodes := make([]*EntityType, len(etcb.builders))
|
||||
mutators := make([]Mutator, len(etcb.builders))
|
||||
for i := range etcb.builders {
|
||||
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
||||
nodes := make([]*EntityType, len(_c.builders))
|
||||
mutators := make([]Mutator, len(_c.builders))
|
||||
for i := range _c.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := etcb.builders[i]
|
||||
builder := _c.builders[i]
|
||||
builder.defaults()
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*EntityTypeMutation)
|
||||
@@ -373,11 +373,11 @@ func (etcb *EntityTypeCreateBulk) Save(ctx context.Context) ([]*EntityType, erro
|
||||
var err error
|
||||
nodes[i], specs[i] = builder.createSpec()
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, etcb.builders[i+1].mutation)
|
||||
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
|
||||
} else {
|
||||
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
||||
// Invoke the actual operation on the latest mutation in the chain.
|
||||
if err = sqlgraph.BatchCreate(ctx, etcb.driver, spec); err != nil {
|
||||
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
@@ -397,7 +397,7 @@ func (etcb *EntityTypeCreateBulk) Save(ctx context.Context) ([]*EntityType, erro
|
||||
}(i, ctx)
|
||||
}
|
||||
if len(mutators) > 0 {
|
||||
if _, err := mutators[0].Mutate(ctx, etcb.builders[0].mutation); err != nil {
|
||||
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
@@ -405,8 +405,8 @@ func (etcb *EntityTypeCreateBulk) Save(ctx context.Context) ([]*EntityType, erro
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (etcb *EntityTypeCreateBulk) SaveX(ctx context.Context) []*EntityType {
|
||||
v, err := etcb.Save(ctx)
|
||||
func (_c *EntityTypeCreateBulk) SaveX(ctx context.Context) []*EntityType {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -414,14 +414,14 @@ func (etcb *EntityTypeCreateBulk) SaveX(ctx context.Context) []*EntityType {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (etcb *EntityTypeCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := etcb.Save(ctx)
|
||||
func (_c *EntityTypeCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (etcb *EntityTypeCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := etcb.Exec(ctx); err != nil {
|
||||
func (_c *EntityTypeCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,56 +20,56 @@ type EntityTypeDelete struct {
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the EntityTypeDelete builder.
|
||||
func (etd *EntityTypeDelete) Where(ps ...predicate.EntityType) *EntityTypeDelete {
|
||||
etd.mutation.Where(ps...)
|
||||
return etd
|
||||
func (_d *EntityTypeDelete) Where(ps ...predicate.EntityType) *EntityTypeDelete {
|
||||
_d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (etd *EntityTypeDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, etd.sqlExec, etd.mutation, etd.hooks)
|
||||
func (_d *EntityTypeDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (etd *EntityTypeDelete) ExecX(ctx context.Context) int {
|
||||
n, err := etd.Exec(ctx)
|
||||
func (_d *EntityTypeDelete) ExecX(ctx context.Context) int {
|
||||
n, err := _d.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (etd *EntityTypeDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
func (_d *EntityTypeDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := sqlgraph.NewDeleteSpec(entitytype.Table, sqlgraph.NewFieldSpec(entitytype.FieldID, field.TypeUUID))
|
||||
if ps := etd.mutation.predicates; len(ps) > 0 {
|
||||
if ps := _d.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, etd.driver, _spec)
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec)
|
||||
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
etd.mutation.done = true
|
||||
_d.mutation.done = true
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// EntityTypeDeleteOne is the builder for deleting a single EntityType entity.
|
||||
type EntityTypeDeleteOne struct {
|
||||
etd *EntityTypeDelete
|
||||
_d *EntityTypeDelete
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the EntityTypeDelete builder.
|
||||
func (etdo *EntityTypeDeleteOne) Where(ps ...predicate.EntityType) *EntityTypeDeleteOne {
|
||||
etdo.etd.mutation.Where(ps...)
|
||||
return etdo
|
||||
func (_d *EntityTypeDeleteOne) Where(ps ...predicate.EntityType) *EntityTypeDeleteOne {
|
||||
_d._d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (etdo *EntityTypeDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := etdo.etd.Exec(ctx)
|
||||
func (_d *EntityTypeDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := _d._d.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
@@ -81,8 +81,8 @@ func (etdo *EntityTypeDeleteOne) Exec(ctx context.Context) error {
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (etdo *EntityTypeDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := etdo.Exec(ctx); err != nil {
|
||||
func (_d *EntityTypeDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := _d.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,44 +35,44 @@ type EntityTypeQuery struct {
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the EntityTypeQuery builder.
|
||||
func (etq *EntityTypeQuery) Where(ps ...predicate.EntityType) *EntityTypeQuery {
|
||||
etq.predicates = append(etq.predicates, ps...)
|
||||
return etq
|
||||
func (_q *EntityTypeQuery) Where(ps ...predicate.EntityType) *EntityTypeQuery {
|
||||
_q.predicates = append(_q.predicates, ps...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// Limit the number of records to be returned by this query.
|
||||
func (etq *EntityTypeQuery) Limit(limit int) *EntityTypeQuery {
|
||||
etq.ctx.Limit = &limit
|
||||
return etq
|
||||
func (_q *EntityTypeQuery) Limit(limit int) *EntityTypeQuery {
|
||||
_q.ctx.Limit = &limit
|
||||
return _q
|
||||
}
|
||||
|
||||
// Offset to start from.
|
||||
func (etq *EntityTypeQuery) Offset(offset int) *EntityTypeQuery {
|
||||
etq.ctx.Offset = &offset
|
||||
return etq
|
||||
func (_q *EntityTypeQuery) Offset(offset int) *EntityTypeQuery {
|
||||
_q.ctx.Offset = &offset
|
||||
return _q
|
||||
}
|
||||
|
||||
// Unique configures the query builder to filter duplicate records on query.
|
||||
// By default, unique is set to true, and can be disabled using this method.
|
||||
func (etq *EntityTypeQuery) Unique(unique bool) *EntityTypeQuery {
|
||||
etq.ctx.Unique = &unique
|
||||
return etq
|
||||
func (_q *EntityTypeQuery) Unique(unique bool) *EntityTypeQuery {
|
||||
_q.ctx.Unique = &unique
|
||||
return _q
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (etq *EntityTypeQuery) Order(o ...entitytype.OrderOption) *EntityTypeQuery {
|
||||
etq.order = append(etq.order, o...)
|
||||
return etq
|
||||
func (_q *EntityTypeQuery) Order(o ...entitytype.OrderOption) *EntityTypeQuery {
|
||||
_q.order = append(_q.order, o...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// QueryGroup chains the current query on the "group" edge.
|
||||
func (etq *EntityTypeQuery) QueryGroup() *GroupQuery {
|
||||
query := (&GroupClient{config: etq.config}).Query()
|
||||
func (_q *EntityTypeQuery) QueryGroup() *GroupQuery {
|
||||
query := (&GroupClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := etq.prepareQuery(ctx); err != nil {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := etq.sqlQuery(ctx)
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -81,20 +81,20 @@ func (etq *EntityTypeQuery) QueryGroup() *GroupQuery {
|
||||
sqlgraph.To(group.Table, group.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, entitytype.GroupTable, entitytype.GroupColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(etq.driver.Dialect(), step)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryEntities chains the current query on the "entities" edge.
|
||||
func (etq *EntityTypeQuery) QueryEntities() *EntityQuery {
|
||||
query := (&EntityClient{config: etq.config}).Query()
|
||||
func (_q *EntityTypeQuery) QueryEntities() *EntityQuery {
|
||||
query := (&EntityClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := etq.prepareQuery(ctx); err != nil {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := etq.sqlQuery(ctx)
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -103,7 +103,7 @@ func (etq *EntityTypeQuery) QueryEntities() *EntityQuery {
|
||||
sqlgraph.To(entity.Table, entity.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, entitytype.EntitiesTable, entitytype.EntitiesColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(etq.driver.Dialect(), step)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
@@ -111,8 +111,8 @@ func (etq *EntityTypeQuery) QueryEntities() *EntityQuery {
|
||||
|
||||
// First returns the first EntityType entity from the query.
|
||||
// Returns a *NotFoundError when no EntityType was found.
|
||||
func (etq *EntityTypeQuery) First(ctx context.Context) (*EntityType, error) {
|
||||
nodes, err := etq.Limit(1).All(setContextOp(ctx, etq.ctx, ent.OpQueryFirst))
|
||||
func (_q *EntityTypeQuery) First(ctx context.Context) (*EntityType, error) {
|
||||
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -123,8 +123,8 @@ func (etq *EntityTypeQuery) First(ctx context.Context) (*EntityType, error) {
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (etq *EntityTypeQuery) FirstX(ctx context.Context) *EntityType {
|
||||
node, err := etq.First(ctx)
|
||||
func (_q *EntityTypeQuery) FirstX(ctx context.Context) *EntityType {
|
||||
node, err := _q.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
@@ -133,9 +133,9 @@ func (etq *EntityTypeQuery) FirstX(ctx context.Context) *EntityType {
|
||||
|
||||
// FirstID returns the first EntityType ID from the query.
|
||||
// Returns a *NotFoundError when no EntityType ID was found.
|
||||
func (etq *EntityTypeQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
func (_q *EntityTypeQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
var ids []uuid.UUID
|
||||
if ids, err = etq.Limit(1).IDs(setContextOp(ctx, etq.ctx, ent.OpQueryFirstID)); err != nil {
|
||||
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
@@ -146,8 +146,8 @@ func (etq *EntityTypeQuery) FirstID(ctx context.Context) (id uuid.UUID, err erro
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (etq *EntityTypeQuery) FirstIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := etq.FirstID(ctx)
|
||||
func (_q *EntityTypeQuery) FirstIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := _q.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
@@ -157,8 +157,8 @@ func (etq *EntityTypeQuery) FirstIDX(ctx context.Context) uuid.UUID {
|
||||
// Only returns a single EntityType entity found by the query, ensuring it only returns one.
|
||||
// Returns a *NotSingularError when more than one EntityType entity is found.
|
||||
// Returns a *NotFoundError when no EntityType entities are found.
|
||||
func (etq *EntityTypeQuery) Only(ctx context.Context) (*EntityType, error) {
|
||||
nodes, err := etq.Limit(2).All(setContextOp(ctx, etq.ctx, ent.OpQueryOnly))
|
||||
func (_q *EntityTypeQuery) Only(ctx context.Context) (*EntityType, error) {
|
||||
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -173,8 +173,8 @@ func (etq *EntityTypeQuery) Only(ctx context.Context) (*EntityType, error) {
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (etq *EntityTypeQuery) OnlyX(ctx context.Context) *EntityType {
|
||||
node, err := etq.Only(ctx)
|
||||
func (_q *EntityTypeQuery) OnlyX(ctx context.Context) *EntityType {
|
||||
node, err := _q.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -184,9 +184,9 @@ func (etq *EntityTypeQuery) OnlyX(ctx context.Context) *EntityType {
|
||||
// OnlyID is like Only, but returns the only EntityType ID in the query.
|
||||
// Returns a *NotSingularError when more than one EntityType ID is found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (etq *EntityTypeQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
func (_q *EntityTypeQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
var ids []uuid.UUID
|
||||
if ids, err = etq.Limit(2).IDs(setContextOp(ctx, etq.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
@@ -201,8 +201,8 @@ func (etq *EntityTypeQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (etq *EntityTypeQuery) OnlyIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := etq.OnlyID(ctx)
|
||||
func (_q *EntityTypeQuery) OnlyIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := _q.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -210,18 +210,18 @@ func (etq *EntityTypeQuery) OnlyIDX(ctx context.Context) uuid.UUID {
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of EntityTypes.
|
||||
func (etq *EntityTypeQuery) All(ctx context.Context) ([]*EntityType, error) {
|
||||
ctx = setContextOp(ctx, etq.ctx, ent.OpQueryAll)
|
||||
if err := etq.prepareQuery(ctx); err != nil {
|
||||
func (_q *EntityTypeQuery) All(ctx context.Context) ([]*EntityType, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qr := querierAll[[]*EntityType, *EntityTypeQuery]()
|
||||
return withInterceptors[[]*EntityType](ctx, etq, qr, etq.inters)
|
||||
return withInterceptors[[]*EntityType](ctx, _q, qr, _q.inters)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (etq *EntityTypeQuery) AllX(ctx context.Context) []*EntityType {
|
||||
nodes, err := etq.All(ctx)
|
||||
func (_q *EntityTypeQuery) AllX(ctx context.Context) []*EntityType {
|
||||
nodes, err := _q.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -229,20 +229,20 @@ func (etq *EntityTypeQuery) AllX(ctx context.Context) []*EntityType {
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of EntityType IDs.
|
||||
func (etq *EntityTypeQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
|
||||
if etq.ctx.Unique == nil && etq.path != nil {
|
||||
etq.Unique(true)
|
||||
func (_q *EntityTypeQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
|
||||
if _q.ctx.Unique == nil && _q.path != nil {
|
||||
_q.Unique(true)
|
||||
}
|
||||
ctx = setContextOp(ctx, etq.ctx, ent.OpQueryIDs)
|
||||
if err = etq.Select(entitytype.FieldID).Scan(ctx, &ids); err != nil {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
|
||||
if err = _q.Select(entitytype.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (etq *EntityTypeQuery) IDsX(ctx context.Context) []uuid.UUID {
|
||||
ids, err := etq.IDs(ctx)
|
||||
func (_q *EntityTypeQuery) IDsX(ctx context.Context) []uuid.UUID {
|
||||
ids, err := _q.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -250,17 +250,17 @@ func (etq *EntityTypeQuery) IDsX(ctx context.Context) []uuid.UUID {
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (etq *EntityTypeQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, etq.ctx, ent.OpQueryCount)
|
||||
if err := etq.prepareQuery(ctx); err != nil {
|
||||
func (_q *EntityTypeQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return withInterceptors[int](ctx, etq, querierCount[*EntityTypeQuery](), etq.inters)
|
||||
return withInterceptors[int](ctx, _q, querierCount[*EntityTypeQuery](), _q.inters)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (etq *EntityTypeQuery) CountX(ctx context.Context) int {
|
||||
count, err := etq.Count(ctx)
|
||||
func (_q *EntityTypeQuery) CountX(ctx context.Context) int {
|
||||
count, err := _q.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -268,9 +268,9 @@ func (etq *EntityTypeQuery) CountX(ctx context.Context) int {
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (etq *EntityTypeQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, etq.ctx, ent.OpQueryExist)
|
||||
switch _, err := etq.FirstID(ctx); {
|
||||
func (_q *EntityTypeQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
|
||||
switch _, err := _q.FirstID(ctx); {
|
||||
case IsNotFound(err):
|
||||
return false, nil
|
||||
case err != nil:
|
||||
@@ -281,8 +281,8 @@ func (etq *EntityTypeQuery) Exist(ctx context.Context) (bool, error) {
|
||||
}
|
||||
|
||||
// ExistX is like Exist, but panics if an error occurs.
|
||||
func (etq *EntityTypeQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := etq.Exist(ctx)
|
||||
func (_q *EntityTypeQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := _q.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -291,44 +291,44 @@ func (etq *EntityTypeQuery) ExistX(ctx context.Context) bool {
|
||||
|
||||
// Clone returns a duplicate of the EntityTypeQuery builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (etq *EntityTypeQuery) Clone() *EntityTypeQuery {
|
||||
if etq == nil {
|
||||
func (_q *EntityTypeQuery) Clone() *EntityTypeQuery {
|
||||
if _q == nil {
|
||||
return nil
|
||||
}
|
||||
return &EntityTypeQuery{
|
||||
config: etq.config,
|
||||
ctx: etq.ctx.Clone(),
|
||||
order: append([]entitytype.OrderOption{}, etq.order...),
|
||||
inters: append([]Interceptor{}, etq.inters...),
|
||||
predicates: append([]predicate.EntityType{}, etq.predicates...),
|
||||
withGroup: etq.withGroup.Clone(),
|
||||
withEntities: etq.withEntities.Clone(),
|
||||
config: _q.config,
|
||||
ctx: _q.ctx.Clone(),
|
||||
order: append([]entitytype.OrderOption{}, _q.order...),
|
||||
inters: append([]Interceptor{}, _q.inters...),
|
||||
predicates: append([]predicate.EntityType{}, _q.predicates...),
|
||||
withGroup: _q.withGroup.Clone(),
|
||||
withEntities: _q.withEntities.Clone(),
|
||||
// clone intermediate query.
|
||||
sql: etq.sql.Clone(),
|
||||
path: etq.path,
|
||||
sql: _q.sql.Clone(),
|
||||
path: _q.path,
|
||||
}
|
||||
}
|
||||
|
||||
// WithGroup tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "group" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (etq *EntityTypeQuery) WithGroup(opts ...func(*GroupQuery)) *EntityTypeQuery {
|
||||
query := (&GroupClient{config: etq.config}).Query()
|
||||
func (_q *EntityTypeQuery) WithGroup(opts ...func(*GroupQuery)) *EntityTypeQuery {
|
||||
query := (&GroupClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
etq.withGroup = query
|
||||
return etq
|
||||
_q.withGroup = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// WithEntities tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "entities" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (etq *EntityTypeQuery) WithEntities(opts ...func(*EntityQuery)) *EntityTypeQuery {
|
||||
query := (&EntityClient{config: etq.config}).Query()
|
||||
func (_q *EntityTypeQuery) WithEntities(opts ...func(*EntityQuery)) *EntityTypeQuery {
|
||||
query := (&EntityClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
etq.withEntities = query
|
||||
return etq
|
||||
_q.withEntities = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// GroupBy is used to group vertices by one or more fields/columns.
|
||||
@@ -345,10 +345,10 @@ func (etq *EntityTypeQuery) WithEntities(opts ...func(*EntityQuery)) *EntityType
|
||||
// GroupBy(entitytype.FieldCreatedAt).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (etq *EntityTypeQuery) GroupBy(field string, fields ...string) *EntityTypeGroupBy {
|
||||
etq.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &EntityTypeGroupBy{build: etq}
|
||||
grbuild.flds = &etq.ctx.Fields
|
||||
func (_q *EntityTypeQuery) GroupBy(field string, fields ...string) *EntityTypeGroupBy {
|
||||
_q.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &EntityTypeGroupBy{build: _q}
|
||||
grbuild.flds = &_q.ctx.Fields
|
||||
grbuild.label = entitytype.Label
|
||||
grbuild.scan = grbuild.Scan
|
||||
return grbuild
|
||||
@@ -366,56 +366,56 @@ func (etq *EntityTypeQuery) GroupBy(field string, fields ...string) *EntityTypeG
|
||||
// client.EntityType.Query().
|
||||
// Select(entitytype.FieldCreatedAt).
|
||||
// Scan(ctx, &v)
|
||||
func (etq *EntityTypeQuery) Select(fields ...string) *EntityTypeSelect {
|
||||
etq.ctx.Fields = append(etq.ctx.Fields, fields...)
|
||||
sbuild := &EntityTypeSelect{EntityTypeQuery: etq}
|
||||
func (_q *EntityTypeQuery) Select(fields ...string) *EntityTypeSelect {
|
||||
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
||||
sbuild := &EntityTypeSelect{EntityTypeQuery: _q}
|
||||
sbuild.label = entitytype.Label
|
||||
sbuild.flds, sbuild.scan = &etq.ctx.Fields, sbuild.Scan
|
||||
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
|
||||
return sbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a EntityTypeSelect configured with the given aggregations.
|
||||
func (etq *EntityTypeQuery) Aggregate(fns ...AggregateFunc) *EntityTypeSelect {
|
||||
return etq.Select().Aggregate(fns...)
|
||||
func (_q *EntityTypeQuery) Aggregate(fns ...AggregateFunc) *EntityTypeSelect {
|
||||
return _q.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (etq *EntityTypeQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range etq.inters {
|
||||
func (_q *EntityTypeQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range _q.inters {
|
||||
if inter == nil {
|
||||
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
|
||||
}
|
||||
if trv, ok := inter.(Traverser); ok {
|
||||
if err := trv.Traverse(ctx, etq); err != nil {
|
||||
if err := trv.Traverse(ctx, _q); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, f := range etq.ctx.Fields {
|
||||
for _, f := range _q.ctx.Fields {
|
||||
if !entitytype.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
}
|
||||
if etq.path != nil {
|
||||
prev, err := etq.path(ctx)
|
||||
if _q.path != nil {
|
||||
prev, err := _q.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
etq.sql = prev
|
||||
_q.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (etq *EntityTypeQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*EntityType, error) {
|
||||
func (_q *EntityTypeQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*EntityType, error) {
|
||||
var (
|
||||
nodes = []*EntityType{}
|
||||
withFKs = etq.withFKs
|
||||
_spec = etq.querySpec()
|
||||
withFKs = _q.withFKs
|
||||
_spec = _q.querySpec()
|
||||
loadedTypes = [2]bool{
|
||||
etq.withGroup != nil,
|
||||
etq.withEntities != nil,
|
||||
_q.withGroup != nil,
|
||||
_q.withEntities != nil,
|
||||
}
|
||||
)
|
||||
if etq.withGroup != nil {
|
||||
if _q.withGroup != nil {
|
||||
withFKs = true
|
||||
}
|
||||
if withFKs {
|
||||
@@ -425,7 +425,7 @@ func (etq *EntityTypeQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*
|
||||
return (*EntityType).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &EntityType{config: etq.config}
|
||||
node := &EntityType{config: _q.config}
|
||||
nodes = append(nodes, node)
|
||||
node.Edges.loadedTypes = loadedTypes
|
||||
return node.assignValues(columns, values)
|
||||
@@ -433,20 +433,20 @@ func (etq *EntityTypeQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*
|
||||
for i := range hooks {
|
||||
hooks[i](ctx, _spec)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, etq.driver, _spec); err != nil {
|
||||
if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
if query := etq.withGroup; query != nil {
|
||||
if err := etq.loadGroup(ctx, query, nodes, nil,
|
||||
if query := _q.withGroup; query != nil {
|
||||
if err := _q.loadGroup(ctx, query, nodes, nil,
|
||||
func(n *EntityType, e *Group) { n.Edges.Group = e }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if query := etq.withEntities; query != nil {
|
||||
if err := etq.loadEntities(ctx, query, nodes,
|
||||
if query := _q.withEntities; query != nil {
|
||||
if err := _q.loadEntities(ctx, query, nodes,
|
||||
func(n *EntityType) { n.Edges.Entities = []*Entity{} },
|
||||
func(n *EntityType, e *Entity) { n.Edges.Entities = append(n.Edges.Entities, e) }); err != nil {
|
||||
return nil, err
|
||||
@@ -455,7 +455,7 @@ func (etq *EntityTypeQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (etq *EntityTypeQuery) loadGroup(ctx context.Context, query *GroupQuery, nodes []*EntityType, init func(*EntityType), assign func(*EntityType, *Group)) error {
|
||||
func (_q *EntityTypeQuery) loadGroup(ctx context.Context, query *GroupQuery, nodes []*EntityType, init func(*EntityType), assign func(*EntityType, *Group)) error {
|
||||
ids := make([]uuid.UUID, 0, len(nodes))
|
||||
nodeids := make(map[uuid.UUID][]*EntityType)
|
||||
for i := range nodes {
|
||||
@@ -487,7 +487,7 @@ func (etq *EntityTypeQuery) loadGroup(ctx context.Context, query *GroupQuery, no
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (etq *EntityTypeQuery) loadEntities(ctx context.Context, query *EntityQuery, nodes []*EntityType, init func(*EntityType), assign func(*EntityType, *Entity)) error {
|
||||
func (_q *EntityTypeQuery) loadEntities(ctx context.Context, query *EntityQuery, nodes []*EntityType, init func(*EntityType), assign func(*EntityType, *Entity)) error {
|
||||
fks := make([]driver.Value, 0, len(nodes))
|
||||
nodeids := make(map[uuid.UUID]*EntityType)
|
||||
for i := range nodes {
|
||||
@@ -519,24 +519,24 @@ func (etq *EntityTypeQuery) loadEntities(ctx context.Context, query *EntityQuery
|
||||
return nil
|
||||
}
|
||||
|
||||
func (etq *EntityTypeQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := etq.querySpec()
|
||||
_spec.Node.Columns = etq.ctx.Fields
|
||||
if len(etq.ctx.Fields) > 0 {
|
||||
_spec.Unique = etq.ctx.Unique != nil && *etq.ctx.Unique
|
||||
func (_q *EntityTypeQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := _q.querySpec()
|
||||
_spec.Node.Columns = _q.ctx.Fields
|
||||
if len(_q.ctx.Fields) > 0 {
|
||||
_spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, etq.driver, _spec)
|
||||
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
|
||||
}
|
||||
|
||||
func (etq *EntityTypeQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
func (_q *EntityTypeQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := sqlgraph.NewQuerySpec(entitytype.Table, entitytype.Columns, sqlgraph.NewFieldSpec(entitytype.FieldID, field.TypeUUID))
|
||||
_spec.From = etq.sql
|
||||
if unique := etq.ctx.Unique; unique != nil {
|
||||
_spec.From = _q.sql
|
||||
if unique := _q.ctx.Unique; unique != nil {
|
||||
_spec.Unique = *unique
|
||||
} else if etq.path != nil {
|
||||
} else if _q.path != nil {
|
||||
_spec.Unique = true
|
||||
}
|
||||
if fields := etq.ctx.Fields; len(fields) > 0 {
|
||||
if fields := _q.ctx.Fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, entitytype.FieldID)
|
||||
for i := range fields {
|
||||
@@ -545,20 +545,20 @@ func (etq *EntityTypeQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := etq.predicates; len(ps) > 0 {
|
||||
if ps := _q.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := etq.ctx.Limit; limit != nil {
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := etq.ctx.Offset; offset != nil {
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := etq.order; len(ps) > 0 {
|
||||
if ps := _q.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
@@ -568,33 +568,33 @@ func (etq *EntityTypeQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (etq *EntityTypeQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(etq.driver.Dialect())
|
||||
func (_q *EntityTypeQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(_q.driver.Dialect())
|
||||
t1 := builder.Table(entitytype.Table)
|
||||
columns := etq.ctx.Fields
|
||||
columns := _q.ctx.Fields
|
||||
if len(columns) == 0 {
|
||||
columns = entitytype.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if etq.sql != nil {
|
||||
selector = etq.sql
|
||||
if _q.sql != nil {
|
||||
selector = _q.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
if etq.ctx.Unique != nil && *etq.ctx.Unique {
|
||||
if _q.ctx.Unique != nil && *_q.ctx.Unique {
|
||||
selector.Distinct()
|
||||
}
|
||||
for _, p := range etq.predicates {
|
||||
for _, p := range _q.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range etq.order {
|
||||
for _, p := range _q.order {
|
||||
p(selector)
|
||||
}
|
||||
if offset := etq.ctx.Offset; offset != nil {
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
// limit is mandatory for offset clause. We start
|
||||
// with default value, and override it below if needed.
|
||||
selector.Offset(*offset).Limit(math.MaxInt32)
|
||||
}
|
||||
if limit := etq.ctx.Limit; limit != nil {
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
@@ -607,41 +607,41 @@ type EntityTypeGroupBy struct {
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (etgb *EntityTypeGroupBy) Aggregate(fns ...AggregateFunc) *EntityTypeGroupBy {
|
||||
etgb.fns = append(etgb.fns, fns...)
|
||||
return etgb
|
||||
func (_g *EntityTypeGroupBy) Aggregate(fns ...AggregateFunc) *EntityTypeGroupBy {
|
||||
_g.fns = append(_g.fns, fns...)
|
||||
return _g
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (etgb *EntityTypeGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, etgb.build.ctx, ent.OpQueryGroupBy)
|
||||
if err := etgb.build.prepareQuery(ctx); err != nil {
|
||||
func (_g *EntityTypeGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
|
||||
if err := _g.build.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*EntityTypeQuery, *EntityTypeGroupBy](ctx, etgb.build, etgb, etgb.build.inters, v)
|
||||
return scanWithInterceptors[*EntityTypeQuery, *EntityTypeGroupBy](ctx, _g.build, _g, _g.build.inters, v)
|
||||
}
|
||||
|
||||
func (etgb *EntityTypeGroupBy) sqlScan(ctx context.Context, root *EntityTypeQuery, v any) error {
|
||||
func (_g *EntityTypeGroupBy) sqlScan(ctx context.Context, root *EntityTypeQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx).Select()
|
||||
aggregation := make([]string, 0, len(etgb.fns))
|
||||
for _, fn := range etgb.fns {
|
||||
aggregation := make([]string, 0, len(_g.fns))
|
||||
for _, fn := range _g.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(*etgb.flds)+len(etgb.fns))
|
||||
for _, f := range *etgb.flds {
|
||||
columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
|
||||
for _, f := range *_g.flds {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
columns = append(columns, aggregation...)
|
||||
selector.Select(columns...)
|
||||
}
|
||||
selector.GroupBy(selector.Columns(*etgb.flds...)...)
|
||||
selector.GroupBy(selector.Columns(*_g.flds...)...)
|
||||
if err := selector.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := etgb.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
@@ -655,27 +655,27 @@ type EntityTypeSelect struct {
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (ets *EntityTypeSelect) Aggregate(fns ...AggregateFunc) *EntityTypeSelect {
|
||||
ets.fns = append(ets.fns, fns...)
|
||||
return ets
|
||||
func (_s *EntityTypeSelect) Aggregate(fns ...AggregateFunc) *EntityTypeSelect {
|
||||
_s.fns = append(_s.fns, fns...)
|
||||
return _s
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (ets *EntityTypeSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, ets.ctx, ent.OpQuerySelect)
|
||||
if err := ets.prepareQuery(ctx); err != nil {
|
||||
func (_s *EntityTypeSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
|
||||
if err := _s.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*EntityTypeQuery, *EntityTypeSelect](ctx, ets.EntityTypeQuery, ets, ets.inters, v)
|
||||
return scanWithInterceptors[*EntityTypeQuery, *EntityTypeSelect](ctx, _s.EntityTypeQuery, _s, _s.inters, v)
|
||||
}
|
||||
|
||||
func (ets *EntityTypeSelect) sqlScan(ctx context.Context, root *EntityTypeQuery, v any) error {
|
||||
func (_s *EntityTypeSelect) sqlScan(ctx context.Context, root *EntityTypeQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx)
|
||||
aggregation := make([]string, 0, len(ets.fns))
|
||||
for _, fn := range ets.fns {
|
||||
aggregation := make([]string, 0, len(_s.fns))
|
||||
for _, fn := range _s.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
switch n := len(*ets.selector.flds); {
|
||||
switch n := len(*_s.selector.flds); {
|
||||
case n == 0 && len(aggregation) > 0:
|
||||
selector.Select(aggregation...)
|
||||
case n != 0 && len(aggregation) > 0:
|
||||
@@ -683,7 +683,7 @@ func (ets *EntityTypeSelect) sqlScan(ctx context.Context, root *EntityTypeQuery,
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := ets.driver.Query(ctx, query, args, rows); err != nil {
|
||||
if err := _s.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
@@ -26,172 +26,172 @@ type EntityTypeUpdate struct {
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the EntityTypeUpdate builder.
|
||||
func (etu *EntityTypeUpdate) Where(ps ...predicate.EntityType) *EntityTypeUpdate {
|
||||
etu.mutation.Where(ps...)
|
||||
return etu
|
||||
func (_u *EntityTypeUpdate) Where(ps ...predicate.EntityType) *EntityTypeUpdate {
|
||||
_u.mutation.Where(ps...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (etu *EntityTypeUpdate) SetUpdatedAt(t time.Time) *EntityTypeUpdate {
|
||||
etu.mutation.SetUpdatedAt(t)
|
||||
return etu
|
||||
func (_u *EntityTypeUpdate) SetUpdatedAt(v time.Time) *EntityTypeUpdate {
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (etu *EntityTypeUpdate) SetName(s string) *EntityTypeUpdate {
|
||||
etu.mutation.SetName(s)
|
||||
return etu
|
||||
func (_u *EntityTypeUpdate) SetName(v string) *EntityTypeUpdate {
|
||||
_u.mutation.SetName(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableName sets the "name" field if the given value is not nil.
|
||||
func (etu *EntityTypeUpdate) SetNillableName(s *string) *EntityTypeUpdate {
|
||||
if s != nil {
|
||||
etu.SetName(*s)
|
||||
func (_u *EntityTypeUpdate) SetNillableName(v *string) *EntityTypeUpdate {
|
||||
if v != nil {
|
||||
_u.SetName(*v)
|
||||
}
|
||||
return etu
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetDescription sets the "description" field.
|
||||
func (etu *EntityTypeUpdate) SetDescription(s string) *EntityTypeUpdate {
|
||||
etu.mutation.SetDescription(s)
|
||||
return etu
|
||||
func (_u *EntityTypeUpdate) SetDescription(v string) *EntityTypeUpdate {
|
||||
_u.mutation.SetDescription(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableDescription sets the "description" field if the given value is not nil.
|
||||
func (etu *EntityTypeUpdate) SetNillableDescription(s *string) *EntityTypeUpdate {
|
||||
if s != nil {
|
||||
etu.SetDescription(*s)
|
||||
func (_u *EntityTypeUpdate) SetNillableDescription(v *string) *EntityTypeUpdate {
|
||||
if v != nil {
|
||||
_u.SetDescription(*v)
|
||||
}
|
||||
return etu
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearDescription clears the value of the "description" field.
|
||||
func (etu *EntityTypeUpdate) ClearDescription() *EntityTypeUpdate {
|
||||
etu.mutation.ClearDescription()
|
||||
return etu
|
||||
func (_u *EntityTypeUpdate) ClearDescription() *EntityTypeUpdate {
|
||||
_u.mutation.ClearDescription()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetIcon sets the "icon" field.
|
||||
func (etu *EntityTypeUpdate) SetIcon(s string) *EntityTypeUpdate {
|
||||
etu.mutation.SetIcon(s)
|
||||
return etu
|
||||
func (_u *EntityTypeUpdate) SetIcon(v string) *EntityTypeUpdate {
|
||||
_u.mutation.SetIcon(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableIcon sets the "icon" field if the given value is not nil.
|
||||
func (etu *EntityTypeUpdate) SetNillableIcon(s *string) *EntityTypeUpdate {
|
||||
if s != nil {
|
||||
etu.SetIcon(*s)
|
||||
func (_u *EntityTypeUpdate) SetNillableIcon(v *string) *EntityTypeUpdate {
|
||||
if v != nil {
|
||||
_u.SetIcon(*v)
|
||||
}
|
||||
return etu
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearIcon clears the value of the "icon" field.
|
||||
func (etu *EntityTypeUpdate) ClearIcon() *EntityTypeUpdate {
|
||||
etu.mutation.ClearIcon()
|
||||
return etu
|
||||
func (_u *EntityTypeUpdate) ClearIcon() *EntityTypeUpdate {
|
||||
_u.mutation.ClearIcon()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetColor sets the "color" field.
|
||||
func (etu *EntityTypeUpdate) SetColor(s string) *EntityTypeUpdate {
|
||||
etu.mutation.SetColor(s)
|
||||
return etu
|
||||
func (_u *EntityTypeUpdate) SetColor(v string) *EntityTypeUpdate {
|
||||
_u.mutation.SetColor(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableColor sets the "color" field if the given value is not nil.
|
||||
func (etu *EntityTypeUpdate) SetNillableColor(s *string) *EntityTypeUpdate {
|
||||
if s != nil {
|
||||
etu.SetColor(*s)
|
||||
func (_u *EntityTypeUpdate) SetNillableColor(v *string) *EntityTypeUpdate {
|
||||
if v != nil {
|
||||
_u.SetColor(*v)
|
||||
}
|
||||
return etu
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearColor clears the value of the "color" field.
|
||||
func (etu *EntityTypeUpdate) ClearColor() *EntityTypeUpdate {
|
||||
etu.mutation.ClearColor()
|
||||
return etu
|
||||
func (_u *EntityTypeUpdate) ClearColor() *EntityTypeUpdate {
|
||||
_u.mutation.ClearColor()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetIsLocation sets the "is_location" field.
|
||||
func (etu *EntityTypeUpdate) SetIsLocation(b bool) *EntityTypeUpdate {
|
||||
etu.mutation.SetIsLocation(b)
|
||||
return etu
|
||||
func (_u *EntityTypeUpdate) SetIsLocation(v bool) *EntityTypeUpdate {
|
||||
_u.mutation.SetIsLocation(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableIsLocation sets the "is_location" field if the given value is not nil.
|
||||
func (etu *EntityTypeUpdate) SetNillableIsLocation(b *bool) *EntityTypeUpdate {
|
||||
if b != nil {
|
||||
etu.SetIsLocation(*b)
|
||||
func (_u *EntityTypeUpdate) SetNillableIsLocation(v *bool) *EntityTypeUpdate {
|
||||
if v != nil {
|
||||
_u.SetIsLocation(*v)
|
||||
}
|
||||
return etu
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetGroupID sets the "group" edge to the Group entity by ID.
|
||||
func (etu *EntityTypeUpdate) SetGroupID(id uuid.UUID) *EntityTypeUpdate {
|
||||
etu.mutation.SetGroupID(id)
|
||||
return etu
|
||||
func (_u *EntityTypeUpdate) SetGroupID(id uuid.UUID) *EntityTypeUpdate {
|
||||
_u.mutation.SetGroupID(id)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetGroup sets the "group" edge to the Group entity.
|
||||
func (etu *EntityTypeUpdate) SetGroup(g *Group) *EntityTypeUpdate {
|
||||
return etu.SetGroupID(g.ID)
|
||||
func (_u *EntityTypeUpdate) SetGroup(v *Group) *EntityTypeUpdate {
|
||||
return _u.SetGroupID(v.ID)
|
||||
}
|
||||
|
||||
// AddEntityIDs adds the "entities" edge to the Entity entity by IDs.
|
||||
func (etu *EntityTypeUpdate) AddEntityIDs(ids ...uuid.UUID) *EntityTypeUpdate {
|
||||
etu.mutation.AddEntityIDs(ids...)
|
||||
return etu
|
||||
func (_u *EntityTypeUpdate) AddEntityIDs(ids ...uuid.UUID) *EntityTypeUpdate {
|
||||
_u.mutation.AddEntityIDs(ids...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddEntities adds the "entities" edges to the Entity entity.
|
||||
func (etu *EntityTypeUpdate) AddEntities(e ...*Entity) *EntityTypeUpdate {
|
||||
ids := make([]uuid.UUID, len(e))
|
||||
for i := range e {
|
||||
ids[i] = e[i].ID
|
||||
func (_u *EntityTypeUpdate) AddEntities(v ...*Entity) *EntityTypeUpdate {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return etu.AddEntityIDs(ids...)
|
||||
return _u.AddEntityIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the EntityTypeMutation object of the builder.
|
||||
func (etu *EntityTypeUpdate) Mutation() *EntityTypeMutation {
|
||||
return etu.mutation
|
||||
func (_u *EntityTypeUpdate) Mutation() *EntityTypeMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// ClearGroup clears the "group" edge to the Group entity.
|
||||
func (etu *EntityTypeUpdate) ClearGroup() *EntityTypeUpdate {
|
||||
etu.mutation.ClearGroup()
|
||||
return etu
|
||||
func (_u *EntityTypeUpdate) ClearGroup() *EntityTypeUpdate {
|
||||
_u.mutation.ClearGroup()
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearEntities clears all "entities" edges to the Entity entity.
|
||||
func (etu *EntityTypeUpdate) ClearEntities() *EntityTypeUpdate {
|
||||
etu.mutation.ClearEntities()
|
||||
return etu
|
||||
func (_u *EntityTypeUpdate) ClearEntities() *EntityTypeUpdate {
|
||||
_u.mutation.ClearEntities()
|
||||
return _u
|
||||
}
|
||||
|
||||
// RemoveEntityIDs removes the "entities" edge to Entity entities by IDs.
|
||||
func (etu *EntityTypeUpdate) RemoveEntityIDs(ids ...uuid.UUID) *EntityTypeUpdate {
|
||||
etu.mutation.RemoveEntityIDs(ids...)
|
||||
return etu
|
||||
func (_u *EntityTypeUpdate) RemoveEntityIDs(ids ...uuid.UUID) *EntityTypeUpdate {
|
||||
_u.mutation.RemoveEntityIDs(ids...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// RemoveEntities removes "entities" edges to Entity entities.
|
||||
func (etu *EntityTypeUpdate) RemoveEntities(e ...*Entity) *EntityTypeUpdate {
|
||||
ids := make([]uuid.UUID, len(e))
|
||||
for i := range e {
|
||||
ids[i] = e[i].ID
|
||||
func (_u *EntityTypeUpdate) RemoveEntities(v ...*Entity) *EntityTypeUpdate {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return etu.RemoveEntityIDs(ids...)
|
||||
return _u.RemoveEntityIDs(ids...)
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (etu *EntityTypeUpdate) Save(ctx context.Context) (int, error) {
|
||||
etu.defaults()
|
||||
return withHooks(ctx, etu.sqlSave, etu.mutation, etu.hooks)
|
||||
func (_u *EntityTypeUpdate) Save(ctx context.Context) (int, error) {
|
||||
_u.defaults()
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (etu *EntityTypeUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := etu.Save(ctx)
|
||||
func (_u *EntityTypeUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -199,94 +199,94 @@ func (etu *EntityTypeUpdate) SaveX(ctx context.Context) int {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (etu *EntityTypeUpdate) Exec(ctx context.Context) error {
|
||||
_, err := etu.Save(ctx)
|
||||
func (_u *EntityTypeUpdate) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (etu *EntityTypeUpdate) ExecX(ctx context.Context) {
|
||||
if err := etu.Exec(ctx); err != nil {
|
||||
func (_u *EntityTypeUpdate) ExecX(ctx context.Context) {
|
||||
if err := _u.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (etu *EntityTypeUpdate) defaults() {
|
||||
if _, ok := etu.mutation.UpdatedAt(); !ok {
|
||||
func (_u *EntityTypeUpdate) defaults() {
|
||||
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
||||
v := entitytype.UpdateDefaultUpdatedAt()
|
||||
etu.mutation.SetUpdatedAt(v)
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (etu *EntityTypeUpdate) check() error {
|
||||
if v, ok := etu.mutation.Name(); ok {
|
||||
func (_u *EntityTypeUpdate) check() error {
|
||||
if v, ok := _u.mutation.Name(); ok {
|
||||
if err := entitytype.NameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "EntityType.name": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := etu.mutation.Description(); ok {
|
||||
if v, ok := _u.mutation.Description(); ok {
|
||||
if err := entitytype.DescriptionValidator(v); err != nil {
|
||||
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "EntityType.description": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := etu.mutation.Icon(); ok {
|
||||
if v, ok := _u.mutation.Icon(); ok {
|
||||
if err := entitytype.IconValidator(v); err != nil {
|
||||
return &ValidationError{Name: "icon", err: fmt.Errorf(`ent: validator failed for field "EntityType.icon": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := etu.mutation.Color(); ok {
|
||||
if v, ok := _u.mutation.Color(); ok {
|
||||
if err := entitytype.ColorValidator(v); err != nil {
|
||||
return &ValidationError{Name: "color", err: fmt.Errorf(`ent: validator failed for field "EntityType.color": %w`, err)}
|
||||
}
|
||||
}
|
||||
if etu.mutation.GroupCleared() && len(etu.mutation.GroupIDs()) > 0 {
|
||||
if _u.mutation.GroupCleared() && len(_u.mutation.GroupIDs()) > 0 {
|
||||
return errors.New(`ent: clearing a required unique edge "EntityType.group"`)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (etu *EntityTypeUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
if err := etu.check(); err != nil {
|
||||
return n, err
|
||||
func (_u *EntityTypeUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
if err := _u.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(entitytype.Table, entitytype.Columns, sqlgraph.NewFieldSpec(entitytype.FieldID, field.TypeUUID))
|
||||
if ps := etu.mutation.predicates; len(ps) > 0 {
|
||||
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := etu.mutation.UpdatedAt(); ok {
|
||||
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(entitytype.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := etu.mutation.Name(); ok {
|
||||
if value, ok := _u.mutation.Name(); ok {
|
||||
_spec.SetField(entitytype.FieldName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := etu.mutation.Description(); ok {
|
||||
if value, ok := _u.mutation.Description(); ok {
|
||||
_spec.SetField(entitytype.FieldDescription, field.TypeString, value)
|
||||
}
|
||||
if etu.mutation.DescriptionCleared() {
|
||||
if _u.mutation.DescriptionCleared() {
|
||||
_spec.ClearField(entitytype.FieldDescription, field.TypeString)
|
||||
}
|
||||
if value, ok := etu.mutation.Icon(); ok {
|
||||
if value, ok := _u.mutation.Icon(); ok {
|
||||
_spec.SetField(entitytype.FieldIcon, field.TypeString, value)
|
||||
}
|
||||
if etu.mutation.IconCleared() {
|
||||
if _u.mutation.IconCleared() {
|
||||
_spec.ClearField(entitytype.FieldIcon, field.TypeString)
|
||||
}
|
||||
if value, ok := etu.mutation.Color(); ok {
|
||||
if value, ok := _u.mutation.Color(); ok {
|
||||
_spec.SetField(entitytype.FieldColor, field.TypeString, value)
|
||||
}
|
||||
if etu.mutation.ColorCleared() {
|
||||
if _u.mutation.ColorCleared() {
|
||||
_spec.ClearField(entitytype.FieldColor, field.TypeString)
|
||||
}
|
||||
if value, ok := etu.mutation.IsLocation(); ok {
|
||||
if value, ok := _u.mutation.IsLocation(); ok {
|
||||
_spec.SetField(entitytype.FieldIsLocation, field.TypeBool, value)
|
||||
}
|
||||
if etu.mutation.GroupCleared() {
|
||||
if _u.mutation.GroupCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -299,7 +299,7 @@ func (etu *EntityTypeUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := etu.mutation.GroupIDs(); len(nodes) > 0 {
|
||||
if nodes := _u.mutation.GroupIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -315,7 +315,7 @@ func (etu *EntityTypeUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if etu.mutation.EntitiesCleared() {
|
||||
if _u.mutation.EntitiesCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
@@ -328,7 +328,7 @@ func (etu *EntityTypeUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := etu.mutation.RemovedEntitiesIDs(); len(nodes) > 0 && !etu.mutation.EntitiesCleared() {
|
||||
if nodes := _u.mutation.RemovedEntitiesIDs(); len(nodes) > 0 && !_u.mutation.EntitiesCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
@@ -344,7 +344,7 @@ func (etu *EntityTypeUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := etu.mutation.EntitiesIDs(); len(nodes) > 0 {
|
||||
if nodes := _u.mutation.EntitiesIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
@@ -360,7 +360,7 @@ func (etu *EntityTypeUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, etu.driver, _spec); err != nil {
|
||||
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{entitytype.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
@@ -368,8 +368,8 @@ func (etu *EntityTypeUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
etu.mutation.done = true
|
||||
return n, nil
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
// EntityTypeUpdateOne is the builder for updating a single EntityType entity.
|
||||
@@ -381,179 +381,179 @@ type EntityTypeUpdateOne struct {
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (etuo *EntityTypeUpdateOne) SetUpdatedAt(t time.Time) *EntityTypeUpdateOne {
|
||||
etuo.mutation.SetUpdatedAt(t)
|
||||
return etuo
|
||||
func (_u *EntityTypeUpdateOne) SetUpdatedAt(v time.Time) *EntityTypeUpdateOne {
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (etuo *EntityTypeUpdateOne) SetName(s string) *EntityTypeUpdateOne {
|
||||
etuo.mutation.SetName(s)
|
||||
return etuo
|
||||
func (_u *EntityTypeUpdateOne) SetName(v string) *EntityTypeUpdateOne {
|
||||
_u.mutation.SetName(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableName sets the "name" field if the given value is not nil.
|
||||
func (etuo *EntityTypeUpdateOne) SetNillableName(s *string) *EntityTypeUpdateOne {
|
||||
if s != nil {
|
||||
etuo.SetName(*s)
|
||||
func (_u *EntityTypeUpdateOne) SetNillableName(v *string) *EntityTypeUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetName(*v)
|
||||
}
|
||||
return etuo
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetDescription sets the "description" field.
|
||||
func (etuo *EntityTypeUpdateOne) SetDescription(s string) *EntityTypeUpdateOne {
|
||||
etuo.mutation.SetDescription(s)
|
||||
return etuo
|
||||
func (_u *EntityTypeUpdateOne) SetDescription(v string) *EntityTypeUpdateOne {
|
||||
_u.mutation.SetDescription(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableDescription sets the "description" field if the given value is not nil.
|
||||
func (etuo *EntityTypeUpdateOne) SetNillableDescription(s *string) *EntityTypeUpdateOne {
|
||||
if s != nil {
|
||||
etuo.SetDescription(*s)
|
||||
func (_u *EntityTypeUpdateOne) SetNillableDescription(v *string) *EntityTypeUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetDescription(*v)
|
||||
}
|
||||
return etuo
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearDescription clears the value of the "description" field.
|
||||
func (etuo *EntityTypeUpdateOne) ClearDescription() *EntityTypeUpdateOne {
|
||||
etuo.mutation.ClearDescription()
|
||||
return etuo
|
||||
func (_u *EntityTypeUpdateOne) ClearDescription() *EntityTypeUpdateOne {
|
||||
_u.mutation.ClearDescription()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetIcon sets the "icon" field.
|
||||
func (etuo *EntityTypeUpdateOne) SetIcon(s string) *EntityTypeUpdateOne {
|
||||
etuo.mutation.SetIcon(s)
|
||||
return etuo
|
||||
func (_u *EntityTypeUpdateOne) SetIcon(v string) *EntityTypeUpdateOne {
|
||||
_u.mutation.SetIcon(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableIcon sets the "icon" field if the given value is not nil.
|
||||
func (etuo *EntityTypeUpdateOne) SetNillableIcon(s *string) *EntityTypeUpdateOne {
|
||||
if s != nil {
|
||||
etuo.SetIcon(*s)
|
||||
func (_u *EntityTypeUpdateOne) SetNillableIcon(v *string) *EntityTypeUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetIcon(*v)
|
||||
}
|
||||
return etuo
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearIcon clears the value of the "icon" field.
|
||||
func (etuo *EntityTypeUpdateOne) ClearIcon() *EntityTypeUpdateOne {
|
||||
etuo.mutation.ClearIcon()
|
||||
return etuo
|
||||
func (_u *EntityTypeUpdateOne) ClearIcon() *EntityTypeUpdateOne {
|
||||
_u.mutation.ClearIcon()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetColor sets the "color" field.
|
||||
func (etuo *EntityTypeUpdateOne) SetColor(s string) *EntityTypeUpdateOne {
|
||||
etuo.mutation.SetColor(s)
|
||||
return etuo
|
||||
func (_u *EntityTypeUpdateOne) SetColor(v string) *EntityTypeUpdateOne {
|
||||
_u.mutation.SetColor(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableColor sets the "color" field if the given value is not nil.
|
||||
func (etuo *EntityTypeUpdateOne) SetNillableColor(s *string) *EntityTypeUpdateOne {
|
||||
if s != nil {
|
||||
etuo.SetColor(*s)
|
||||
func (_u *EntityTypeUpdateOne) SetNillableColor(v *string) *EntityTypeUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetColor(*v)
|
||||
}
|
||||
return etuo
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearColor clears the value of the "color" field.
|
||||
func (etuo *EntityTypeUpdateOne) ClearColor() *EntityTypeUpdateOne {
|
||||
etuo.mutation.ClearColor()
|
||||
return etuo
|
||||
func (_u *EntityTypeUpdateOne) ClearColor() *EntityTypeUpdateOne {
|
||||
_u.mutation.ClearColor()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetIsLocation sets the "is_location" field.
|
||||
func (etuo *EntityTypeUpdateOne) SetIsLocation(b bool) *EntityTypeUpdateOne {
|
||||
etuo.mutation.SetIsLocation(b)
|
||||
return etuo
|
||||
func (_u *EntityTypeUpdateOne) SetIsLocation(v bool) *EntityTypeUpdateOne {
|
||||
_u.mutation.SetIsLocation(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableIsLocation sets the "is_location" field if the given value is not nil.
|
||||
func (etuo *EntityTypeUpdateOne) SetNillableIsLocation(b *bool) *EntityTypeUpdateOne {
|
||||
if b != nil {
|
||||
etuo.SetIsLocation(*b)
|
||||
func (_u *EntityTypeUpdateOne) SetNillableIsLocation(v *bool) *EntityTypeUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetIsLocation(*v)
|
||||
}
|
||||
return etuo
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetGroupID sets the "group" edge to the Group entity by ID.
|
||||
func (etuo *EntityTypeUpdateOne) SetGroupID(id uuid.UUID) *EntityTypeUpdateOne {
|
||||
etuo.mutation.SetGroupID(id)
|
||||
return etuo
|
||||
func (_u *EntityTypeUpdateOne) SetGroupID(id uuid.UUID) *EntityTypeUpdateOne {
|
||||
_u.mutation.SetGroupID(id)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetGroup sets the "group" edge to the Group entity.
|
||||
func (etuo *EntityTypeUpdateOne) SetGroup(g *Group) *EntityTypeUpdateOne {
|
||||
return etuo.SetGroupID(g.ID)
|
||||
func (_u *EntityTypeUpdateOne) SetGroup(v *Group) *EntityTypeUpdateOne {
|
||||
return _u.SetGroupID(v.ID)
|
||||
}
|
||||
|
||||
// AddEntityIDs adds the "entities" edge to the Entity entity by IDs.
|
||||
func (etuo *EntityTypeUpdateOne) AddEntityIDs(ids ...uuid.UUID) *EntityTypeUpdateOne {
|
||||
etuo.mutation.AddEntityIDs(ids...)
|
||||
return etuo
|
||||
func (_u *EntityTypeUpdateOne) AddEntityIDs(ids ...uuid.UUID) *EntityTypeUpdateOne {
|
||||
_u.mutation.AddEntityIDs(ids...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddEntities adds the "entities" edges to the Entity entity.
|
||||
func (etuo *EntityTypeUpdateOne) AddEntities(e ...*Entity) *EntityTypeUpdateOne {
|
||||
ids := make([]uuid.UUID, len(e))
|
||||
for i := range e {
|
||||
ids[i] = e[i].ID
|
||||
func (_u *EntityTypeUpdateOne) AddEntities(v ...*Entity) *EntityTypeUpdateOne {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return etuo.AddEntityIDs(ids...)
|
||||
return _u.AddEntityIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the EntityTypeMutation object of the builder.
|
||||
func (etuo *EntityTypeUpdateOne) Mutation() *EntityTypeMutation {
|
||||
return etuo.mutation
|
||||
func (_u *EntityTypeUpdateOne) Mutation() *EntityTypeMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// ClearGroup clears the "group" edge to the Group entity.
|
||||
func (etuo *EntityTypeUpdateOne) ClearGroup() *EntityTypeUpdateOne {
|
||||
etuo.mutation.ClearGroup()
|
||||
return etuo
|
||||
func (_u *EntityTypeUpdateOne) ClearGroup() *EntityTypeUpdateOne {
|
||||
_u.mutation.ClearGroup()
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearEntities clears all "entities" edges to the Entity entity.
|
||||
func (etuo *EntityTypeUpdateOne) ClearEntities() *EntityTypeUpdateOne {
|
||||
etuo.mutation.ClearEntities()
|
||||
return etuo
|
||||
func (_u *EntityTypeUpdateOne) ClearEntities() *EntityTypeUpdateOne {
|
||||
_u.mutation.ClearEntities()
|
||||
return _u
|
||||
}
|
||||
|
||||
// RemoveEntityIDs removes the "entities" edge to Entity entities by IDs.
|
||||
func (etuo *EntityTypeUpdateOne) RemoveEntityIDs(ids ...uuid.UUID) *EntityTypeUpdateOne {
|
||||
etuo.mutation.RemoveEntityIDs(ids...)
|
||||
return etuo
|
||||
func (_u *EntityTypeUpdateOne) RemoveEntityIDs(ids ...uuid.UUID) *EntityTypeUpdateOne {
|
||||
_u.mutation.RemoveEntityIDs(ids...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// RemoveEntities removes "entities" edges to Entity entities.
|
||||
func (etuo *EntityTypeUpdateOne) RemoveEntities(e ...*Entity) *EntityTypeUpdateOne {
|
||||
ids := make([]uuid.UUID, len(e))
|
||||
for i := range e {
|
||||
ids[i] = e[i].ID
|
||||
func (_u *EntityTypeUpdateOne) RemoveEntities(v ...*Entity) *EntityTypeUpdateOne {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return etuo.RemoveEntityIDs(ids...)
|
||||
return _u.RemoveEntityIDs(ids...)
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the EntityTypeUpdate builder.
|
||||
func (etuo *EntityTypeUpdateOne) Where(ps ...predicate.EntityType) *EntityTypeUpdateOne {
|
||||
etuo.mutation.Where(ps...)
|
||||
return etuo
|
||||
func (_u *EntityTypeUpdateOne) Where(ps ...predicate.EntityType) *EntityTypeUpdateOne {
|
||||
_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 (etuo *EntityTypeUpdateOne) Select(field string, fields ...string) *EntityTypeUpdateOne {
|
||||
etuo.fields = append([]string{field}, fields...)
|
||||
return etuo
|
||||
func (_u *EntityTypeUpdateOne) Select(field string, fields ...string) *EntityTypeUpdateOne {
|
||||
_u.fields = append([]string{field}, fields...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated EntityType entity.
|
||||
func (etuo *EntityTypeUpdateOne) Save(ctx context.Context) (*EntityType, error) {
|
||||
etuo.defaults()
|
||||
return withHooks(ctx, etuo.sqlSave, etuo.mutation, etuo.hooks)
|
||||
func (_u *EntityTypeUpdateOne) Save(ctx context.Context) (*EntityType, error) {
|
||||
_u.defaults()
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (etuo *EntityTypeUpdateOne) SaveX(ctx context.Context) *EntityType {
|
||||
node, err := etuo.Save(ctx)
|
||||
func (_u *EntityTypeUpdateOne) SaveX(ctx context.Context) *EntityType {
|
||||
node, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -561,65 +561,65 @@ func (etuo *EntityTypeUpdateOne) SaveX(ctx context.Context) *EntityType {
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (etuo *EntityTypeUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := etuo.Save(ctx)
|
||||
func (_u *EntityTypeUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (etuo *EntityTypeUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := etuo.Exec(ctx); err != nil {
|
||||
func (_u *EntityTypeUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := _u.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (etuo *EntityTypeUpdateOne) defaults() {
|
||||
if _, ok := etuo.mutation.UpdatedAt(); !ok {
|
||||
func (_u *EntityTypeUpdateOne) defaults() {
|
||||
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
||||
v := entitytype.UpdateDefaultUpdatedAt()
|
||||
etuo.mutation.SetUpdatedAt(v)
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (etuo *EntityTypeUpdateOne) check() error {
|
||||
if v, ok := etuo.mutation.Name(); ok {
|
||||
func (_u *EntityTypeUpdateOne) check() error {
|
||||
if v, ok := _u.mutation.Name(); ok {
|
||||
if err := entitytype.NameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "EntityType.name": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := etuo.mutation.Description(); ok {
|
||||
if v, ok := _u.mutation.Description(); ok {
|
||||
if err := entitytype.DescriptionValidator(v); err != nil {
|
||||
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "EntityType.description": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := etuo.mutation.Icon(); ok {
|
||||
if v, ok := _u.mutation.Icon(); ok {
|
||||
if err := entitytype.IconValidator(v); err != nil {
|
||||
return &ValidationError{Name: "icon", err: fmt.Errorf(`ent: validator failed for field "EntityType.icon": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := etuo.mutation.Color(); ok {
|
||||
if v, ok := _u.mutation.Color(); ok {
|
||||
if err := entitytype.ColorValidator(v); err != nil {
|
||||
return &ValidationError{Name: "color", err: fmt.Errorf(`ent: validator failed for field "EntityType.color": %w`, err)}
|
||||
}
|
||||
}
|
||||
if etuo.mutation.GroupCleared() && len(etuo.mutation.GroupIDs()) > 0 {
|
||||
if _u.mutation.GroupCleared() && len(_u.mutation.GroupIDs()) > 0 {
|
||||
return errors.New(`ent: clearing a required unique edge "EntityType.group"`)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (etuo *EntityTypeUpdateOne) sqlSave(ctx context.Context) (_node *EntityType, err error) {
|
||||
if err := etuo.check(); err != nil {
|
||||
func (_u *EntityTypeUpdateOne) sqlSave(ctx context.Context) (_node *EntityType, err error) {
|
||||
if err := _u.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(entitytype.Table, entitytype.Columns, sqlgraph.NewFieldSpec(entitytype.FieldID, field.TypeUUID))
|
||||
id, ok := etuo.mutation.ID()
|
||||
id, ok := _u.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "EntityType.id" for update`)}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
if fields := etuo.fields; len(fields) > 0 {
|
||||
if fields := _u.fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, entitytype.FieldID)
|
||||
for _, f := range fields {
|
||||
@@ -631,41 +631,41 @@ func (etuo *EntityTypeUpdateOne) sqlSave(ctx context.Context) (_node *EntityType
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := etuo.mutation.predicates; len(ps) > 0 {
|
||||
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := etuo.mutation.UpdatedAt(); ok {
|
||||
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(entitytype.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := etuo.mutation.Name(); ok {
|
||||
if value, ok := _u.mutation.Name(); ok {
|
||||
_spec.SetField(entitytype.FieldName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := etuo.mutation.Description(); ok {
|
||||
if value, ok := _u.mutation.Description(); ok {
|
||||
_spec.SetField(entitytype.FieldDescription, field.TypeString, value)
|
||||
}
|
||||
if etuo.mutation.DescriptionCleared() {
|
||||
if _u.mutation.DescriptionCleared() {
|
||||
_spec.ClearField(entitytype.FieldDescription, field.TypeString)
|
||||
}
|
||||
if value, ok := etuo.mutation.Icon(); ok {
|
||||
if value, ok := _u.mutation.Icon(); ok {
|
||||
_spec.SetField(entitytype.FieldIcon, field.TypeString, value)
|
||||
}
|
||||
if etuo.mutation.IconCleared() {
|
||||
if _u.mutation.IconCleared() {
|
||||
_spec.ClearField(entitytype.FieldIcon, field.TypeString)
|
||||
}
|
||||
if value, ok := etuo.mutation.Color(); ok {
|
||||
if value, ok := _u.mutation.Color(); ok {
|
||||
_spec.SetField(entitytype.FieldColor, field.TypeString, value)
|
||||
}
|
||||
if etuo.mutation.ColorCleared() {
|
||||
if _u.mutation.ColorCleared() {
|
||||
_spec.ClearField(entitytype.FieldColor, field.TypeString)
|
||||
}
|
||||
if value, ok := etuo.mutation.IsLocation(); ok {
|
||||
if value, ok := _u.mutation.IsLocation(); ok {
|
||||
_spec.SetField(entitytype.FieldIsLocation, field.TypeBool, value)
|
||||
}
|
||||
if etuo.mutation.GroupCleared() {
|
||||
if _u.mutation.GroupCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -678,7 +678,7 @@ func (etuo *EntityTypeUpdateOne) sqlSave(ctx context.Context) (_node *EntityType
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := etuo.mutation.GroupIDs(); len(nodes) > 0 {
|
||||
if nodes := _u.mutation.GroupIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -694,7 +694,7 @@ func (etuo *EntityTypeUpdateOne) sqlSave(ctx context.Context) (_node *EntityType
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if etuo.mutation.EntitiesCleared() {
|
||||
if _u.mutation.EntitiesCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
@@ -707,7 +707,7 @@ func (etuo *EntityTypeUpdateOne) sqlSave(ctx context.Context) (_node *EntityType
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := etuo.mutation.RemovedEntitiesIDs(); len(nodes) > 0 && !etuo.mutation.EntitiesCleared() {
|
||||
if nodes := _u.mutation.RemovedEntitiesIDs(); len(nodes) > 0 && !_u.mutation.EntitiesCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
@@ -723,7 +723,7 @@ func (etuo *EntityTypeUpdateOne) sqlSave(ctx context.Context) (_node *EntityType
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := etuo.mutation.EntitiesIDs(); len(nodes) > 0 {
|
||||
if nodes := _u.mutation.EntitiesIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
@@ -739,10 +739,10 @@ func (etuo *EntityTypeUpdateOne) sqlSave(ctx context.Context) (_node *EntityType
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
_node = &EntityType{config: etuo.config}
|
||||
_node = &EntityType{config: _u.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
if err = sqlgraph.UpdateNode(ctx, etuo.driver, _spec); err != nil {
|
||||
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{entitytype.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
@@ -750,6 +750,6 @@ func (etuo *EntityTypeUpdateOne) sqlSave(ctx context.Context) (_node *EntityType
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
etuo.mutation.done = true
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ func (*Group) scanValues(columns []string) ([]any, error) {
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the Group fields.
|
||||
func (gr *Group) assignValues(columns []string, values []any) error {
|
||||
func (_m *Group) assignValues(columns []string, values []any) error {
|
||||
if m, n := len(values), len(columns); m < n {
|
||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||
}
|
||||
@@ -135,34 +135,34 @@ func (gr *Group) assignValues(columns []string, values []any) error {
|
||||
if value, ok := values[i].(*uuid.UUID); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", values[i])
|
||||
} else if value != nil {
|
||||
gr.ID = *value
|
||||
_m.ID = *value
|
||||
}
|
||||
case group.FieldCreatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
||||
} else if value.Valid {
|
||||
gr.CreatedAt = value.Time
|
||||
_m.CreatedAt = value.Time
|
||||
}
|
||||
case group.FieldUpdatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
|
||||
} else if value.Valid {
|
||||
gr.UpdatedAt = value.Time
|
||||
_m.UpdatedAt = value.Time
|
||||
}
|
||||
case group.FieldName:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field name", values[i])
|
||||
} else if value.Valid {
|
||||
gr.Name = value.String
|
||||
_m.Name = value.String
|
||||
}
|
||||
case group.FieldCurrency:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field currency", values[i])
|
||||
} else if value.Valid {
|
||||
gr.Currency = value.String
|
||||
_m.Currency = value.String
|
||||
}
|
||||
default:
|
||||
gr.selectValues.Set(columns[i], values[i])
|
||||
_m.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -170,74 +170,74 @@ func (gr *Group) assignValues(columns []string, values []any) error {
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the Group.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (gr *Group) Value(name string) (ent.Value, error) {
|
||||
return gr.selectValues.Get(name)
|
||||
func (_m *Group) Value(name string) (ent.Value, error) {
|
||||
return _m.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// QueryUsers queries the "users" edge of the Group entity.
|
||||
func (gr *Group) QueryUsers() *UserQuery {
|
||||
return NewGroupClient(gr.config).QueryUsers(gr)
|
||||
func (_m *Group) QueryUsers() *UserQuery {
|
||||
return NewGroupClient(_m.config).QueryUsers(_m)
|
||||
}
|
||||
|
||||
// QueryEntities queries the "entities" edge of the Group entity.
|
||||
func (gr *Group) QueryEntities() *EntityQuery {
|
||||
return NewGroupClient(gr.config).QueryEntities(gr)
|
||||
func (_m *Group) QueryEntities() *EntityQuery {
|
||||
return NewGroupClient(_m.config).QueryEntities(_m)
|
||||
}
|
||||
|
||||
// QueryLabels queries the "labels" edge of the Group entity.
|
||||
func (gr *Group) QueryLabels() *LabelQuery {
|
||||
return NewGroupClient(gr.config).QueryLabels(gr)
|
||||
func (_m *Group) QueryLabels() *LabelQuery {
|
||||
return NewGroupClient(_m.config).QueryLabels(_m)
|
||||
}
|
||||
|
||||
// QueryInvitationTokens queries the "invitation_tokens" edge of the Group entity.
|
||||
func (gr *Group) QueryInvitationTokens() *GroupInvitationTokenQuery {
|
||||
return NewGroupClient(gr.config).QueryInvitationTokens(gr)
|
||||
func (_m *Group) QueryInvitationTokens() *GroupInvitationTokenQuery {
|
||||
return NewGroupClient(_m.config).QueryInvitationTokens(_m)
|
||||
}
|
||||
|
||||
// QueryNotifiers queries the "notifiers" edge of the Group entity.
|
||||
func (gr *Group) QueryNotifiers() *NotifierQuery {
|
||||
return NewGroupClient(gr.config).QueryNotifiers(gr)
|
||||
func (_m *Group) QueryNotifiers() *NotifierQuery {
|
||||
return NewGroupClient(_m.config).QueryNotifiers(_m)
|
||||
}
|
||||
|
||||
// QueryEntityTypes queries the "entity_types" edge of the Group entity.
|
||||
func (gr *Group) QueryEntityTypes() *EntityTypeQuery {
|
||||
return NewGroupClient(gr.config).QueryEntityTypes(gr)
|
||||
func (_m *Group) QueryEntityTypes() *EntityTypeQuery {
|
||||
return NewGroupClient(_m.config).QueryEntityTypes(_m)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this Group.
|
||||
// Note that you need to call Group.Unwrap() before calling this method if this Group
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (gr *Group) Update() *GroupUpdateOne {
|
||||
return NewGroupClient(gr.config).UpdateOne(gr)
|
||||
func (_m *Group) Update() *GroupUpdateOne {
|
||||
return NewGroupClient(_m.config).UpdateOne(_m)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the Group entity that was returned from a transaction after it was closed,
|
||||
// so that all future queries will be executed through the driver which created the transaction.
|
||||
func (gr *Group) Unwrap() *Group {
|
||||
_tx, ok := gr.config.driver.(*txDriver)
|
||||
func (_m *Group) Unwrap() *Group {
|
||||
_tx, ok := _m.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: Group is not a transactional entity")
|
||||
}
|
||||
gr.config.driver = _tx.drv
|
||||
return gr
|
||||
_m.config.driver = _tx.drv
|
||||
return _m
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (gr *Group) String() string {
|
||||
func (_m *Group) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("Group(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", gr.ID))
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||||
builder.WriteString("created_at=")
|
||||
builder.WriteString(gr.CreatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("updated_at=")
|
||||
builder.WriteString(gr.UpdatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("name=")
|
||||
builder.WriteString(gr.Name)
|
||||
builder.WriteString(_m.Name)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("currency=")
|
||||
builder.WriteString(gr.Currency)
|
||||
builder.WriteString(_m.Currency)
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
@@ -28,171 +28,171 @@ type GroupCreate struct {
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (gc *GroupCreate) SetCreatedAt(t time.Time) *GroupCreate {
|
||||
gc.mutation.SetCreatedAt(t)
|
||||
return gc
|
||||
func (_c *GroupCreate) SetCreatedAt(v time.Time) *GroupCreate {
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||
func (gc *GroupCreate) SetNillableCreatedAt(t *time.Time) *GroupCreate {
|
||||
if t != nil {
|
||||
gc.SetCreatedAt(*t)
|
||||
func (_c *GroupCreate) SetNillableCreatedAt(v *time.Time) *GroupCreate {
|
||||
if v != nil {
|
||||
_c.SetCreatedAt(*v)
|
||||
}
|
||||
return gc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (gc *GroupCreate) SetUpdatedAt(t time.Time) *GroupCreate {
|
||||
gc.mutation.SetUpdatedAt(t)
|
||||
return gc
|
||||
func (_c *GroupCreate) SetUpdatedAt(v time.Time) *GroupCreate {
|
||||
_c.mutation.SetUpdatedAt(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
||||
func (gc *GroupCreate) SetNillableUpdatedAt(t *time.Time) *GroupCreate {
|
||||
if t != nil {
|
||||
gc.SetUpdatedAt(*t)
|
||||
func (_c *GroupCreate) SetNillableUpdatedAt(v *time.Time) *GroupCreate {
|
||||
if v != nil {
|
||||
_c.SetUpdatedAt(*v)
|
||||
}
|
||||
return gc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (gc *GroupCreate) SetName(s string) *GroupCreate {
|
||||
gc.mutation.SetName(s)
|
||||
return gc
|
||||
func (_c *GroupCreate) SetName(v string) *GroupCreate {
|
||||
_c.mutation.SetName(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetCurrency sets the "currency" field.
|
||||
func (gc *GroupCreate) SetCurrency(s string) *GroupCreate {
|
||||
gc.mutation.SetCurrency(s)
|
||||
return gc
|
||||
func (_c *GroupCreate) SetCurrency(v string) *GroupCreate {
|
||||
_c.mutation.SetCurrency(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableCurrency sets the "currency" field if the given value is not nil.
|
||||
func (gc *GroupCreate) SetNillableCurrency(s *string) *GroupCreate {
|
||||
if s != nil {
|
||||
gc.SetCurrency(*s)
|
||||
func (_c *GroupCreate) SetNillableCurrency(v *string) *GroupCreate {
|
||||
if v != nil {
|
||||
_c.SetCurrency(*v)
|
||||
}
|
||||
return gc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetID sets the "id" field.
|
||||
func (gc *GroupCreate) SetID(u uuid.UUID) *GroupCreate {
|
||||
gc.mutation.SetID(u)
|
||||
return gc
|
||||
func (_c *GroupCreate) SetID(v uuid.UUID) *GroupCreate {
|
||||
_c.mutation.SetID(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableID sets the "id" field if the given value is not nil.
|
||||
func (gc *GroupCreate) SetNillableID(u *uuid.UUID) *GroupCreate {
|
||||
if u != nil {
|
||||
gc.SetID(*u)
|
||||
func (_c *GroupCreate) SetNillableID(v *uuid.UUID) *GroupCreate {
|
||||
if v != nil {
|
||||
_c.SetID(*v)
|
||||
}
|
||||
return gc
|
||||
return _c
|
||||
}
|
||||
|
||||
// AddUserIDs adds the "users" edge to the User entity by IDs.
|
||||
func (gc *GroupCreate) AddUserIDs(ids ...uuid.UUID) *GroupCreate {
|
||||
gc.mutation.AddUserIDs(ids...)
|
||||
return gc
|
||||
func (_c *GroupCreate) AddUserIDs(ids ...uuid.UUID) *GroupCreate {
|
||||
_c.mutation.AddUserIDs(ids...)
|
||||
return _c
|
||||
}
|
||||
|
||||
// AddUsers adds the "users" edges to the User entity.
|
||||
func (gc *GroupCreate) AddUsers(u ...*User) *GroupCreate {
|
||||
ids := make([]uuid.UUID, len(u))
|
||||
for i := range u {
|
||||
ids[i] = u[i].ID
|
||||
func (_c *GroupCreate) AddUsers(v ...*User) *GroupCreate {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return gc.AddUserIDs(ids...)
|
||||
return _c.AddUserIDs(ids...)
|
||||
}
|
||||
|
||||
// AddEntityIDs adds the "entities" edge to the Entity entity by IDs.
|
||||
func (gc *GroupCreate) AddEntityIDs(ids ...uuid.UUID) *GroupCreate {
|
||||
gc.mutation.AddEntityIDs(ids...)
|
||||
return gc
|
||||
func (_c *GroupCreate) AddEntityIDs(ids ...uuid.UUID) *GroupCreate {
|
||||
_c.mutation.AddEntityIDs(ids...)
|
||||
return _c
|
||||
}
|
||||
|
||||
// AddEntities adds the "entities" edges to the Entity entity.
|
||||
func (gc *GroupCreate) AddEntities(e ...*Entity) *GroupCreate {
|
||||
ids := make([]uuid.UUID, len(e))
|
||||
for i := range e {
|
||||
ids[i] = e[i].ID
|
||||
func (_c *GroupCreate) AddEntities(v ...*Entity) *GroupCreate {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return gc.AddEntityIDs(ids...)
|
||||
return _c.AddEntityIDs(ids...)
|
||||
}
|
||||
|
||||
// AddLabelIDs adds the "labels" edge to the Label entity by IDs.
|
||||
func (gc *GroupCreate) AddLabelIDs(ids ...uuid.UUID) *GroupCreate {
|
||||
gc.mutation.AddLabelIDs(ids...)
|
||||
return gc
|
||||
func (_c *GroupCreate) AddLabelIDs(ids ...uuid.UUID) *GroupCreate {
|
||||
_c.mutation.AddLabelIDs(ids...)
|
||||
return _c
|
||||
}
|
||||
|
||||
// AddLabels adds the "labels" edges to the Label entity.
|
||||
func (gc *GroupCreate) AddLabels(l ...*Label) *GroupCreate {
|
||||
ids := make([]uuid.UUID, len(l))
|
||||
for i := range l {
|
||||
ids[i] = l[i].ID
|
||||
func (_c *GroupCreate) AddLabels(v ...*Label) *GroupCreate {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return gc.AddLabelIDs(ids...)
|
||||
return _c.AddLabelIDs(ids...)
|
||||
}
|
||||
|
||||
// AddInvitationTokenIDs adds the "invitation_tokens" edge to the GroupInvitationToken entity by IDs.
|
||||
func (gc *GroupCreate) AddInvitationTokenIDs(ids ...uuid.UUID) *GroupCreate {
|
||||
gc.mutation.AddInvitationTokenIDs(ids...)
|
||||
return gc
|
||||
func (_c *GroupCreate) AddInvitationTokenIDs(ids ...uuid.UUID) *GroupCreate {
|
||||
_c.mutation.AddInvitationTokenIDs(ids...)
|
||||
return _c
|
||||
}
|
||||
|
||||
// AddInvitationTokens adds the "invitation_tokens" edges to the GroupInvitationToken entity.
|
||||
func (gc *GroupCreate) AddInvitationTokens(g ...*GroupInvitationToken) *GroupCreate {
|
||||
ids := make([]uuid.UUID, len(g))
|
||||
for i := range g {
|
||||
ids[i] = g[i].ID
|
||||
func (_c *GroupCreate) AddInvitationTokens(v ...*GroupInvitationToken) *GroupCreate {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return gc.AddInvitationTokenIDs(ids...)
|
||||
return _c.AddInvitationTokenIDs(ids...)
|
||||
}
|
||||
|
||||
// AddNotifierIDs adds the "notifiers" edge to the Notifier entity by IDs.
|
||||
func (gc *GroupCreate) AddNotifierIDs(ids ...uuid.UUID) *GroupCreate {
|
||||
gc.mutation.AddNotifierIDs(ids...)
|
||||
return gc
|
||||
func (_c *GroupCreate) AddNotifierIDs(ids ...uuid.UUID) *GroupCreate {
|
||||
_c.mutation.AddNotifierIDs(ids...)
|
||||
return _c
|
||||
}
|
||||
|
||||
// AddNotifiers adds the "notifiers" edges to the Notifier entity.
|
||||
func (gc *GroupCreate) AddNotifiers(n ...*Notifier) *GroupCreate {
|
||||
ids := make([]uuid.UUID, len(n))
|
||||
for i := range n {
|
||||
ids[i] = n[i].ID
|
||||
func (_c *GroupCreate) AddNotifiers(v ...*Notifier) *GroupCreate {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return gc.AddNotifierIDs(ids...)
|
||||
return _c.AddNotifierIDs(ids...)
|
||||
}
|
||||
|
||||
// AddEntityTypeIDs adds the "entity_types" edge to the EntityType entity by IDs.
|
||||
func (gc *GroupCreate) AddEntityTypeIDs(ids ...uuid.UUID) *GroupCreate {
|
||||
gc.mutation.AddEntityTypeIDs(ids...)
|
||||
return gc
|
||||
func (_c *GroupCreate) AddEntityTypeIDs(ids ...uuid.UUID) *GroupCreate {
|
||||
_c.mutation.AddEntityTypeIDs(ids...)
|
||||
return _c
|
||||
}
|
||||
|
||||
// AddEntityTypes adds the "entity_types" edges to the EntityType entity.
|
||||
func (gc *GroupCreate) AddEntityTypes(e ...*EntityType) *GroupCreate {
|
||||
ids := make([]uuid.UUID, len(e))
|
||||
for i := range e {
|
||||
ids[i] = e[i].ID
|
||||
func (_c *GroupCreate) AddEntityTypes(v ...*EntityType) *GroupCreate {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return gc.AddEntityTypeIDs(ids...)
|
||||
return _c.AddEntityTypeIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the GroupMutation object of the builder.
|
||||
func (gc *GroupCreate) Mutation() *GroupMutation {
|
||||
return gc.mutation
|
||||
func (_c *GroupCreate) Mutation() *GroupMutation {
|
||||
return _c.mutation
|
||||
}
|
||||
|
||||
// Save creates the Group in the database.
|
||||
func (gc *GroupCreate) Save(ctx context.Context) (*Group, error) {
|
||||
gc.defaults()
|
||||
return withHooks(ctx, gc.sqlSave, gc.mutation, gc.hooks)
|
||||
func (_c *GroupCreate) Save(ctx context.Context) (*Group, error) {
|
||||
_c.defaults()
|
||||
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (gc *GroupCreate) SaveX(ctx context.Context) *Group {
|
||||
v, err := gc.Save(ctx)
|
||||
func (_c *GroupCreate) SaveX(ctx context.Context) *Group {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -200,66 +200,66 @@ func (gc *GroupCreate) SaveX(ctx context.Context) *Group {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (gc *GroupCreate) Exec(ctx context.Context) error {
|
||||
_, err := gc.Save(ctx)
|
||||
func (_c *GroupCreate) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (gc *GroupCreate) ExecX(ctx context.Context) {
|
||||
if err := gc.Exec(ctx); err != nil {
|
||||
func (_c *GroupCreate) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (gc *GroupCreate) defaults() {
|
||||
if _, ok := gc.mutation.CreatedAt(); !ok {
|
||||
func (_c *GroupCreate) defaults() {
|
||||
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||
v := group.DefaultCreatedAt()
|
||||
gc.mutation.SetCreatedAt(v)
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
}
|
||||
if _, ok := gc.mutation.UpdatedAt(); !ok {
|
||||
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
||||
v := group.DefaultUpdatedAt()
|
||||
gc.mutation.SetUpdatedAt(v)
|
||||
_c.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
if _, ok := gc.mutation.Currency(); !ok {
|
||||
if _, ok := _c.mutation.Currency(); !ok {
|
||||
v := group.DefaultCurrency
|
||||
gc.mutation.SetCurrency(v)
|
||||
_c.mutation.SetCurrency(v)
|
||||
}
|
||||
if _, ok := gc.mutation.ID(); !ok {
|
||||
if _, ok := _c.mutation.ID(); !ok {
|
||||
v := group.DefaultID()
|
||||
gc.mutation.SetID(v)
|
||||
_c.mutation.SetID(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (gc *GroupCreate) check() error {
|
||||
if _, ok := gc.mutation.CreatedAt(); !ok {
|
||||
func (_c *GroupCreate) check() error {
|
||||
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Group.created_at"`)}
|
||||
}
|
||||
if _, ok := gc.mutation.UpdatedAt(); !ok {
|
||||
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
||||
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Group.updated_at"`)}
|
||||
}
|
||||
if _, ok := gc.mutation.Name(); !ok {
|
||||
if _, ok := _c.mutation.Name(); !ok {
|
||||
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Group.name"`)}
|
||||
}
|
||||
if v, ok := gc.mutation.Name(); ok {
|
||||
if v, ok := _c.mutation.Name(); ok {
|
||||
if err := group.NameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Group.name": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := gc.mutation.Currency(); !ok {
|
||||
if _, ok := _c.mutation.Currency(); !ok {
|
||||
return &ValidationError{Name: "currency", err: errors.New(`ent: missing required field "Group.currency"`)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (gc *GroupCreate) sqlSave(ctx context.Context) (*Group, error) {
|
||||
if err := gc.check(); err != nil {
|
||||
func (_c *GroupCreate) sqlSave(ctx context.Context) (*Group, error) {
|
||||
if err := _c.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_node, _spec := gc.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, gc.driver, _spec); err != nil {
|
||||
_node, _spec := _c.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
@@ -272,37 +272,37 @@ func (gc *GroupCreate) sqlSave(ctx context.Context) (*Group, error) {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
gc.mutation.id = &_node.ID
|
||||
gc.mutation.done = true
|
||||
_c.mutation.id = &_node.ID
|
||||
_c.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
func (gc *GroupCreate) createSpec() (*Group, *sqlgraph.CreateSpec) {
|
||||
func (_c *GroupCreate) createSpec() (*Group, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &Group{config: gc.config}
|
||||
_node = &Group{config: _c.config}
|
||||
_spec = sqlgraph.NewCreateSpec(group.Table, sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID))
|
||||
)
|
||||
if id, ok := gc.mutation.ID(); ok {
|
||||
if id, ok := _c.mutation.ID(); ok {
|
||||
_node.ID = id
|
||||
_spec.ID.Value = &id
|
||||
}
|
||||
if value, ok := gc.mutation.CreatedAt(); ok {
|
||||
if value, ok := _c.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(group.FieldCreatedAt, field.TypeTime, value)
|
||||
_node.CreatedAt = value
|
||||
}
|
||||
if value, ok := gc.mutation.UpdatedAt(); ok {
|
||||
if value, ok := _c.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(group.FieldUpdatedAt, field.TypeTime, value)
|
||||
_node.UpdatedAt = value
|
||||
}
|
||||
if value, ok := gc.mutation.Name(); ok {
|
||||
if value, ok := _c.mutation.Name(); ok {
|
||||
_spec.SetField(group.FieldName, field.TypeString, value)
|
||||
_node.Name = value
|
||||
}
|
||||
if value, ok := gc.mutation.Currency(); ok {
|
||||
if value, ok := _c.mutation.Currency(); ok {
|
||||
_spec.SetField(group.FieldCurrency, field.TypeString, value)
|
||||
_node.Currency = value
|
||||
}
|
||||
if nodes := gc.mutation.UsersIDs(); len(nodes) > 0 {
|
||||
if nodes := _c.mutation.UsersIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
@@ -318,7 +318,7 @@ func (gc *GroupCreate) createSpec() (*Group, *sqlgraph.CreateSpec) {
|
||||
}
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
if nodes := gc.mutation.EntitiesIDs(); len(nodes) > 0 {
|
||||
if nodes := _c.mutation.EntitiesIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
@@ -334,7 +334,7 @@ func (gc *GroupCreate) createSpec() (*Group, *sqlgraph.CreateSpec) {
|
||||
}
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
if nodes := gc.mutation.LabelsIDs(); len(nodes) > 0 {
|
||||
if nodes := _c.mutation.LabelsIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
@@ -350,7 +350,7 @@ func (gc *GroupCreate) createSpec() (*Group, *sqlgraph.CreateSpec) {
|
||||
}
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
if nodes := gc.mutation.InvitationTokensIDs(); len(nodes) > 0 {
|
||||
if nodes := _c.mutation.InvitationTokensIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
@@ -366,7 +366,7 @@ func (gc *GroupCreate) createSpec() (*Group, *sqlgraph.CreateSpec) {
|
||||
}
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
if nodes := gc.mutation.NotifiersIDs(); len(nodes) > 0 {
|
||||
if nodes := _c.mutation.NotifiersIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
@@ -382,7 +382,7 @@ func (gc *GroupCreate) createSpec() (*Group, *sqlgraph.CreateSpec) {
|
||||
}
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
if nodes := gc.mutation.EntityTypesIDs(); len(nodes) > 0 {
|
||||
if nodes := _c.mutation.EntityTypesIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
@@ -409,16 +409,16 @@ type GroupCreateBulk struct {
|
||||
}
|
||||
|
||||
// Save creates the Group entities in the database.
|
||||
func (gcb *GroupCreateBulk) Save(ctx context.Context) ([]*Group, error) {
|
||||
if gcb.err != nil {
|
||||
return nil, gcb.err
|
||||
func (_c *GroupCreateBulk) Save(ctx context.Context) ([]*Group, error) {
|
||||
if _c.err != nil {
|
||||
return nil, _c.err
|
||||
}
|
||||
specs := make([]*sqlgraph.CreateSpec, len(gcb.builders))
|
||||
nodes := make([]*Group, len(gcb.builders))
|
||||
mutators := make([]Mutator, len(gcb.builders))
|
||||
for i := range gcb.builders {
|
||||
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
||||
nodes := make([]*Group, len(_c.builders))
|
||||
mutators := make([]Mutator, len(_c.builders))
|
||||
for i := range _c.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := gcb.builders[i]
|
||||
builder := _c.builders[i]
|
||||
builder.defaults()
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*GroupMutation)
|
||||
@@ -432,11 +432,11 @@ func (gcb *GroupCreateBulk) Save(ctx context.Context) ([]*Group, error) {
|
||||
var err error
|
||||
nodes[i], specs[i] = builder.createSpec()
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, gcb.builders[i+1].mutation)
|
||||
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
|
||||
} else {
|
||||
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
||||
// Invoke the actual operation on the latest mutation in the chain.
|
||||
if err = sqlgraph.BatchCreate(ctx, gcb.driver, spec); err != nil {
|
||||
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
@@ -456,7 +456,7 @@ func (gcb *GroupCreateBulk) Save(ctx context.Context) ([]*Group, error) {
|
||||
}(i, ctx)
|
||||
}
|
||||
if len(mutators) > 0 {
|
||||
if _, err := mutators[0].Mutate(ctx, gcb.builders[0].mutation); err != nil {
|
||||
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
@@ -464,8 +464,8 @@ func (gcb *GroupCreateBulk) Save(ctx context.Context) ([]*Group, error) {
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (gcb *GroupCreateBulk) SaveX(ctx context.Context) []*Group {
|
||||
v, err := gcb.Save(ctx)
|
||||
func (_c *GroupCreateBulk) SaveX(ctx context.Context) []*Group {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -473,14 +473,14 @@ func (gcb *GroupCreateBulk) SaveX(ctx context.Context) []*Group {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (gcb *GroupCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := gcb.Save(ctx)
|
||||
func (_c *GroupCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (gcb *GroupCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := gcb.Exec(ctx); err != nil {
|
||||
func (_c *GroupCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,56 +20,56 @@ type GroupDelete struct {
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the GroupDelete builder.
|
||||
func (gd *GroupDelete) Where(ps ...predicate.Group) *GroupDelete {
|
||||
gd.mutation.Where(ps...)
|
||||
return gd
|
||||
func (_d *GroupDelete) Where(ps ...predicate.Group) *GroupDelete {
|
||||
_d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (gd *GroupDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, gd.sqlExec, gd.mutation, gd.hooks)
|
||||
func (_d *GroupDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (gd *GroupDelete) ExecX(ctx context.Context) int {
|
||||
n, err := gd.Exec(ctx)
|
||||
func (_d *GroupDelete) ExecX(ctx context.Context) int {
|
||||
n, err := _d.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (gd *GroupDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
func (_d *GroupDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := sqlgraph.NewDeleteSpec(group.Table, sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID))
|
||||
if ps := gd.mutation.predicates; len(ps) > 0 {
|
||||
if ps := _d.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, gd.driver, _spec)
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec)
|
||||
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
gd.mutation.done = true
|
||||
_d.mutation.done = true
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// GroupDeleteOne is the builder for deleting a single Group entity.
|
||||
type GroupDeleteOne struct {
|
||||
gd *GroupDelete
|
||||
_d *GroupDelete
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the GroupDelete builder.
|
||||
func (gdo *GroupDeleteOne) Where(ps ...predicate.Group) *GroupDeleteOne {
|
||||
gdo.gd.mutation.Where(ps...)
|
||||
return gdo
|
||||
func (_d *GroupDeleteOne) Where(ps ...predicate.Group) *GroupDeleteOne {
|
||||
_d._d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (gdo *GroupDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := gdo.gd.Exec(ctx)
|
||||
func (_d *GroupDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := _d._d.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
@@ -81,8 +81,8 @@ func (gdo *GroupDeleteOne) Exec(ctx context.Context) error {
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (gdo *GroupDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := gdo.Exec(ctx); err != nil {
|
||||
func (_d *GroupDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := _d.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,44 +42,44 @@ type GroupQuery struct {
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the GroupQuery builder.
|
||||
func (gq *GroupQuery) Where(ps ...predicate.Group) *GroupQuery {
|
||||
gq.predicates = append(gq.predicates, ps...)
|
||||
return gq
|
||||
func (_q *GroupQuery) Where(ps ...predicate.Group) *GroupQuery {
|
||||
_q.predicates = append(_q.predicates, ps...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// Limit the number of records to be returned by this query.
|
||||
func (gq *GroupQuery) Limit(limit int) *GroupQuery {
|
||||
gq.ctx.Limit = &limit
|
||||
return gq
|
||||
func (_q *GroupQuery) Limit(limit int) *GroupQuery {
|
||||
_q.ctx.Limit = &limit
|
||||
return _q
|
||||
}
|
||||
|
||||
// Offset to start from.
|
||||
func (gq *GroupQuery) Offset(offset int) *GroupQuery {
|
||||
gq.ctx.Offset = &offset
|
||||
return gq
|
||||
func (_q *GroupQuery) Offset(offset int) *GroupQuery {
|
||||
_q.ctx.Offset = &offset
|
||||
return _q
|
||||
}
|
||||
|
||||
// Unique configures the query builder to filter duplicate records on query.
|
||||
// By default, unique is set to true, and can be disabled using this method.
|
||||
func (gq *GroupQuery) Unique(unique bool) *GroupQuery {
|
||||
gq.ctx.Unique = &unique
|
||||
return gq
|
||||
func (_q *GroupQuery) Unique(unique bool) *GroupQuery {
|
||||
_q.ctx.Unique = &unique
|
||||
return _q
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (gq *GroupQuery) Order(o ...group.OrderOption) *GroupQuery {
|
||||
gq.order = append(gq.order, o...)
|
||||
return gq
|
||||
func (_q *GroupQuery) Order(o ...group.OrderOption) *GroupQuery {
|
||||
_q.order = append(_q.order, o...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// QueryUsers chains the current query on the "users" edge.
|
||||
func (gq *GroupQuery) QueryUsers() *UserQuery {
|
||||
query := (&UserClient{config: gq.config}).Query()
|
||||
func (_q *GroupQuery) QueryUsers() *UserQuery {
|
||||
query := (&UserClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := gq.prepareQuery(ctx); err != nil {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := gq.sqlQuery(ctx)
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -88,20 +88,20 @@ func (gq *GroupQuery) QueryUsers() *UserQuery {
|
||||
sqlgraph.To(user.Table, user.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, group.UsersTable, group.UsersColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(gq.driver.Dialect(), step)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryEntities chains the current query on the "entities" edge.
|
||||
func (gq *GroupQuery) QueryEntities() *EntityQuery {
|
||||
query := (&EntityClient{config: gq.config}).Query()
|
||||
func (_q *GroupQuery) QueryEntities() *EntityQuery {
|
||||
query := (&EntityClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := gq.prepareQuery(ctx); err != nil {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := gq.sqlQuery(ctx)
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -110,20 +110,20 @@ func (gq *GroupQuery) QueryEntities() *EntityQuery {
|
||||
sqlgraph.To(entity.Table, entity.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, group.EntitiesTable, group.EntitiesColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(gq.driver.Dialect(), step)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryLabels chains the current query on the "labels" edge.
|
||||
func (gq *GroupQuery) QueryLabels() *LabelQuery {
|
||||
query := (&LabelClient{config: gq.config}).Query()
|
||||
func (_q *GroupQuery) QueryLabels() *LabelQuery {
|
||||
query := (&LabelClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := gq.prepareQuery(ctx); err != nil {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := gq.sqlQuery(ctx)
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -132,20 +132,20 @@ func (gq *GroupQuery) QueryLabels() *LabelQuery {
|
||||
sqlgraph.To(label.Table, label.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, group.LabelsTable, group.LabelsColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(gq.driver.Dialect(), step)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryInvitationTokens chains the current query on the "invitation_tokens" edge.
|
||||
func (gq *GroupQuery) QueryInvitationTokens() *GroupInvitationTokenQuery {
|
||||
query := (&GroupInvitationTokenClient{config: gq.config}).Query()
|
||||
func (_q *GroupQuery) QueryInvitationTokens() *GroupInvitationTokenQuery {
|
||||
query := (&GroupInvitationTokenClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := gq.prepareQuery(ctx); err != nil {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := gq.sqlQuery(ctx)
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -154,20 +154,20 @@ func (gq *GroupQuery) QueryInvitationTokens() *GroupInvitationTokenQuery {
|
||||
sqlgraph.To(groupinvitationtoken.Table, groupinvitationtoken.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, group.InvitationTokensTable, group.InvitationTokensColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(gq.driver.Dialect(), step)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryNotifiers chains the current query on the "notifiers" edge.
|
||||
func (gq *GroupQuery) QueryNotifiers() *NotifierQuery {
|
||||
query := (&NotifierClient{config: gq.config}).Query()
|
||||
func (_q *GroupQuery) QueryNotifiers() *NotifierQuery {
|
||||
query := (&NotifierClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := gq.prepareQuery(ctx); err != nil {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := gq.sqlQuery(ctx)
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -176,20 +176,20 @@ func (gq *GroupQuery) QueryNotifiers() *NotifierQuery {
|
||||
sqlgraph.To(notifier.Table, notifier.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, group.NotifiersTable, group.NotifiersColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(gq.driver.Dialect(), step)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryEntityTypes chains the current query on the "entity_types" edge.
|
||||
func (gq *GroupQuery) QueryEntityTypes() *EntityTypeQuery {
|
||||
query := (&EntityTypeClient{config: gq.config}).Query()
|
||||
func (_q *GroupQuery) QueryEntityTypes() *EntityTypeQuery {
|
||||
query := (&EntityTypeClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := gq.prepareQuery(ctx); err != nil {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := gq.sqlQuery(ctx)
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -198,7 +198,7 @@ func (gq *GroupQuery) QueryEntityTypes() *EntityTypeQuery {
|
||||
sqlgraph.To(entitytype.Table, entitytype.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, group.EntityTypesTable, group.EntityTypesColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(gq.driver.Dialect(), step)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
@@ -206,8 +206,8 @@ func (gq *GroupQuery) QueryEntityTypes() *EntityTypeQuery {
|
||||
|
||||
// First returns the first Group entity from the query.
|
||||
// Returns a *NotFoundError when no Group was found.
|
||||
func (gq *GroupQuery) First(ctx context.Context) (*Group, error) {
|
||||
nodes, err := gq.Limit(1).All(setContextOp(ctx, gq.ctx, ent.OpQueryFirst))
|
||||
func (_q *GroupQuery) First(ctx context.Context) (*Group, error) {
|
||||
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -218,8 +218,8 @@ func (gq *GroupQuery) First(ctx context.Context) (*Group, error) {
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (gq *GroupQuery) FirstX(ctx context.Context) *Group {
|
||||
node, err := gq.First(ctx)
|
||||
func (_q *GroupQuery) FirstX(ctx context.Context) *Group {
|
||||
node, err := _q.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
@@ -228,9 +228,9 @@ func (gq *GroupQuery) FirstX(ctx context.Context) *Group {
|
||||
|
||||
// FirstID returns the first Group ID from the query.
|
||||
// Returns a *NotFoundError when no Group ID was found.
|
||||
func (gq *GroupQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
func (_q *GroupQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
var ids []uuid.UUID
|
||||
if ids, err = gq.Limit(1).IDs(setContextOp(ctx, gq.ctx, ent.OpQueryFirstID)); err != nil {
|
||||
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
@@ -241,8 +241,8 @@ func (gq *GroupQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (gq *GroupQuery) FirstIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := gq.FirstID(ctx)
|
||||
func (_q *GroupQuery) FirstIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := _q.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
@@ -252,8 +252,8 @@ func (gq *GroupQuery) FirstIDX(ctx context.Context) uuid.UUID {
|
||||
// Only returns a single Group entity found by the query, ensuring it only returns one.
|
||||
// Returns a *NotSingularError when more than one Group entity is found.
|
||||
// Returns a *NotFoundError when no Group entities are found.
|
||||
func (gq *GroupQuery) Only(ctx context.Context) (*Group, error) {
|
||||
nodes, err := gq.Limit(2).All(setContextOp(ctx, gq.ctx, ent.OpQueryOnly))
|
||||
func (_q *GroupQuery) Only(ctx context.Context) (*Group, error) {
|
||||
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -268,8 +268,8 @@ func (gq *GroupQuery) Only(ctx context.Context) (*Group, error) {
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (gq *GroupQuery) OnlyX(ctx context.Context) *Group {
|
||||
node, err := gq.Only(ctx)
|
||||
func (_q *GroupQuery) OnlyX(ctx context.Context) *Group {
|
||||
node, err := _q.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -279,9 +279,9 @@ func (gq *GroupQuery) OnlyX(ctx context.Context) *Group {
|
||||
// OnlyID is like Only, but returns the only Group ID in the query.
|
||||
// Returns a *NotSingularError when more than one Group ID is found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (gq *GroupQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
func (_q *GroupQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
var ids []uuid.UUID
|
||||
if ids, err = gq.Limit(2).IDs(setContextOp(ctx, gq.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
@@ -296,8 +296,8 @@ func (gq *GroupQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (gq *GroupQuery) OnlyIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := gq.OnlyID(ctx)
|
||||
func (_q *GroupQuery) OnlyIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := _q.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -305,18 +305,18 @@ func (gq *GroupQuery) OnlyIDX(ctx context.Context) uuid.UUID {
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of Groups.
|
||||
func (gq *GroupQuery) All(ctx context.Context) ([]*Group, error) {
|
||||
ctx = setContextOp(ctx, gq.ctx, ent.OpQueryAll)
|
||||
if err := gq.prepareQuery(ctx); err != nil {
|
||||
func (_q *GroupQuery) All(ctx context.Context) ([]*Group, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qr := querierAll[[]*Group, *GroupQuery]()
|
||||
return withInterceptors[[]*Group](ctx, gq, qr, gq.inters)
|
||||
return withInterceptors[[]*Group](ctx, _q, qr, _q.inters)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (gq *GroupQuery) AllX(ctx context.Context) []*Group {
|
||||
nodes, err := gq.All(ctx)
|
||||
func (_q *GroupQuery) AllX(ctx context.Context) []*Group {
|
||||
nodes, err := _q.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -324,20 +324,20 @@ func (gq *GroupQuery) AllX(ctx context.Context) []*Group {
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of Group IDs.
|
||||
func (gq *GroupQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
|
||||
if gq.ctx.Unique == nil && gq.path != nil {
|
||||
gq.Unique(true)
|
||||
func (_q *GroupQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
|
||||
if _q.ctx.Unique == nil && _q.path != nil {
|
||||
_q.Unique(true)
|
||||
}
|
||||
ctx = setContextOp(ctx, gq.ctx, ent.OpQueryIDs)
|
||||
if err = gq.Select(group.FieldID).Scan(ctx, &ids); err != nil {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
|
||||
if err = _q.Select(group.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (gq *GroupQuery) IDsX(ctx context.Context) []uuid.UUID {
|
||||
ids, err := gq.IDs(ctx)
|
||||
func (_q *GroupQuery) IDsX(ctx context.Context) []uuid.UUID {
|
||||
ids, err := _q.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -345,17 +345,17 @@ func (gq *GroupQuery) IDsX(ctx context.Context) []uuid.UUID {
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (gq *GroupQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, gq.ctx, ent.OpQueryCount)
|
||||
if err := gq.prepareQuery(ctx); err != nil {
|
||||
func (_q *GroupQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return withInterceptors[int](ctx, gq, querierCount[*GroupQuery](), gq.inters)
|
||||
return withInterceptors[int](ctx, _q, querierCount[*GroupQuery](), _q.inters)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (gq *GroupQuery) CountX(ctx context.Context) int {
|
||||
count, err := gq.Count(ctx)
|
||||
func (_q *GroupQuery) CountX(ctx context.Context) int {
|
||||
count, err := _q.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -363,9 +363,9 @@ func (gq *GroupQuery) CountX(ctx context.Context) int {
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (gq *GroupQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, gq.ctx, ent.OpQueryExist)
|
||||
switch _, err := gq.FirstID(ctx); {
|
||||
func (_q *GroupQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
|
||||
switch _, err := _q.FirstID(ctx); {
|
||||
case IsNotFound(err):
|
||||
return false, nil
|
||||
case err != nil:
|
||||
@@ -376,8 +376,8 @@ func (gq *GroupQuery) Exist(ctx context.Context) (bool, error) {
|
||||
}
|
||||
|
||||
// ExistX is like Exist, but panics if an error occurs.
|
||||
func (gq *GroupQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := gq.Exist(ctx)
|
||||
func (_q *GroupQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := _q.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -386,92 +386,92 @@ func (gq *GroupQuery) ExistX(ctx context.Context) bool {
|
||||
|
||||
// Clone returns a duplicate of the GroupQuery builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (gq *GroupQuery) Clone() *GroupQuery {
|
||||
if gq == nil {
|
||||
func (_q *GroupQuery) Clone() *GroupQuery {
|
||||
if _q == nil {
|
||||
return nil
|
||||
}
|
||||
return &GroupQuery{
|
||||
config: gq.config,
|
||||
ctx: gq.ctx.Clone(),
|
||||
order: append([]group.OrderOption{}, gq.order...),
|
||||
inters: append([]Interceptor{}, gq.inters...),
|
||||
predicates: append([]predicate.Group{}, gq.predicates...),
|
||||
withUsers: gq.withUsers.Clone(),
|
||||
withEntities: gq.withEntities.Clone(),
|
||||
withLabels: gq.withLabels.Clone(),
|
||||
withInvitationTokens: gq.withInvitationTokens.Clone(),
|
||||
withNotifiers: gq.withNotifiers.Clone(),
|
||||
withEntityTypes: gq.withEntityTypes.Clone(),
|
||||
config: _q.config,
|
||||
ctx: _q.ctx.Clone(),
|
||||
order: append([]group.OrderOption{}, _q.order...),
|
||||
inters: append([]Interceptor{}, _q.inters...),
|
||||
predicates: append([]predicate.Group{}, _q.predicates...),
|
||||
withUsers: _q.withUsers.Clone(),
|
||||
withEntities: _q.withEntities.Clone(),
|
||||
withLabels: _q.withLabels.Clone(),
|
||||
withInvitationTokens: _q.withInvitationTokens.Clone(),
|
||||
withNotifiers: _q.withNotifiers.Clone(),
|
||||
withEntityTypes: _q.withEntityTypes.Clone(),
|
||||
// clone intermediate query.
|
||||
sql: gq.sql.Clone(),
|
||||
path: gq.path,
|
||||
sql: _q.sql.Clone(),
|
||||
path: _q.path,
|
||||
}
|
||||
}
|
||||
|
||||
// WithUsers tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "users" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (gq *GroupQuery) WithUsers(opts ...func(*UserQuery)) *GroupQuery {
|
||||
query := (&UserClient{config: gq.config}).Query()
|
||||
func (_q *GroupQuery) WithUsers(opts ...func(*UserQuery)) *GroupQuery {
|
||||
query := (&UserClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
gq.withUsers = query
|
||||
return gq
|
||||
_q.withUsers = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// WithEntities tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "entities" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (gq *GroupQuery) WithEntities(opts ...func(*EntityQuery)) *GroupQuery {
|
||||
query := (&EntityClient{config: gq.config}).Query()
|
||||
func (_q *GroupQuery) WithEntities(opts ...func(*EntityQuery)) *GroupQuery {
|
||||
query := (&EntityClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
gq.withEntities = query
|
||||
return gq
|
||||
_q.withEntities = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// WithLabels tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "labels" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (gq *GroupQuery) WithLabels(opts ...func(*LabelQuery)) *GroupQuery {
|
||||
query := (&LabelClient{config: gq.config}).Query()
|
||||
func (_q *GroupQuery) WithLabels(opts ...func(*LabelQuery)) *GroupQuery {
|
||||
query := (&LabelClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
gq.withLabels = query
|
||||
return gq
|
||||
_q.withLabels = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// WithInvitationTokens tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "invitation_tokens" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (gq *GroupQuery) WithInvitationTokens(opts ...func(*GroupInvitationTokenQuery)) *GroupQuery {
|
||||
query := (&GroupInvitationTokenClient{config: gq.config}).Query()
|
||||
func (_q *GroupQuery) WithInvitationTokens(opts ...func(*GroupInvitationTokenQuery)) *GroupQuery {
|
||||
query := (&GroupInvitationTokenClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
gq.withInvitationTokens = query
|
||||
return gq
|
||||
_q.withInvitationTokens = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// WithNotifiers tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "notifiers" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (gq *GroupQuery) WithNotifiers(opts ...func(*NotifierQuery)) *GroupQuery {
|
||||
query := (&NotifierClient{config: gq.config}).Query()
|
||||
func (_q *GroupQuery) WithNotifiers(opts ...func(*NotifierQuery)) *GroupQuery {
|
||||
query := (&NotifierClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
gq.withNotifiers = query
|
||||
return gq
|
||||
_q.withNotifiers = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// WithEntityTypes tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "entity_types" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (gq *GroupQuery) WithEntityTypes(opts ...func(*EntityTypeQuery)) *GroupQuery {
|
||||
query := (&EntityTypeClient{config: gq.config}).Query()
|
||||
func (_q *GroupQuery) WithEntityTypes(opts ...func(*EntityTypeQuery)) *GroupQuery {
|
||||
query := (&EntityTypeClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
gq.withEntityTypes = query
|
||||
return gq
|
||||
_q.withEntityTypes = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// GroupBy is used to group vertices by one or more fields/columns.
|
||||
@@ -488,10 +488,10 @@ func (gq *GroupQuery) WithEntityTypes(opts ...func(*EntityTypeQuery)) *GroupQuer
|
||||
// GroupBy(group.FieldCreatedAt).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (gq *GroupQuery) GroupBy(field string, fields ...string) *GroupGroupBy {
|
||||
gq.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &GroupGroupBy{build: gq}
|
||||
grbuild.flds = &gq.ctx.Fields
|
||||
func (_q *GroupQuery) GroupBy(field string, fields ...string) *GroupGroupBy {
|
||||
_q.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &GroupGroupBy{build: _q}
|
||||
grbuild.flds = &_q.ctx.Fields
|
||||
grbuild.label = group.Label
|
||||
grbuild.scan = grbuild.Scan
|
||||
return grbuild
|
||||
@@ -509,63 +509,63 @@ func (gq *GroupQuery) GroupBy(field string, fields ...string) *GroupGroupBy {
|
||||
// client.Group.Query().
|
||||
// Select(group.FieldCreatedAt).
|
||||
// Scan(ctx, &v)
|
||||
func (gq *GroupQuery) Select(fields ...string) *GroupSelect {
|
||||
gq.ctx.Fields = append(gq.ctx.Fields, fields...)
|
||||
sbuild := &GroupSelect{GroupQuery: gq}
|
||||
func (_q *GroupQuery) Select(fields ...string) *GroupSelect {
|
||||
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
||||
sbuild := &GroupSelect{GroupQuery: _q}
|
||||
sbuild.label = group.Label
|
||||
sbuild.flds, sbuild.scan = &gq.ctx.Fields, sbuild.Scan
|
||||
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
|
||||
return sbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a GroupSelect configured with the given aggregations.
|
||||
func (gq *GroupQuery) Aggregate(fns ...AggregateFunc) *GroupSelect {
|
||||
return gq.Select().Aggregate(fns...)
|
||||
func (_q *GroupQuery) Aggregate(fns ...AggregateFunc) *GroupSelect {
|
||||
return _q.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (gq *GroupQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range gq.inters {
|
||||
func (_q *GroupQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range _q.inters {
|
||||
if inter == nil {
|
||||
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
|
||||
}
|
||||
if trv, ok := inter.(Traverser); ok {
|
||||
if err := trv.Traverse(ctx, gq); err != nil {
|
||||
if err := trv.Traverse(ctx, _q); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, f := range gq.ctx.Fields {
|
||||
for _, f := range _q.ctx.Fields {
|
||||
if !group.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
}
|
||||
if gq.path != nil {
|
||||
prev, err := gq.path(ctx)
|
||||
if _q.path != nil {
|
||||
prev, err := _q.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
gq.sql = prev
|
||||
_q.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (gq *GroupQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Group, error) {
|
||||
func (_q *GroupQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Group, error) {
|
||||
var (
|
||||
nodes = []*Group{}
|
||||
_spec = gq.querySpec()
|
||||
_spec = _q.querySpec()
|
||||
loadedTypes = [6]bool{
|
||||
gq.withUsers != nil,
|
||||
gq.withEntities != nil,
|
||||
gq.withLabels != nil,
|
||||
gq.withInvitationTokens != nil,
|
||||
gq.withNotifiers != nil,
|
||||
gq.withEntityTypes != nil,
|
||||
_q.withUsers != nil,
|
||||
_q.withEntities != nil,
|
||||
_q.withLabels != nil,
|
||||
_q.withInvitationTokens != nil,
|
||||
_q.withNotifiers != nil,
|
||||
_q.withEntityTypes != nil,
|
||||
}
|
||||
)
|
||||
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||
return (*Group).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &Group{config: gq.config}
|
||||
node := &Group{config: _q.config}
|
||||
nodes = append(nodes, node)
|
||||
node.Edges.loadedTypes = loadedTypes
|
||||
return node.assignValues(columns, values)
|
||||
@@ -573,35 +573,35 @@ func (gq *GroupQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Group,
|
||||
for i := range hooks {
|
||||
hooks[i](ctx, _spec)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, gq.driver, _spec); err != nil {
|
||||
if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
if query := gq.withUsers; query != nil {
|
||||
if err := gq.loadUsers(ctx, query, nodes,
|
||||
if query := _q.withUsers; query != nil {
|
||||
if err := _q.loadUsers(ctx, query, nodes,
|
||||
func(n *Group) { n.Edges.Users = []*User{} },
|
||||
func(n *Group, e *User) { n.Edges.Users = append(n.Edges.Users, e) }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if query := gq.withEntities; query != nil {
|
||||
if err := gq.loadEntities(ctx, query, nodes,
|
||||
if query := _q.withEntities; query != nil {
|
||||
if err := _q.loadEntities(ctx, query, nodes,
|
||||
func(n *Group) { n.Edges.Entities = []*Entity{} },
|
||||
func(n *Group, e *Entity) { n.Edges.Entities = append(n.Edges.Entities, e) }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if query := gq.withLabels; query != nil {
|
||||
if err := gq.loadLabels(ctx, query, nodes,
|
||||
if query := _q.withLabels; query != nil {
|
||||
if err := _q.loadLabels(ctx, query, nodes,
|
||||
func(n *Group) { n.Edges.Labels = []*Label{} },
|
||||
func(n *Group, e *Label) { n.Edges.Labels = append(n.Edges.Labels, e) }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if query := gq.withInvitationTokens; query != nil {
|
||||
if err := gq.loadInvitationTokens(ctx, query, nodes,
|
||||
if query := _q.withInvitationTokens; query != nil {
|
||||
if err := _q.loadInvitationTokens(ctx, query, nodes,
|
||||
func(n *Group) { n.Edges.InvitationTokens = []*GroupInvitationToken{} },
|
||||
func(n *Group, e *GroupInvitationToken) {
|
||||
n.Edges.InvitationTokens = append(n.Edges.InvitationTokens, e)
|
||||
@@ -609,15 +609,15 @@ func (gq *GroupQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Group,
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if query := gq.withNotifiers; query != nil {
|
||||
if err := gq.loadNotifiers(ctx, query, nodes,
|
||||
if query := _q.withNotifiers; query != nil {
|
||||
if err := _q.loadNotifiers(ctx, query, nodes,
|
||||
func(n *Group) { n.Edges.Notifiers = []*Notifier{} },
|
||||
func(n *Group, e *Notifier) { n.Edges.Notifiers = append(n.Edges.Notifiers, e) }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if query := gq.withEntityTypes; query != nil {
|
||||
if err := gq.loadEntityTypes(ctx, query, nodes,
|
||||
if query := _q.withEntityTypes; query != nil {
|
||||
if err := _q.loadEntityTypes(ctx, query, nodes,
|
||||
func(n *Group) { n.Edges.EntityTypes = []*EntityType{} },
|
||||
func(n *Group, e *EntityType) { n.Edges.EntityTypes = append(n.Edges.EntityTypes, e) }); err != nil {
|
||||
return nil, err
|
||||
@@ -626,7 +626,7 @@ func (gq *GroupQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Group,
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (gq *GroupQuery) loadUsers(ctx context.Context, query *UserQuery, nodes []*Group, init func(*Group), assign func(*Group, *User)) error {
|
||||
func (_q *GroupQuery) loadUsers(ctx context.Context, query *UserQuery, nodes []*Group, init func(*Group), assign func(*Group, *User)) error {
|
||||
fks := make([]driver.Value, 0, len(nodes))
|
||||
nodeids := make(map[uuid.UUID]*Group)
|
||||
for i := range nodes {
|
||||
@@ -657,7 +657,7 @@ func (gq *GroupQuery) loadUsers(ctx context.Context, query *UserQuery, nodes []*
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (gq *GroupQuery) loadEntities(ctx context.Context, query *EntityQuery, nodes []*Group, init func(*Group), assign func(*Group, *Entity)) error {
|
||||
func (_q *GroupQuery) loadEntities(ctx context.Context, query *EntityQuery, nodes []*Group, init func(*Group), assign func(*Group, *Entity)) error {
|
||||
fks := make([]driver.Value, 0, len(nodes))
|
||||
nodeids := make(map[uuid.UUID]*Group)
|
||||
for i := range nodes {
|
||||
@@ -688,7 +688,7 @@ func (gq *GroupQuery) loadEntities(ctx context.Context, query *EntityQuery, node
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (gq *GroupQuery) loadLabels(ctx context.Context, query *LabelQuery, nodes []*Group, init func(*Group), assign func(*Group, *Label)) error {
|
||||
func (_q *GroupQuery) loadLabels(ctx context.Context, query *LabelQuery, nodes []*Group, init func(*Group), assign func(*Group, *Label)) error {
|
||||
fks := make([]driver.Value, 0, len(nodes))
|
||||
nodeids := make(map[uuid.UUID]*Group)
|
||||
for i := range nodes {
|
||||
@@ -719,7 +719,7 @@ func (gq *GroupQuery) loadLabels(ctx context.Context, query *LabelQuery, nodes [
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (gq *GroupQuery) loadInvitationTokens(ctx context.Context, query *GroupInvitationTokenQuery, nodes []*Group, init func(*Group), assign func(*Group, *GroupInvitationToken)) error {
|
||||
func (_q *GroupQuery) loadInvitationTokens(ctx context.Context, query *GroupInvitationTokenQuery, nodes []*Group, init func(*Group), assign func(*Group, *GroupInvitationToken)) error {
|
||||
fks := make([]driver.Value, 0, len(nodes))
|
||||
nodeids := make(map[uuid.UUID]*Group)
|
||||
for i := range nodes {
|
||||
@@ -750,7 +750,7 @@ func (gq *GroupQuery) loadInvitationTokens(ctx context.Context, query *GroupInvi
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (gq *GroupQuery) loadNotifiers(ctx context.Context, query *NotifierQuery, nodes []*Group, init func(*Group), assign func(*Group, *Notifier)) error {
|
||||
func (_q *GroupQuery) loadNotifiers(ctx context.Context, query *NotifierQuery, nodes []*Group, init func(*Group), assign func(*Group, *Notifier)) error {
|
||||
fks := make([]driver.Value, 0, len(nodes))
|
||||
nodeids := make(map[uuid.UUID]*Group)
|
||||
for i := range nodes {
|
||||
@@ -780,7 +780,7 @@ func (gq *GroupQuery) loadNotifiers(ctx context.Context, query *NotifierQuery, n
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (gq *GroupQuery) loadEntityTypes(ctx context.Context, query *EntityTypeQuery, nodes []*Group, init func(*Group), assign func(*Group, *EntityType)) error {
|
||||
func (_q *GroupQuery) loadEntityTypes(ctx context.Context, query *EntityTypeQuery, nodes []*Group, init func(*Group), assign func(*Group, *EntityType)) error {
|
||||
fks := make([]driver.Value, 0, len(nodes))
|
||||
nodeids := make(map[uuid.UUID]*Group)
|
||||
for i := range nodes {
|
||||
@@ -812,24 +812,24 @@ func (gq *GroupQuery) loadEntityTypes(ctx context.Context, query *EntityTypeQuer
|
||||
return nil
|
||||
}
|
||||
|
||||
func (gq *GroupQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := gq.querySpec()
|
||||
_spec.Node.Columns = gq.ctx.Fields
|
||||
if len(gq.ctx.Fields) > 0 {
|
||||
_spec.Unique = gq.ctx.Unique != nil && *gq.ctx.Unique
|
||||
func (_q *GroupQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := _q.querySpec()
|
||||
_spec.Node.Columns = _q.ctx.Fields
|
||||
if len(_q.ctx.Fields) > 0 {
|
||||
_spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, gq.driver, _spec)
|
||||
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
|
||||
}
|
||||
|
||||
func (gq *GroupQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
func (_q *GroupQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := sqlgraph.NewQuerySpec(group.Table, group.Columns, sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID))
|
||||
_spec.From = gq.sql
|
||||
if unique := gq.ctx.Unique; unique != nil {
|
||||
_spec.From = _q.sql
|
||||
if unique := _q.ctx.Unique; unique != nil {
|
||||
_spec.Unique = *unique
|
||||
} else if gq.path != nil {
|
||||
} else if _q.path != nil {
|
||||
_spec.Unique = true
|
||||
}
|
||||
if fields := gq.ctx.Fields; len(fields) > 0 {
|
||||
if fields := _q.ctx.Fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, group.FieldID)
|
||||
for i := range fields {
|
||||
@@ -838,20 +838,20 @@ func (gq *GroupQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := gq.predicates; len(ps) > 0 {
|
||||
if ps := _q.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := gq.ctx.Limit; limit != nil {
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := gq.ctx.Offset; offset != nil {
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := gq.order; len(ps) > 0 {
|
||||
if ps := _q.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
@@ -861,33 +861,33 @@ func (gq *GroupQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (gq *GroupQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(gq.driver.Dialect())
|
||||
func (_q *GroupQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(_q.driver.Dialect())
|
||||
t1 := builder.Table(group.Table)
|
||||
columns := gq.ctx.Fields
|
||||
columns := _q.ctx.Fields
|
||||
if len(columns) == 0 {
|
||||
columns = group.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if gq.sql != nil {
|
||||
selector = gq.sql
|
||||
if _q.sql != nil {
|
||||
selector = _q.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
if gq.ctx.Unique != nil && *gq.ctx.Unique {
|
||||
if _q.ctx.Unique != nil && *_q.ctx.Unique {
|
||||
selector.Distinct()
|
||||
}
|
||||
for _, p := range gq.predicates {
|
||||
for _, p := range _q.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range gq.order {
|
||||
for _, p := range _q.order {
|
||||
p(selector)
|
||||
}
|
||||
if offset := gq.ctx.Offset; offset != nil {
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
// limit is mandatory for offset clause. We start
|
||||
// with default value, and override it below if needed.
|
||||
selector.Offset(*offset).Limit(math.MaxInt32)
|
||||
}
|
||||
if limit := gq.ctx.Limit; limit != nil {
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
@@ -900,41 +900,41 @@ type GroupGroupBy struct {
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (ggb *GroupGroupBy) Aggregate(fns ...AggregateFunc) *GroupGroupBy {
|
||||
ggb.fns = append(ggb.fns, fns...)
|
||||
return ggb
|
||||
func (_g *GroupGroupBy) Aggregate(fns ...AggregateFunc) *GroupGroupBy {
|
||||
_g.fns = append(_g.fns, fns...)
|
||||
return _g
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (ggb *GroupGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, ggb.build.ctx, ent.OpQueryGroupBy)
|
||||
if err := ggb.build.prepareQuery(ctx); err != nil {
|
||||
func (_g *GroupGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
|
||||
if err := _g.build.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*GroupQuery, *GroupGroupBy](ctx, ggb.build, ggb, ggb.build.inters, v)
|
||||
return scanWithInterceptors[*GroupQuery, *GroupGroupBy](ctx, _g.build, _g, _g.build.inters, v)
|
||||
}
|
||||
|
||||
func (ggb *GroupGroupBy) sqlScan(ctx context.Context, root *GroupQuery, v any) error {
|
||||
func (_g *GroupGroupBy) sqlScan(ctx context.Context, root *GroupQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx).Select()
|
||||
aggregation := make([]string, 0, len(ggb.fns))
|
||||
for _, fn := range ggb.fns {
|
||||
aggregation := make([]string, 0, len(_g.fns))
|
||||
for _, fn := range _g.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(*ggb.flds)+len(ggb.fns))
|
||||
for _, f := range *ggb.flds {
|
||||
columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
|
||||
for _, f := range *_g.flds {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
columns = append(columns, aggregation...)
|
||||
selector.Select(columns...)
|
||||
}
|
||||
selector.GroupBy(selector.Columns(*ggb.flds...)...)
|
||||
selector.GroupBy(selector.Columns(*_g.flds...)...)
|
||||
if err := selector.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := ggb.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
@@ -948,27 +948,27 @@ type GroupSelect struct {
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (gs *GroupSelect) Aggregate(fns ...AggregateFunc) *GroupSelect {
|
||||
gs.fns = append(gs.fns, fns...)
|
||||
return gs
|
||||
func (_s *GroupSelect) Aggregate(fns ...AggregateFunc) *GroupSelect {
|
||||
_s.fns = append(_s.fns, fns...)
|
||||
return _s
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (gs *GroupSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, gs.ctx, ent.OpQuerySelect)
|
||||
if err := gs.prepareQuery(ctx); err != nil {
|
||||
func (_s *GroupSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
|
||||
if err := _s.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*GroupQuery, *GroupSelect](ctx, gs.GroupQuery, gs, gs.inters, v)
|
||||
return scanWithInterceptors[*GroupQuery, *GroupSelect](ctx, _s.GroupQuery, _s, _s.inters, v)
|
||||
}
|
||||
|
||||
func (gs *GroupSelect) sqlScan(ctx context.Context, root *GroupQuery, v any) error {
|
||||
func (_s *GroupSelect) sqlScan(ctx context.Context, root *GroupQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx)
|
||||
aggregation := make([]string, 0, len(gs.fns))
|
||||
for _, fn := range gs.fns {
|
||||
aggregation := make([]string, 0, len(_s.fns))
|
||||
for _, fn := range _s.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
switch n := len(*gs.selector.flds); {
|
||||
switch n := len(*_s.selector.flds); {
|
||||
case n == 0 && len(aggregation) > 0:
|
||||
selector.Select(aggregation...)
|
||||
case n != 0 && len(aggregation) > 0:
|
||||
@@ -976,7 +976,7 @@ func (gs *GroupSelect) sqlScan(ctx context.Context, root *GroupQuery, v any) err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := gs.driver.Query(ctx, query, args, rows); err != nil {
|
||||
if err := _s.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -80,7 +80,7 @@ func (*GroupInvitationToken) scanValues(columns []string) ([]any, error) {
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the GroupInvitationToken fields.
|
||||
func (git *GroupInvitationToken) assignValues(columns []string, values []any) error {
|
||||
func (_m *GroupInvitationToken) assignValues(columns []string, values []any) error {
|
||||
if m, n := len(values), len(columns); m < n {
|
||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||
}
|
||||
@@ -90,47 +90,47 @@ func (git *GroupInvitationToken) assignValues(columns []string, values []any) er
|
||||
if value, ok := values[i].(*uuid.UUID); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", values[i])
|
||||
} else if value != nil {
|
||||
git.ID = *value
|
||||
_m.ID = *value
|
||||
}
|
||||
case groupinvitationtoken.FieldCreatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
||||
} else if value.Valid {
|
||||
git.CreatedAt = value.Time
|
||||
_m.CreatedAt = value.Time
|
||||
}
|
||||
case groupinvitationtoken.FieldUpdatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
|
||||
} else if value.Valid {
|
||||
git.UpdatedAt = value.Time
|
||||
_m.UpdatedAt = value.Time
|
||||
}
|
||||
case groupinvitationtoken.FieldToken:
|
||||
if value, ok := values[i].(*[]byte); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field token", values[i])
|
||||
} else if value != nil {
|
||||
git.Token = *value
|
||||
_m.Token = *value
|
||||
}
|
||||
case groupinvitationtoken.FieldExpiresAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field expires_at", values[i])
|
||||
} else if value.Valid {
|
||||
git.ExpiresAt = value.Time
|
||||
_m.ExpiresAt = value.Time
|
||||
}
|
||||
case groupinvitationtoken.FieldUses:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field uses", values[i])
|
||||
} else if value.Valid {
|
||||
git.Uses = int(value.Int64)
|
||||
_m.Uses = int(value.Int64)
|
||||
}
|
||||
case groupinvitationtoken.ForeignKeys[0]:
|
||||
if value, ok := values[i].(*sql.NullScanner); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field group_invitation_tokens", values[i])
|
||||
} else if value.Valid {
|
||||
git.group_invitation_tokens = new(uuid.UUID)
|
||||
*git.group_invitation_tokens = *value.S.(*uuid.UUID)
|
||||
_m.group_invitation_tokens = new(uuid.UUID)
|
||||
*_m.group_invitation_tokens = *value.S.(*uuid.UUID)
|
||||
}
|
||||
default:
|
||||
git.selectValues.Set(columns[i], values[i])
|
||||
_m.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -138,52 +138,52 @@ func (git *GroupInvitationToken) assignValues(columns []string, values []any) er
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the GroupInvitationToken.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (git *GroupInvitationToken) Value(name string) (ent.Value, error) {
|
||||
return git.selectValues.Get(name)
|
||||
func (_m *GroupInvitationToken) Value(name string) (ent.Value, error) {
|
||||
return _m.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// QueryGroup queries the "group" edge of the GroupInvitationToken entity.
|
||||
func (git *GroupInvitationToken) QueryGroup() *GroupQuery {
|
||||
return NewGroupInvitationTokenClient(git.config).QueryGroup(git)
|
||||
func (_m *GroupInvitationToken) QueryGroup() *GroupQuery {
|
||||
return NewGroupInvitationTokenClient(_m.config).QueryGroup(_m)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this GroupInvitationToken.
|
||||
// Note that you need to call GroupInvitationToken.Unwrap() before calling this method if this GroupInvitationToken
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (git *GroupInvitationToken) Update() *GroupInvitationTokenUpdateOne {
|
||||
return NewGroupInvitationTokenClient(git.config).UpdateOne(git)
|
||||
func (_m *GroupInvitationToken) Update() *GroupInvitationTokenUpdateOne {
|
||||
return NewGroupInvitationTokenClient(_m.config).UpdateOne(_m)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the GroupInvitationToken entity that was returned from a transaction after it was closed,
|
||||
// so that all future queries will be executed through the driver which created the transaction.
|
||||
func (git *GroupInvitationToken) Unwrap() *GroupInvitationToken {
|
||||
_tx, ok := git.config.driver.(*txDriver)
|
||||
func (_m *GroupInvitationToken) Unwrap() *GroupInvitationToken {
|
||||
_tx, ok := _m.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: GroupInvitationToken is not a transactional entity")
|
||||
}
|
||||
git.config.driver = _tx.drv
|
||||
return git
|
||||
_m.config.driver = _tx.drv
|
||||
return _m
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (git *GroupInvitationToken) String() string {
|
||||
func (_m *GroupInvitationToken) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("GroupInvitationToken(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", git.ID))
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||||
builder.WriteString("created_at=")
|
||||
builder.WriteString(git.CreatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("updated_at=")
|
||||
builder.WriteString(git.UpdatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("token=")
|
||||
builder.WriteString(fmt.Sprintf("%v", git.Token))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Token))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("expires_at=")
|
||||
builder.WriteString(git.ExpiresAt.Format(time.ANSIC))
|
||||
builder.WriteString(_m.ExpiresAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("uses=")
|
||||
builder.WriteString(fmt.Sprintf("%v", git.Uses))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Uses))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
@@ -23,114 +23,114 @@ type GroupInvitationTokenCreate struct {
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (gitc *GroupInvitationTokenCreate) SetCreatedAt(t time.Time) *GroupInvitationTokenCreate {
|
||||
gitc.mutation.SetCreatedAt(t)
|
||||
return gitc
|
||||
func (_c *GroupInvitationTokenCreate) SetCreatedAt(v time.Time) *GroupInvitationTokenCreate {
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||
func (gitc *GroupInvitationTokenCreate) SetNillableCreatedAt(t *time.Time) *GroupInvitationTokenCreate {
|
||||
if t != nil {
|
||||
gitc.SetCreatedAt(*t)
|
||||
func (_c *GroupInvitationTokenCreate) SetNillableCreatedAt(v *time.Time) *GroupInvitationTokenCreate {
|
||||
if v != nil {
|
||||
_c.SetCreatedAt(*v)
|
||||
}
|
||||
return gitc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (gitc *GroupInvitationTokenCreate) SetUpdatedAt(t time.Time) *GroupInvitationTokenCreate {
|
||||
gitc.mutation.SetUpdatedAt(t)
|
||||
return gitc
|
||||
func (_c *GroupInvitationTokenCreate) SetUpdatedAt(v time.Time) *GroupInvitationTokenCreate {
|
||||
_c.mutation.SetUpdatedAt(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
||||
func (gitc *GroupInvitationTokenCreate) SetNillableUpdatedAt(t *time.Time) *GroupInvitationTokenCreate {
|
||||
if t != nil {
|
||||
gitc.SetUpdatedAt(*t)
|
||||
func (_c *GroupInvitationTokenCreate) SetNillableUpdatedAt(v *time.Time) *GroupInvitationTokenCreate {
|
||||
if v != nil {
|
||||
_c.SetUpdatedAt(*v)
|
||||
}
|
||||
return gitc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetToken sets the "token" field.
|
||||
func (gitc *GroupInvitationTokenCreate) SetToken(b []byte) *GroupInvitationTokenCreate {
|
||||
gitc.mutation.SetToken(b)
|
||||
return gitc
|
||||
func (_c *GroupInvitationTokenCreate) SetToken(v []byte) *GroupInvitationTokenCreate {
|
||||
_c.mutation.SetToken(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetExpiresAt sets the "expires_at" field.
|
||||
func (gitc *GroupInvitationTokenCreate) SetExpiresAt(t time.Time) *GroupInvitationTokenCreate {
|
||||
gitc.mutation.SetExpiresAt(t)
|
||||
return gitc
|
||||
func (_c *GroupInvitationTokenCreate) SetExpiresAt(v time.Time) *GroupInvitationTokenCreate {
|
||||
_c.mutation.SetExpiresAt(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableExpiresAt sets the "expires_at" field if the given value is not nil.
|
||||
func (gitc *GroupInvitationTokenCreate) SetNillableExpiresAt(t *time.Time) *GroupInvitationTokenCreate {
|
||||
if t != nil {
|
||||
gitc.SetExpiresAt(*t)
|
||||
func (_c *GroupInvitationTokenCreate) SetNillableExpiresAt(v *time.Time) *GroupInvitationTokenCreate {
|
||||
if v != nil {
|
||||
_c.SetExpiresAt(*v)
|
||||
}
|
||||
return gitc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetUses sets the "uses" field.
|
||||
func (gitc *GroupInvitationTokenCreate) SetUses(i int) *GroupInvitationTokenCreate {
|
||||
gitc.mutation.SetUses(i)
|
||||
return gitc
|
||||
func (_c *GroupInvitationTokenCreate) SetUses(v int) *GroupInvitationTokenCreate {
|
||||
_c.mutation.SetUses(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableUses sets the "uses" field if the given value is not nil.
|
||||
func (gitc *GroupInvitationTokenCreate) SetNillableUses(i *int) *GroupInvitationTokenCreate {
|
||||
if i != nil {
|
||||
gitc.SetUses(*i)
|
||||
func (_c *GroupInvitationTokenCreate) SetNillableUses(v *int) *GroupInvitationTokenCreate {
|
||||
if v != nil {
|
||||
_c.SetUses(*v)
|
||||
}
|
||||
return gitc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetID sets the "id" field.
|
||||
func (gitc *GroupInvitationTokenCreate) SetID(u uuid.UUID) *GroupInvitationTokenCreate {
|
||||
gitc.mutation.SetID(u)
|
||||
return gitc
|
||||
func (_c *GroupInvitationTokenCreate) SetID(v uuid.UUID) *GroupInvitationTokenCreate {
|
||||
_c.mutation.SetID(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableID sets the "id" field if the given value is not nil.
|
||||
func (gitc *GroupInvitationTokenCreate) SetNillableID(u *uuid.UUID) *GroupInvitationTokenCreate {
|
||||
if u != nil {
|
||||
gitc.SetID(*u)
|
||||
func (_c *GroupInvitationTokenCreate) SetNillableID(v *uuid.UUID) *GroupInvitationTokenCreate {
|
||||
if v != nil {
|
||||
_c.SetID(*v)
|
||||
}
|
||||
return gitc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetGroupID sets the "group" edge to the Group entity by ID.
|
||||
func (gitc *GroupInvitationTokenCreate) SetGroupID(id uuid.UUID) *GroupInvitationTokenCreate {
|
||||
gitc.mutation.SetGroupID(id)
|
||||
return gitc
|
||||
func (_c *GroupInvitationTokenCreate) SetGroupID(id uuid.UUID) *GroupInvitationTokenCreate {
|
||||
_c.mutation.SetGroupID(id)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableGroupID sets the "group" edge to the Group entity by ID if the given value is not nil.
|
||||
func (gitc *GroupInvitationTokenCreate) SetNillableGroupID(id *uuid.UUID) *GroupInvitationTokenCreate {
|
||||
func (_c *GroupInvitationTokenCreate) SetNillableGroupID(id *uuid.UUID) *GroupInvitationTokenCreate {
|
||||
if id != nil {
|
||||
gitc = gitc.SetGroupID(*id)
|
||||
_c = _c.SetGroupID(*id)
|
||||
}
|
||||
return gitc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetGroup sets the "group" edge to the Group entity.
|
||||
func (gitc *GroupInvitationTokenCreate) SetGroup(g *Group) *GroupInvitationTokenCreate {
|
||||
return gitc.SetGroupID(g.ID)
|
||||
func (_c *GroupInvitationTokenCreate) SetGroup(v *Group) *GroupInvitationTokenCreate {
|
||||
return _c.SetGroupID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the GroupInvitationTokenMutation object of the builder.
|
||||
func (gitc *GroupInvitationTokenCreate) Mutation() *GroupInvitationTokenMutation {
|
||||
return gitc.mutation
|
||||
func (_c *GroupInvitationTokenCreate) Mutation() *GroupInvitationTokenMutation {
|
||||
return _c.mutation
|
||||
}
|
||||
|
||||
// Save creates the GroupInvitationToken in the database.
|
||||
func (gitc *GroupInvitationTokenCreate) Save(ctx context.Context) (*GroupInvitationToken, error) {
|
||||
gitc.defaults()
|
||||
return withHooks(ctx, gitc.sqlSave, gitc.mutation, gitc.hooks)
|
||||
func (_c *GroupInvitationTokenCreate) Save(ctx context.Context) (*GroupInvitationToken, error) {
|
||||
_c.defaults()
|
||||
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (gitc *GroupInvitationTokenCreate) SaveX(ctx context.Context) *GroupInvitationToken {
|
||||
v, err := gitc.Save(ctx)
|
||||
func (_c *GroupInvitationTokenCreate) SaveX(ctx context.Context) *GroupInvitationToken {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -138,68 +138,68 @@ func (gitc *GroupInvitationTokenCreate) SaveX(ctx context.Context) *GroupInvitat
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (gitc *GroupInvitationTokenCreate) Exec(ctx context.Context) error {
|
||||
_, err := gitc.Save(ctx)
|
||||
func (_c *GroupInvitationTokenCreate) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (gitc *GroupInvitationTokenCreate) ExecX(ctx context.Context) {
|
||||
if err := gitc.Exec(ctx); err != nil {
|
||||
func (_c *GroupInvitationTokenCreate) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (gitc *GroupInvitationTokenCreate) defaults() {
|
||||
if _, ok := gitc.mutation.CreatedAt(); !ok {
|
||||
func (_c *GroupInvitationTokenCreate) defaults() {
|
||||
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||
v := groupinvitationtoken.DefaultCreatedAt()
|
||||
gitc.mutation.SetCreatedAt(v)
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
}
|
||||
if _, ok := gitc.mutation.UpdatedAt(); !ok {
|
||||
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
||||
v := groupinvitationtoken.DefaultUpdatedAt()
|
||||
gitc.mutation.SetUpdatedAt(v)
|
||||
_c.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
if _, ok := gitc.mutation.ExpiresAt(); !ok {
|
||||
if _, ok := _c.mutation.ExpiresAt(); !ok {
|
||||
v := groupinvitationtoken.DefaultExpiresAt()
|
||||
gitc.mutation.SetExpiresAt(v)
|
||||
_c.mutation.SetExpiresAt(v)
|
||||
}
|
||||
if _, ok := gitc.mutation.Uses(); !ok {
|
||||
if _, ok := _c.mutation.Uses(); !ok {
|
||||
v := groupinvitationtoken.DefaultUses
|
||||
gitc.mutation.SetUses(v)
|
||||
_c.mutation.SetUses(v)
|
||||
}
|
||||
if _, ok := gitc.mutation.ID(); !ok {
|
||||
if _, ok := _c.mutation.ID(); !ok {
|
||||
v := groupinvitationtoken.DefaultID()
|
||||
gitc.mutation.SetID(v)
|
||||
_c.mutation.SetID(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (gitc *GroupInvitationTokenCreate) check() error {
|
||||
if _, ok := gitc.mutation.CreatedAt(); !ok {
|
||||
func (_c *GroupInvitationTokenCreate) check() error {
|
||||
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "GroupInvitationToken.created_at"`)}
|
||||
}
|
||||
if _, ok := gitc.mutation.UpdatedAt(); !ok {
|
||||
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
||||
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "GroupInvitationToken.updated_at"`)}
|
||||
}
|
||||
if _, ok := gitc.mutation.Token(); !ok {
|
||||
if _, ok := _c.mutation.Token(); !ok {
|
||||
return &ValidationError{Name: "token", err: errors.New(`ent: missing required field "GroupInvitationToken.token"`)}
|
||||
}
|
||||
if _, ok := gitc.mutation.ExpiresAt(); !ok {
|
||||
if _, ok := _c.mutation.ExpiresAt(); !ok {
|
||||
return &ValidationError{Name: "expires_at", err: errors.New(`ent: missing required field "GroupInvitationToken.expires_at"`)}
|
||||
}
|
||||
if _, ok := gitc.mutation.Uses(); !ok {
|
||||
if _, ok := _c.mutation.Uses(); !ok {
|
||||
return &ValidationError{Name: "uses", err: errors.New(`ent: missing required field "GroupInvitationToken.uses"`)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (gitc *GroupInvitationTokenCreate) sqlSave(ctx context.Context) (*GroupInvitationToken, error) {
|
||||
if err := gitc.check(); err != nil {
|
||||
func (_c *GroupInvitationTokenCreate) sqlSave(ctx context.Context) (*GroupInvitationToken, error) {
|
||||
if err := _c.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_node, _spec := gitc.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, gitc.driver, _spec); err != nil {
|
||||
_node, _spec := _c.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
@@ -212,41 +212,41 @@ func (gitc *GroupInvitationTokenCreate) sqlSave(ctx context.Context) (*GroupInvi
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
gitc.mutation.id = &_node.ID
|
||||
gitc.mutation.done = true
|
||||
_c.mutation.id = &_node.ID
|
||||
_c.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
func (gitc *GroupInvitationTokenCreate) createSpec() (*GroupInvitationToken, *sqlgraph.CreateSpec) {
|
||||
func (_c *GroupInvitationTokenCreate) createSpec() (*GroupInvitationToken, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &GroupInvitationToken{config: gitc.config}
|
||||
_node = &GroupInvitationToken{config: _c.config}
|
||||
_spec = sqlgraph.NewCreateSpec(groupinvitationtoken.Table, sqlgraph.NewFieldSpec(groupinvitationtoken.FieldID, field.TypeUUID))
|
||||
)
|
||||
if id, ok := gitc.mutation.ID(); ok {
|
||||
if id, ok := _c.mutation.ID(); ok {
|
||||
_node.ID = id
|
||||
_spec.ID.Value = &id
|
||||
}
|
||||
if value, ok := gitc.mutation.CreatedAt(); ok {
|
||||
if value, ok := _c.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(groupinvitationtoken.FieldCreatedAt, field.TypeTime, value)
|
||||
_node.CreatedAt = value
|
||||
}
|
||||
if value, ok := gitc.mutation.UpdatedAt(); ok {
|
||||
if value, ok := _c.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(groupinvitationtoken.FieldUpdatedAt, field.TypeTime, value)
|
||||
_node.UpdatedAt = value
|
||||
}
|
||||
if value, ok := gitc.mutation.Token(); ok {
|
||||
if value, ok := _c.mutation.Token(); ok {
|
||||
_spec.SetField(groupinvitationtoken.FieldToken, field.TypeBytes, value)
|
||||
_node.Token = value
|
||||
}
|
||||
if value, ok := gitc.mutation.ExpiresAt(); ok {
|
||||
if value, ok := _c.mutation.ExpiresAt(); ok {
|
||||
_spec.SetField(groupinvitationtoken.FieldExpiresAt, field.TypeTime, value)
|
||||
_node.ExpiresAt = value
|
||||
}
|
||||
if value, ok := gitc.mutation.Uses(); ok {
|
||||
if value, ok := _c.mutation.Uses(); ok {
|
||||
_spec.SetField(groupinvitationtoken.FieldUses, field.TypeInt, value)
|
||||
_node.Uses = value
|
||||
}
|
||||
if nodes := gitc.mutation.GroupIDs(); len(nodes) > 0 {
|
||||
if nodes := _c.mutation.GroupIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -274,16 +274,16 @@ type GroupInvitationTokenCreateBulk struct {
|
||||
}
|
||||
|
||||
// Save creates the GroupInvitationToken entities in the database.
|
||||
func (gitcb *GroupInvitationTokenCreateBulk) Save(ctx context.Context) ([]*GroupInvitationToken, error) {
|
||||
if gitcb.err != nil {
|
||||
return nil, gitcb.err
|
||||
func (_c *GroupInvitationTokenCreateBulk) Save(ctx context.Context) ([]*GroupInvitationToken, error) {
|
||||
if _c.err != nil {
|
||||
return nil, _c.err
|
||||
}
|
||||
specs := make([]*sqlgraph.CreateSpec, len(gitcb.builders))
|
||||
nodes := make([]*GroupInvitationToken, len(gitcb.builders))
|
||||
mutators := make([]Mutator, len(gitcb.builders))
|
||||
for i := range gitcb.builders {
|
||||
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
||||
nodes := make([]*GroupInvitationToken, len(_c.builders))
|
||||
mutators := make([]Mutator, len(_c.builders))
|
||||
for i := range _c.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := gitcb.builders[i]
|
||||
builder := _c.builders[i]
|
||||
builder.defaults()
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*GroupInvitationTokenMutation)
|
||||
@@ -297,11 +297,11 @@ func (gitcb *GroupInvitationTokenCreateBulk) Save(ctx context.Context) ([]*Group
|
||||
var err error
|
||||
nodes[i], specs[i] = builder.createSpec()
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, gitcb.builders[i+1].mutation)
|
||||
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
|
||||
} else {
|
||||
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
||||
// Invoke the actual operation on the latest mutation in the chain.
|
||||
if err = sqlgraph.BatchCreate(ctx, gitcb.driver, spec); err != nil {
|
||||
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
@@ -321,7 +321,7 @@ func (gitcb *GroupInvitationTokenCreateBulk) Save(ctx context.Context) ([]*Group
|
||||
}(i, ctx)
|
||||
}
|
||||
if len(mutators) > 0 {
|
||||
if _, err := mutators[0].Mutate(ctx, gitcb.builders[0].mutation); err != nil {
|
||||
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
@@ -329,8 +329,8 @@ func (gitcb *GroupInvitationTokenCreateBulk) Save(ctx context.Context) ([]*Group
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (gitcb *GroupInvitationTokenCreateBulk) SaveX(ctx context.Context) []*GroupInvitationToken {
|
||||
v, err := gitcb.Save(ctx)
|
||||
func (_c *GroupInvitationTokenCreateBulk) SaveX(ctx context.Context) []*GroupInvitationToken {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -338,14 +338,14 @@ func (gitcb *GroupInvitationTokenCreateBulk) SaveX(ctx context.Context) []*Group
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (gitcb *GroupInvitationTokenCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := gitcb.Save(ctx)
|
||||
func (_c *GroupInvitationTokenCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (gitcb *GroupInvitationTokenCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := gitcb.Exec(ctx); err != nil {
|
||||
func (_c *GroupInvitationTokenCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,56 +20,56 @@ type GroupInvitationTokenDelete struct {
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the GroupInvitationTokenDelete builder.
|
||||
func (gitd *GroupInvitationTokenDelete) Where(ps ...predicate.GroupInvitationToken) *GroupInvitationTokenDelete {
|
||||
gitd.mutation.Where(ps...)
|
||||
return gitd
|
||||
func (_d *GroupInvitationTokenDelete) Where(ps ...predicate.GroupInvitationToken) *GroupInvitationTokenDelete {
|
||||
_d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (gitd *GroupInvitationTokenDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, gitd.sqlExec, gitd.mutation, gitd.hooks)
|
||||
func (_d *GroupInvitationTokenDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (gitd *GroupInvitationTokenDelete) ExecX(ctx context.Context) int {
|
||||
n, err := gitd.Exec(ctx)
|
||||
func (_d *GroupInvitationTokenDelete) ExecX(ctx context.Context) int {
|
||||
n, err := _d.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (gitd *GroupInvitationTokenDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
func (_d *GroupInvitationTokenDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := sqlgraph.NewDeleteSpec(groupinvitationtoken.Table, sqlgraph.NewFieldSpec(groupinvitationtoken.FieldID, field.TypeUUID))
|
||||
if ps := gitd.mutation.predicates; len(ps) > 0 {
|
||||
if ps := _d.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, gitd.driver, _spec)
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec)
|
||||
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
gitd.mutation.done = true
|
||||
_d.mutation.done = true
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// GroupInvitationTokenDeleteOne is the builder for deleting a single GroupInvitationToken entity.
|
||||
type GroupInvitationTokenDeleteOne struct {
|
||||
gitd *GroupInvitationTokenDelete
|
||||
_d *GroupInvitationTokenDelete
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the GroupInvitationTokenDelete builder.
|
||||
func (gitdo *GroupInvitationTokenDeleteOne) Where(ps ...predicate.GroupInvitationToken) *GroupInvitationTokenDeleteOne {
|
||||
gitdo.gitd.mutation.Where(ps...)
|
||||
return gitdo
|
||||
func (_d *GroupInvitationTokenDeleteOne) Where(ps ...predicate.GroupInvitationToken) *GroupInvitationTokenDeleteOne {
|
||||
_d._d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (gitdo *GroupInvitationTokenDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := gitdo.gitd.Exec(ctx)
|
||||
func (_d *GroupInvitationTokenDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := _d._d.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
@@ -81,8 +81,8 @@ func (gitdo *GroupInvitationTokenDeleteOne) Exec(ctx context.Context) error {
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (gitdo *GroupInvitationTokenDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := gitdo.Exec(ctx); err != nil {
|
||||
func (_d *GroupInvitationTokenDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := _d.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,44 +32,44 @@ type GroupInvitationTokenQuery struct {
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the GroupInvitationTokenQuery builder.
|
||||
func (gitq *GroupInvitationTokenQuery) Where(ps ...predicate.GroupInvitationToken) *GroupInvitationTokenQuery {
|
||||
gitq.predicates = append(gitq.predicates, ps...)
|
||||
return gitq
|
||||
func (_q *GroupInvitationTokenQuery) Where(ps ...predicate.GroupInvitationToken) *GroupInvitationTokenQuery {
|
||||
_q.predicates = append(_q.predicates, ps...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// Limit the number of records to be returned by this query.
|
||||
func (gitq *GroupInvitationTokenQuery) Limit(limit int) *GroupInvitationTokenQuery {
|
||||
gitq.ctx.Limit = &limit
|
||||
return gitq
|
||||
func (_q *GroupInvitationTokenQuery) Limit(limit int) *GroupInvitationTokenQuery {
|
||||
_q.ctx.Limit = &limit
|
||||
return _q
|
||||
}
|
||||
|
||||
// Offset to start from.
|
||||
func (gitq *GroupInvitationTokenQuery) Offset(offset int) *GroupInvitationTokenQuery {
|
||||
gitq.ctx.Offset = &offset
|
||||
return gitq
|
||||
func (_q *GroupInvitationTokenQuery) Offset(offset int) *GroupInvitationTokenQuery {
|
||||
_q.ctx.Offset = &offset
|
||||
return _q
|
||||
}
|
||||
|
||||
// Unique configures the query builder to filter duplicate records on query.
|
||||
// By default, unique is set to true, and can be disabled using this method.
|
||||
func (gitq *GroupInvitationTokenQuery) Unique(unique bool) *GroupInvitationTokenQuery {
|
||||
gitq.ctx.Unique = &unique
|
||||
return gitq
|
||||
func (_q *GroupInvitationTokenQuery) Unique(unique bool) *GroupInvitationTokenQuery {
|
||||
_q.ctx.Unique = &unique
|
||||
return _q
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (gitq *GroupInvitationTokenQuery) Order(o ...groupinvitationtoken.OrderOption) *GroupInvitationTokenQuery {
|
||||
gitq.order = append(gitq.order, o...)
|
||||
return gitq
|
||||
func (_q *GroupInvitationTokenQuery) Order(o ...groupinvitationtoken.OrderOption) *GroupInvitationTokenQuery {
|
||||
_q.order = append(_q.order, o...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// QueryGroup chains the current query on the "group" edge.
|
||||
func (gitq *GroupInvitationTokenQuery) QueryGroup() *GroupQuery {
|
||||
query := (&GroupClient{config: gitq.config}).Query()
|
||||
func (_q *GroupInvitationTokenQuery) QueryGroup() *GroupQuery {
|
||||
query := (&GroupClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := gitq.prepareQuery(ctx); err != nil {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := gitq.sqlQuery(ctx)
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -78,7 +78,7 @@ func (gitq *GroupInvitationTokenQuery) QueryGroup() *GroupQuery {
|
||||
sqlgraph.To(group.Table, group.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, groupinvitationtoken.GroupTable, groupinvitationtoken.GroupColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(gitq.driver.Dialect(), step)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
@@ -86,8 +86,8 @@ func (gitq *GroupInvitationTokenQuery) QueryGroup() *GroupQuery {
|
||||
|
||||
// First returns the first GroupInvitationToken entity from the query.
|
||||
// Returns a *NotFoundError when no GroupInvitationToken was found.
|
||||
func (gitq *GroupInvitationTokenQuery) First(ctx context.Context) (*GroupInvitationToken, error) {
|
||||
nodes, err := gitq.Limit(1).All(setContextOp(ctx, gitq.ctx, ent.OpQueryFirst))
|
||||
func (_q *GroupInvitationTokenQuery) First(ctx context.Context) (*GroupInvitationToken, error) {
|
||||
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -98,8 +98,8 @@ func (gitq *GroupInvitationTokenQuery) First(ctx context.Context) (*GroupInvitat
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (gitq *GroupInvitationTokenQuery) FirstX(ctx context.Context) *GroupInvitationToken {
|
||||
node, err := gitq.First(ctx)
|
||||
func (_q *GroupInvitationTokenQuery) FirstX(ctx context.Context) *GroupInvitationToken {
|
||||
node, err := _q.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
@@ -108,9 +108,9 @@ func (gitq *GroupInvitationTokenQuery) FirstX(ctx context.Context) *GroupInvitat
|
||||
|
||||
// FirstID returns the first GroupInvitationToken ID from the query.
|
||||
// Returns a *NotFoundError when no GroupInvitationToken ID was found.
|
||||
func (gitq *GroupInvitationTokenQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
func (_q *GroupInvitationTokenQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
var ids []uuid.UUID
|
||||
if ids, err = gitq.Limit(1).IDs(setContextOp(ctx, gitq.ctx, ent.OpQueryFirstID)); err != nil {
|
||||
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
@@ -121,8 +121,8 @@ func (gitq *GroupInvitationTokenQuery) FirstID(ctx context.Context) (id uuid.UUI
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (gitq *GroupInvitationTokenQuery) FirstIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := gitq.FirstID(ctx)
|
||||
func (_q *GroupInvitationTokenQuery) FirstIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := _q.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
@@ -132,8 +132,8 @@ func (gitq *GroupInvitationTokenQuery) FirstIDX(ctx context.Context) uuid.UUID {
|
||||
// Only returns a single GroupInvitationToken entity found by the query, ensuring it only returns one.
|
||||
// Returns a *NotSingularError when more than one GroupInvitationToken entity is found.
|
||||
// Returns a *NotFoundError when no GroupInvitationToken entities are found.
|
||||
func (gitq *GroupInvitationTokenQuery) Only(ctx context.Context) (*GroupInvitationToken, error) {
|
||||
nodes, err := gitq.Limit(2).All(setContextOp(ctx, gitq.ctx, ent.OpQueryOnly))
|
||||
func (_q *GroupInvitationTokenQuery) Only(ctx context.Context) (*GroupInvitationToken, error) {
|
||||
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -148,8 +148,8 @@ func (gitq *GroupInvitationTokenQuery) Only(ctx context.Context) (*GroupInvitati
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (gitq *GroupInvitationTokenQuery) OnlyX(ctx context.Context) *GroupInvitationToken {
|
||||
node, err := gitq.Only(ctx)
|
||||
func (_q *GroupInvitationTokenQuery) OnlyX(ctx context.Context) *GroupInvitationToken {
|
||||
node, err := _q.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -159,9 +159,9 @@ func (gitq *GroupInvitationTokenQuery) OnlyX(ctx context.Context) *GroupInvitati
|
||||
// OnlyID is like Only, but returns the only GroupInvitationToken ID in the query.
|
||||
// Returns a *NotSingularError when more than one GroupInvitationToken ID is found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (gitq *GroupInvitationTokenQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
func (_q *GroupInvitationTokenQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
var ids []uuid.UUID
|
||||
if ids, err = gitq.Limit(2).IDs(setContextOp(ctx, gitq.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
@@ -176,8 +176,8 @@ func (gitq *GroupInvitationTokenQuery) OnlyID(ctx context.Context) (id uuid.UUID
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (gitq *GroupInvitationTokenQuery) OnlyIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := gitq.OnlyID(ctx)
|
||||
func (_q *GroupInvitationTokenQuery) OnlyIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := _q.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -185,18 +185,18 @@ func (gitq *GroupInvitationTokenQuery) OnlyIDX(ctx context.Context) uuid.UUID {
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of GroupInvitationTokens.
|
||||
func (gitq *GroupInvitationTokenQuery) All(ctx context.Context) ([]*GroupInvitationToken, error) {
|
||||
ctx = setContextOp(ctx, gitq.ctx, ent.OpQueryAll)
|
||||
if err := gitq.prepareQuery(ctx); err != nil {
|
||||
func (_q *GroupInvitationTokenQuery) All(ctx context.Context) ([]*GroupInvitationToken, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qr := querierAll[[]*GroupInvitationToken, *GroupInvitationTokenQuery]()
|
||||
return withInterceptors[[]*GroupInvitationToken](ctx, gitq, qr, gitq.inters)
|
||||
return withInterceptors[[]*GroupInvitationToken](ctx, _q, qr, _q.inters)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (gitq *GroupInvitationTokenQuery) AllX(ctx context.Context) []*GroupInvitationToken {
|
||||
nodes, err := gitq.All(ctx)
|
||||
func (_q *GroupInvitationTokenQuery) AllX(ctx context.Context) []*GroupInvitationToken {
|
||||
nodes, err := _q.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -204,20 +204,20 @@ func (gitq *GroupInvitationTokenQuery) AllX(ctx context.Context) []*GroupInvitat
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of GroupInvitationToken IDs.
|
||||
func (gitq *GroupInvitationTokenQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
|
||||
if gitq.ctx.Unique == nil && gitq.path != nil {
|
||||
gitq.Unique(true)
|
||||
func (_q *GroupInvitationTokenQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
|
||||
if _q.ctx.Unique == nil && _q.path != nil {
|
||||
_q.Unique(true)
|
||||
}
|
||||
ctx = setContextOp(ctx, gitq.ctx, ent.OpQueryIDs)
|
||||
if err = gitq.Select(groupinvitationtoken.FieldID).Scan(ctx, &ids); err != nil {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
|
||||
if err = _q.Select(groupinvitationtoken.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (gitq *GroupInvitationTokenQuery) IDsX(ctx context.Context) []uuid.UUID {
|
||||
ids, err := gitq.IDs(ctx)
|
||||
func (_q *GroupInvitationTokenQuery) IDsX(ctx context.Context) []uuid.UUID {
|
||||
ids, err := _q.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -225,17 +225,17 @@ func (gitq *GroupInvitationTokenQuery) IDsX(ctx context.Context) []uuid.UUID {
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (gitq *GroupInvitationTokenQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, gitq.ctx, ent.OpQueryCount)
|
||||
if err := gitq.prepareQuery(ctx); err != nil {
|
||||
func (_q *GroupInvitationTokenQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return withInterceptors[int](ctx, gitq, querierCount[*GroupInvitationTokenQuery](), gitq.inters)
|
||||
return withInterceptors[int](ctx, _q, querierCount[*GroupInvitationTokenQuery](), _q.inters)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (gitq *GroupInvitationTokenQuery) CountX(ctx context.Context) int {
|
||||
count, err := gitq.Count(ctx)
|
||||
func (_q *GroupInvitationTokenQuery) CountX(ctx context.Context) int {
|
||||
count, err := _q.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -243,9 +243,9 @@ func (gitq *GroupInvitationTokenQuery) CountX(ctx context.Context) int {
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (gitq *GroupInvitationTokenQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, gitq.ctx, ent.OpQueryExist)
|
||||
switch _, err := gitq.FirstID(ctx); {
|
||||
func (_q *GroupInvitationTokenQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
|
||||
switch _, err := _q.FirstID(ctx); {
|
||||
case IsNotFound(err):
|
||||
return false, nil
|
||||
case err != nil:
|
||||
@@ -256,8 +256,8 @@ func (gitq *GroupInvitationTokenQuery) Exist(ctx context.Context) (bool, error)
|
||||
}
|
||||
|
||||
// ExistX is like Exist, but panics if an error occurs.
|
||||
func (gitq *GroupInvitationTokenQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := gitq.Exist(ctx)
|
||||
func (_q *GroupInvitationTokenQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := _q.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -266,32 +266,32 @@ func (gitq *GroupInvitationTokenQuery) ExistX(ctx context.Context) bool {
|
||||
|
||||
// Clone returns a duplicate of the GroupInvitationTokenQuery builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (gitq *GroupInvitationTokenQuery) Clone() *GroupInvitationTokenQuery {
|
||||
if gitq == nil {
|
||||
func (_q *GroupInvitationTokenQuery) Clone() *GroupInvitationTokenQuery {
|
||||
if _q == nil {
|
||||
return nil
|
||||
}
|
||||
return &GroupInvitationTokenQuery{
|
||||
config: gitq.config,
|
||||
ctx: gitq.ctx.Clone(),
|
||||
order: append([]groupinvitationtoken.OrderOption{}, gitq.order...),
|
||||
inters: append([]Interceptor{}, gitq.inters...),
|
||||
predicates: append([]predicate.GroupInvitationToken{}, gitq.predicates...),
|
||||
withGroup: gitq.withGroup.Clone(),
|
||||
config: _q.config,
|
||||
ctx: _q.ctx.Clone(),
|
||||
order: append([]groupinvitationtoken.OrderOption{}, _q.order...),
|
||||
inters: append([]Interceptor{}, _q.inters...),
|
||||
predicates: append([]predicate.GroupInvitationToken{}, _q.predicates...),
|
||||
withGroup: _q.withGroup.Clone(),
|
||||
// clone intermediate query.
|
||||
sql: gitq.sql.Clone(),
|
||||
path: gitq.path,
|
||||
sql: _q.sql.Clone(),
|
||||
path: _q.path,
|
||||
}
|
||||
}
|
||||
|
||||
// WithGroup tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "group" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (gitq *GroupInvitationTokenQuery) WithGroup(opts ...func(*GroupQuery)) *GroupInvitationTokenQuery {
|
||||
query := (&GroupClient{config: gitq.config}).Query()
|
||||
func (_q *GroupInvitationTokenQuery) WithGroup(opts ...func(*GroupQuery)) *GroupInvitationTokenQuery {
|
||||
query := (&GroupClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
gitq.withGroup = query
|
||||
return gitq
|
||||
_q.withGroup = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// GroupBy is used to group vertices by one or more fields/columns.
|
||||
@@ -308,10 +308,10 @@ func (gitq *GroupInvitationTokenQuery) WithGroup(opts ...func(*GroupQuery)) *Gro
|
||||
// GroupBy(groupinvitationtoken.FieldCreatedAt).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (gitq *GroupInvitationTokenQuery) GroupBy(field string, fields ...string) *GroupInvitationTokenGroupBy {
|
||||
gitq.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &GroupInvitationTokenGroupBy{build: gitq}
|
||||
grbuild.flds = &gitq.ctx.Fields
|
||||
func (_q *GroupInvitationTokenQuery) GroupBy(field string, fields ...string) *GroupInvitationTokenGroupBy {
|
||||
_q.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &GroupInvitationTokenGroupBy{build: _q}
|
||||
grbuild.flds = &_q.ctx.Fields
|
||||
grbuild.label = groupinvitationtoken.Label
|
||||
grbuild.scan = grbuild.Scan
|
||||
return grbuild
|
||||
@@ -329,55 +329,55 @@ func (gitq *GroupInvitationTokenQuery) GroupBy(field string, fields ...string) *
|
||||
// client.GroupInvitationToken.Query().
|
||||
// Select(groupinvitationtoken.FieldCreatedAt).
|
||||
// Scan(ctx, &v)
|
||||
func (gitq *GroupInvitationTokenQuery) Select(fields ...string) *GroupInvitationTokenSelect {
|
||||
gitq.ctx.Fields = append(gitq.ctx.Fields, fields...)
|
||||
sbuild := &GroupInvitationTokenSelect{GroupInvitationTokenQuery: gitq}
|
||||
func (_q *GroupInvitationTokenQuery) Select(fields ...string) *GroupInvitationTokenSelect {
|
||||
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
||||
sbuild := &GroupInvitationTokenSelect{GroupInvitationTokenQuery: _q}
|
||||
sbuild.label = groupinvitationtoken.Label
|
||||
sbuild.flds, sbuild.scan = &gitq.ctx.Fields, sbuild.Scan
|
||||
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
|
||||
return sbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a GroupInvitationTokenSelect configured with the given aggregations.
|
||||
func (gitq *GroupInvitationTokenQuery) Aggregate(fns ...AggregateFunc) *GroupInvitationTokenSelect {
|
||||
return gitq.Select().Aggregate(fns...)
|
||||
func (_q *GroupInvitationTokenQuery) Aggregate(fns ...AggregateFunc) *GroupInvitationTokenSelect {
|
||||
return _q.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (gitq *GroupInvitationTokenQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range gitq.inters {
|
||||
func (_q *GroupInvitationTokenQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range _q.inters {
|
||||
if inter == nil {
|
||||
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
|
||||
}
|
||||
if trv, ok := inter.(Traverser); ok {
|
||||
if err := trv.Traverse(ctx, gitq); err != nil {
|
||||
if err := trv.Traverse(ctx, _q); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, f := range gitq.ctx.Fields {
|
||||
for _, f := range _q.ctx.Fields {
|
||||
if !groupinvitationtoken.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
}
|
||||
if gitq.path != nil {
|
||||
prev, err := gitq.path(ctx)
|
||||
if _q.path != nil {
|
||||
prev, err := _q.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
gitq.sql = prev
|
||||
_q.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (gitq *GroupInvitationTokenQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*GroupInvitationToken, error) {
|
||||
func (_q *GroupInvitationTokenQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*GroupInvitationToken, error) {
|
||||
var (
|
||||
nodes = []*GroupInvitationToken{}
|
||||
withFKs = gitq.withFKs
|
||||
_spec = gitq.querySpec()
|
||||
withFKs = _q.withFKs
|
||||
_spec = _q.querySpec()
|
||||
loadedTypes = [1]bool{
|
||||
gitq.withGroup != nil,
|
||||
_q.withGroup != nil,
|
||||
}
|
||||
)
|
||||
if gitq.withGroup != nil {
|
||||
if _q.withGroup != nil {
|
||||
withFKs = true
|
||||
}
|
||||
if withFKs {
|
||||
@@ -387,7 +387,7 @@ func (gitq *GroupInvitationTokenQuery) sqlAll(ctx context.Context, hooks ...quer
|
||||
return (*GroupInvitationToken).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &GroupInvitationToken{config: gitq.config}
|
||||
node := &GroupInvitationToken{config: _q.config}
|
||||
nodes = append(nodes, node)
|
||||
node.Edges.loadedTypes = loadedTypes
|
||||
return node.assignValues(columns, values)
|
||||
@@ -395,14 +395,14 @@ func (gitq *GroupInvitationTokenQuery) sqlAll(ctx context.Context, hooks ...quer
|
||||
for i := range hooks {
|
||||
hooks[i](ctx, _spec)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, gitq.driver, _spec); err != nil {
|
||||
if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
if query := gitq.withGroup; query != nil {
|
||||
if err := gitq.loadGroup(ctx, query, nodes, nil,
|
||||
if query := _q.withGroup; query != nil {
|
||||
if err := _q.loadGroup(ctx, query, nodes, nil,
|
||||
func(n *GroupInvitationToken, e *Group) { n.Edges.Group = e }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -410,7 +410,7 @@ func (gitq *GroupInvitationTokenQuery) sqlAll(ctx context.Context, hooks ...quer
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (gitq *GroupInvitationTokenQuery) loadGroup(ctx context.Context, query *GroupQuery, nodes []*GroupInvitationToken, init func(*GroupInvitationToken), assign func(*GroupInvitationToken, *Group)) error {
|
||||
func (_q *GroupInvitationTokenQuery) loadGroup(ctx context.Context, query *GroupQuery, nodes []*GroupInvitationToken, init func(*GroupInvitationToken), assign func(*GroupInvitationToken, *Group)) error {
|
||||
ids := make([]uuid.UUID, 0, len(nodes))
|
||||
nodeids := make(map[uuid.UUID][]*GroupInvitationToken)
|
||||
for i := range nodes {
|
||||
@@ -443,24 +443,24 @@ func (gitq *GroupInvitationTokenQuery) loadGroup(ctx context.Context, query *Gro
|
||||
return nil
|
||||
}
|
||||
|
||||
func (gitq *GroupInvitationTokenQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := gitq.querySpec()
|
||||
_spec.Node.Columns = gitq.ctx.Fields
|
||||
if len(gitq.ctx.Fields) > 0 {
|
||||
_spec.Unique = gitq.ctx.Unique != nil && *gitq.ctx.Unique
|
||||
func (_q *GroupInvitationTokenQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := _q.querySpec()
|
||||
_spec.Node.Columns = _q.ctx.Fields
|
||||
if len(_q.ctx.Fields) > 0 {
|
||||
_spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, gitq.driver, _spec)
|
||||
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
|
||||
}
|
||||
|
||||
func (gitq *GroupInvitationTokenQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
func (_q *GroupInvitationTokenQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := sqlgraph.NewQuerySpec(groupinvitationtoken.Table, groupinvitationtoken.Columns, sqlgraph.NewFieldSpec(groupinvitationtoken.FieldID, field.TypeUUID))
|
||||
_spec.From = gitq.sql
|
||||
if unique := gitq.ctx.Unique; unique != nil {
|
||||
_spec.From = _q.sql
|
||||
if unique := _q.ctx.Unique; unique != nil {
|
||||
_spec.Unique = *unique
|
||||
} else if gitq.path != nil {
|
||||
} else if _q.path != nil {
|
||||
_spec.Unique = true
|
||||
}
|
||||
if fields := gitq.ctx.Fields; len(fields) > 0 {
|
||||
if fields := _q.ctx.Fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, groupinvitationtoken.FieldID)
|
||||
for i := range fields {
|
||||
@@ -469,20 +469,20 @@ func (gitq *GroupInvitationTokenQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := gitq.predicates; len(ps) > 0 {
|
||||
if ps := _q.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := gitq.ctx.Limit; limit != nil {
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := gitq.ctx.Offset; offset != nil {
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := gitq.order; len(ps) > 0 {
|
||||
if ps := _q.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
@@ -492,33 +492,33 @@ func (gitq *GroupInvitationTokenQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (gitq *GroupInvitationTokenQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(gitq.driver.Dialect())
|
||||
func (_q *GroupInvitationTokenQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(_q.driver.Dialect())
|
||||
t1 := builder.Table(groupinvitationtoken.Table)
|
||||
columns := gitq.ctx.Fields
|
||||
columns := _q.ctx.Fields
|
||||
if len(columns) == 0 {
|
||||
columns = groupinvitationtoken.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if gitq.sql != nil {
|
||||
selector = gitq.sql
|
||||
if _q.sql != nil {
|
||||
selector = _q.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
if gitq.ctx.Unique != nil && *gitq.ctx.Unique {
|
||||
if _q.ctx.Unique != nil && *_q.ctx.Unique {
|
||||
selector.Distinct()
|
||||
}
|
||||
for _, p := range gitq.predicates {
|
||||
for _, p := range _q.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range gitq.order {
|
||||
for _, p := range _q.order {
|
||||
p(selector)
|
||||
}
|
||||
if offset := gitq.ctx.Offset; offset != nil {
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
// limit is mandatory for offset clause. We start
|
||||
// with default value, and override it below if needed.
|
||||
selector.Offset(*offset).Limit(math.MaxInt32)
|
||||
}
|
||||
if limit := gitq.ctx.Limit; limit != nil {
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
@@ -531,41 +531,41 @@ type GroupInvitationTokenGroupBy struct {
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (gitgb *GroupInvitationTokenGroupBy) Aggregate(fns ...AggregateFunc) *GroupInvitationTokenGroupBy {
|
||||
gitgb.fns = append(gitgb.fns, fns...)
|
||||
return gitgb
|
||||
func (_g *GroupInvitationTokenGroupBy) Aggregate(fns ...AggregateFunc) *GroupInvitationTokenGroupBy {
|
||||
_g.fns = append(_g.fns, fns...)
|
||||
return _g
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (gitgb *GroupInvitationTokenGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, gitgb.build.ctx, ent.OpQueryGroupBy)
|
||||
if err := gitgb.build.prepareQuery(ctx); err != nil {
|
||||
func (_g *GroupInvitationTokenGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
|
||||
if err := _g.build.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*GroupInvitationTokenQuery, *GroupInvitationTokenGroupBy](ctx, gitgb.build, gitgb, gitgb.build.inters, v)
|
||||
return scanWithInterceptors[*GroupInvitationTokenQuery, *GroupInvitationTokenGroupBy](ctx, _g.build, _g, _g.build.inters, v)
|
||||
}
|
||||
|
||||
func (gitgb *GroupInvitationTokenGroupBy) sqlScan(ctx context.Context, root *GroupInvitationTokenQuery, v any) error {
|
||||
func (_g *GroupInvitationTokenGroupBy) sqlScan(ctx context.Context, root *GroupInvitationTokenQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx).Select()
|
||||
aggregation := make([]string, 0, len(gitgb.fns))
|
||||
for _, fn := range gitgb.fns {
|
||||
aggregation := make([]string, 0, len(_g.fns))
|
||||
for _, fn := range _g.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(*gitgb.flds)+len(gitgb.fns))
|
||||
for _, f := range *gitgb.flds {
|
||||
columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
|
||||
for _, f := range *_g.flds {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
columns = append(columns, aggregation...)
|
||||
selector.Select(columns...)
|
||||
}
|
||||
selector.GroupBy(selector.Columns(*gitgb.flds...)...)
|
||||
selector.GroupBy(selector.Columns(*_g.flds...)...)
|
||||
if err := selector.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := gitgb.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
@@ -579,27 +579,27 @@ type GroupInvitationTokenSelect struct {
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (gits *GroupInvitationTokenSelect) Aggregate(fns ...AggregateFunc) *GroupInvitationTokenSelect {
|
||||
gits.fns = append(gits.fns, fns...)
|
||||
return gits
|
||||
func (_s *GroupInvitationTokenSelect) Aggregate(fns ...AggregateFunc) *GroupInvitationTokenSelect {
|
||||
_s.fns = append(_s.fns, fns...)
|
||||
return _s
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (gits *GroupInvitationTokenSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, gits.ctx, ent.OpQuerySelect)
|
||||
if err := gits.prepareQuery(ctx); err != nil {
|
||||
func (_s *GroupInvitationTokenSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
|
||||
if err := _s.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*GroupInvitationTokenQuery, *GroupInvitationTokenSelect](ctx, gits.GroupInvitationTokenQuery, gits, gits.inters, v)
|
||||
return scanWithInterceptors[*GroupInvitationTokenQuery, *GroupInvitationTokenSelect](ctx, _s.GroupInvitationTokenQuery, _s, _s.inters, v)
|
||||
}
|
||||
|
||||
func (gits *GroupInvitationTokenSelect) sqlScan(ctx context.Context, root *GroupInvitationTokenQuery, v any) error {
|
||||
func (_s *GroupInvitationTokenSelect) sqlScan(ctx context.Context, root *GroupInvitationTokenQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx)
|
||||
aggregation := make([]string, 0, len(gits.fns))
|
||||
for _, fn := range gits.fns {
|
||||
aggregation := make([]string, 0, len(_s.fns))
|
||||
for _, fn := range _s.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
switch n := len(*gits.selector.flds); {
|
||||
switch n := len(*_s.selector.flds); {
|
||||
case n == 0 && len(aggregation) > 0:
|
||||
selector.Select(aggregation...)
|
||||
case n != 0 && len(aggregation) > 0:
|
||||
@@ -607,7 +607,7 @@ func (gits *GroupInvitationTokenSelect) sqlScan(ctx context.Context, root *Group
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := gits.driver.Query(ctx, query, args, rows); err != nil {
|
||||
if err := _s.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
@@ -25,97 +25,97 @@ type GroupInvitationTokenUpdate struct {
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the GroupInvitationTokenUpdate builder.
|
||||
func (gitu *GroupInvitationTokenUpdate) Where(ps ...predicate.GroupInvitationToken) *GroupInvitationTokenUpdate {
|
||||
gitu.mutation.Where(ps...)
|
||||
return gitu
|
||||
func (_u *GroupInvitationTokenUpdate) Where(ps ...predicate.GroupInvitationToken) *GroupInvitationTokenUpdate {
|
||||
_u.mutation.Where(ps...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (gitu *GroupInvitationTokenUpdate) SetUpdatedAt(t time.Time) *GroupInvitationTokenUpdate {
|
||||
gitu.mutation.SetUpdatedAt(t)
|
||||
return gitu
|
||||
func (_u *GroupInvitationTokenUpdate) SetUpdatedAt(v time.Time) *GroupInvitationTokenUpdate {
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetToken sets the "token" field.
|
||||
func (gitu *GroupInvitationTokenUpdate) SetToken(b []byte) *GroupInvitationTokenUpdate {
|
||||
gitu.mutation.SetToken(b)
|
||||
return gitu
|
||||
func (_u *GroupInvitationTokenUpdate) SetToken(v []byte) *GroupInvitationTokenUpdate {
|
||||
_u.mutation.SetToken(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetExpiresAt sets the "expires_at" field.
|
||||
func (gitu *GroupInvitationTokenUpdate) SetExpiresAt(t time.Time) *GroupInvitationTokenUpdate {
|
||||
gitu.mutation.SetExpiresAt(t)
|
||||
return gitu
|
||||
func (_u *GroupInvitationTokenUpdate) SetExpiresAt(v time.Time) *GroupInvitationTokenUpdate {
|
||||
_u.mutation.SetExpiresAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableExpiresAt sets the "expires_at" field if the given value is not nil.
|
||||
func (gitu *GroupInvitationTokenUpdate) SetNillableExpiresAt(t *time.Time) *GroupInvitationTokenUpdate {
|
||||
if t != nil {
|
||||
gitu.SetExpiresAt(*t)
|
||||
func (_u *GroupInvitationTokenUpdate) SetNillableExpiresAt(v *time.Time) *GroupInvitationTokenUpdate {
|
||||
if v != nil {
|
||||
_u.SetExpiresAt(*v)
|
||||
}
|
||||
return gitu
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUses sets the "uses" field.
|
||||
func (gitu *GroupInvitationTokenUpdate) SetUses(i int) *GroupInvitationTokenUpdate {
|
||||
gitu.mutation.ResetUses()
|
||||
gitu.mutation.SetUses(i)
|
||||
return gitu
|
||||
func (_u *GroupInvitationTokenUpdate) SetUses(v int) *GroupInvitationTokenUpdate {
|
||||
_u.mutation.ResetUses()
|
||||
_u.mutation.SetUses(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableUses sets the "uses" field if the given value is not nil.
|
||||
func (gitu *GroupInvitationTokenUpdate) SetNillableUses(i *int) *GroupInvitationTokenUpdate {
|
||||
if i != nil {
|
||||
gitu.SetUses(*i)
|
||||
func (_u *GroupInvitationTokenUpdate) SetNillableUses(v *int) *GroupInvitationTokenUpdate {
|
||||
if v != nil {
|
||||
_u.SetUses(*v)
|
||||
}
|
||||
return gitu
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddUses adds i to the "uses" field.
|
||||
func (gitu *GroupInvitationTokenUpdate) AddUses(i int) *GroupInvitationTokenUpdate {
|
||||
gitu.mutation.AddUses(i)
|
||||
return gitu
|
||||
// AddUses adds value to the "uses" field.
|
||||
func (_u *GroupInvitationTokenUpdate) AddUses(v int) *GroupInvitationTokenUpdate {
|
||||
_u.mutation.AddUses(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetGroupID sets the "group" edge to the Group entity by ID.
|
||||
func (gitu *GroupInvitationTokenUpdate) SetGroupID(id uuid.UUID) *GroupInvitationTokenUpdate {
|
||||
gitu.mutation.SetGroupID(id)
|
||||
return gitu
|
||||
func (_u *GroupInvitationTokenUpdate) SetGroupID(id uuid.UUID) *GroupInvitationTokenUpdate {
|
||||
_u.mutation.SetGroupID(id)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableGroupID sets the "group" edge to the Group entity by ID if the given value is not nil.
|
||||
func (gitu *GroupInvitationTokenUpdate) SetNillableGroupID(id *uuid.UUID) *GroupInvitationTokenUpdate {
|
||||
func (_u *GroupInvitationTokenUpdate) SetNillableGroupID(id *uuid.UUID) *GroupInvitationTokenUpdate {
|
||||
if id != nil {
|
||||
gitu = gitu.SetGroupID(*id)
|
||||
_u = _u.SetGroupID(*id)
|
||||
}
|
||||
return gitu
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetGroup sets the "group" edge to the Group entity.
|
||||
func (gitu *GroupInvitationTokenUpdate) SetGroup(g *Group) *GroupInvitationTokenUpdate {
|
||||
return gitu.SetGroupID(g.ID)
|
||||
func (_u *GroupInvitationTokenUpdate) SetGroup(v *Group) *GroupInvitationTokenUpdate {
|
||||
return _u.SetGroupID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the GroupInvitationTokenMutation object of the builder.
|
||||
func (gitu *GroupInvitationTokenUpdate) Mutation() *GroupInvitationTokenMutation {
|
||||
return gitu.mutation
|
||||
func (_u *GroupInvitationTokenUpdate) Mutation() *GroupInvitationTokenMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// ClearGroup clears the "group" edge to the Group entity.
|
||||
func (gitu *GroupInvitationTokenUpdate) ClearGroup() *GroupInvitationTokenUpdate {
|
||||
gitu.mutation.ClearGroup()
|
||||
return gitu
|
||||
func (_u *GroupInvitationTokenUpdate) ClearGroup() *GroupInvitationTokenUpdate {
|
||||
_u.mutation.ClearGroup()
|
||||
return _u
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (gitu *GroupInvitationTokenUpdate) Save(ctx context.Context) (int, error) {
|
||||
gitu.defaults()
|
||||
return withHooks(ctx, gitu.sqlSave, gitu.mutation, gitu.hooks)
|
||||
func (_u *GroupInvitationTokenUpdate) Save(ctx context.Context) (int, error) {
|
||||
_u.defaults()
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (gitu *GroupInvitationTokenUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := gitu.Save(ctx)
|
||||
func (_u *GroupInvitationTokenUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -123,51 +123,51 @@ func (gitu *GroupInvitationTokenUpdate) SaveX(ctx context.Context) int {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (gitu *GroupInvitationTokenUpdate) Exec(ctx context.Context) error {
|
||||
_, err := gitu.Save(ctx)
|
||||
func (_u *GroupInvitationTokenUpdate) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (gitu *GroupInvitationTokenUpdate) ExecX(ctx context.Context) {
|
||||
if err := gitu.Exec(ctx); err != nil {
|
||||
func (_u *GroupInvitationTokenUpdate) ExecX(ctx context.Context) {
|
||||
if err := _u.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (gitu *GroupInvitationTokenUpdate) defaults() {
|
||||
if _, ok := gitu.mutation.UpdatedAt(); !ok {
|
||||
func (_u *GroupInvitationTokenUpdate) defaults() {
|
||||
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
||||
v := groupinvitationtoken.UpdateDefaultUpdatedAt()
|
||||
gitu.mutation.SetUpdatedAt(v)
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
func (gitu *GroupInvitationTokenUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
func (_u *GroupInvitationTokenUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
_spec := sqlgraph.NewUpdateSpec(groupinvitationtoken.Table, groupinvitationtoken.Columns, sqlgraph.NewFieldSpec(groupinvitationtoken.FieldID, field.TypeUUID))
|
||||
if ps := gitu.mutation.predicates; len(ps) > 0 {
|
||||
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := gitu.mutation.UpdatedAt(); ok {
|
||||
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(groupinvitationtoken.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := gitu.mutation.Token(); ok {
|
||||
if value, ok := _u.mutation.Token(); ok {
|
||||
_spec.SetField(groupinvitationtoken.FieldToken, field.TypeBytes, value)
|
||||
}
|
||||
if value, ok := gitu.mutation.ExpiresAt(); ok {
|
||||
if value, ok := _u.mutation.ExpiresAt(); ok {
|
||||
_spec.SetField(groupinvitationtoken.FieldExpiresAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := gitu.mutation.Uses(); ok {
|
||||
if value, ok := _u.mutation.Uses(); ok {
|
||||
_spec.SetField(groupinvitationtoken.FieldUses, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := gitu.mutation.AddedUses(); ok {
|
||||
if value, ok := _u.mutation.AddedUses(); ok {
|
||||
_spec.AddField(groupinvitationtoken.FieldUses, field.TypeInt, value)
|
||||
}
|
||||
if gitu.mutation.GroupCleared() {
|
||||
if _u.mutation.GroupCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -180,7 +180,7 @@ func (gitu *GroupInvitationTokenUpdate) sqlSave(ctx context.Context) (n int, err
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := gitu.mutation.GroupIDs(); len(nodes) > 0 {
|
||||
if nodes := _u.mutation.GroupIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -196,7 +196,7 @@ func (gitu *GroupInvitationTokenUpdate) sqlSave(ctx context.Context) (n int, err
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, gitu.driver, _spec); err != nil {
|
||||
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{groupinvitationtoken.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
@@ -204,8 +204,8 @@ func (gitu *GroupInvitationTokenUpdate) sqlSave(ctx context.Context) (n int, err
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
gitu.mutation.done = true
|
||||
return n, nil
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
// GroupInvitationTokenUpdateOne is the builder for updating a single GroupInvitationToken entity.
|
||||
@@ -217,104 +217,104 @@ type GroupInvitationTokenUpdateOne struct {
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (gituo *GroupInvitationTokenUpdateOne) SetUpdatedAt(t time.Time) *GroupInvitationTokenUpdateOne {
|
||||
gituo.mutation.SetUpdatedAt(t)
|
||||
return gituo
|
||||
func (_u *GroupInvitationTokenUpdateOne) SetUpdatedAt(v time.Time) *GroupInvitationTokenUpdateOne {
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetToken sets the "token" field.
|
||||
func (gituo *GroupInvitationTokenUpdateOne) SetToken(b []byte) *GroupInvitationTokenUpdateOne {
|
||||
gituo.mutation.SetToken(b)
|
||||
return gituo
|
||||
func (_u *GroupInvitationTokenUpdateOne) SetToken(v []byte) *GroupInvitationTokenUpdateOne {
|
||||
_u.mutation.SetToken(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetExpiresAt sets the "expires_at" field.
|
||||
func (gituo *GroupInvitationTokenUpdateOne) SetExpiresAt(t time.Time) *GroupInvitationTokenUpdateOne {
|
||||
gituo.mutation.SetExpiresAt(t)
|
||||
return gituo
|
||||
func (_u *GroupInvitationTokenUpdateOne) SetExpiresAt(v time.Time) *GroupInvitationTokenUpdateOne {
|
||||
_u.mutation.SetExpiresAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableExpiresAt sets the "expires_at" field if the given value is not nil.
|
||||
func (gituo *GroupInvitationTokenUpdateOne) SetNillableExpiresAt(t *time.Time) *GroupInvitationTokenUpdateOne {
|
||||
if t != nil {
|
||||
gituo.SetExpiresAt(*t)
|
||||
func (_u *GroupInvitationTokenUpdateOne) SetNillableExpiresAt(v *time.Time) *GroupInvitationTokenUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetExpiresAt(*v)
|
||||
}
|
||||
return gituo
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUses sets the "uses" field.
|
||||
func (gituo *GroupInvitationTokenUpdateOne) SetUses(i int) *GroupInvitationTokenUpdateOne {
|
||||
gituo.mutation.ResetUses()
|
||||
gituo.mutation.SetUses(i)
|
||||
return gituo
|
||||
func (_u *GroupInvitationTokenUpdateOne) SetUses(v int) *GroupInvitationTokenUpdateOne {
|
||||
_u.mutation.ResetUses()
|
||||
_u.mutation.SetUses(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableUses sets the "uses" field if the given value is not nil.
|
||||
func (gituo *GroupInvitationTokenUpdateOne) SetNillableUses(i *int) *GroupInvitationTokenUpdateOne {
|
||||
if i != nil {
|
||||
gituo.SetUses(*i)
|
||||
func (_u *GroupInvitationTokenUpdateOne) SetNillableUses(v *int) *GroupInvitationTokenUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetUses(*v)
|
||||
}
|
||||
return gituo
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddUses adds i to the "uses" field.
|
||||
func (gituo *GroupInvitationTokenUpdateOne) AddUses(i int) *GroupInvitationTokenUpdateOne {
|
||||
gituo.mutation.AddUses(i)
|
||||
return gituo
|
||||
// AddUses adds value to the "uses" field.
|
||||
func (_u *GroupInvitationTokenUpdateOne) AddUses(v int) *GroupInvitationTokenUpdateOne {
|
||||
_u.mutation.AddUses(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetGroupID sets the "group" edge to the Group entity by ID.
|
||||
func (gituo *GroupInvitationTokenUpdateOne) SetGroupID(id uuid.UUID) *GroupInvitationTokenUpdateOne {
|
||||
gituo.mutation.SetGroupID(id)
|
||||
return gituo
|
||||
func (_u *GroupInvitationTokenUpdateOne) SetGroupID(id uuid.UUID) *GroupInvitationTokenUpdateOne {
|
||||
_u.mutation.SetGroupID(id)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableGroupID sets the "group" edge to the Group entity by ID if the given value is not nil.
|
||||
func (gituo *GroupInvitationTokenUpdateOne) SetNillableGroupID(id *uuid.UUID) *GroupInvitationTokenUpdateOne {
|
||||
func (_u *GroupInvitationTokenUpdateOne) SetNillableGroupID(id *uuid.UUID) *GroupInvitationTokenUpdateOne {
|
||||
if id != nil {
|
||||
gituo = gituo.SetGroupID(*id)
|
||||
_u = _u.SetGroupID(*id)
|
||||
}
|
||||
return gituo
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetGroup sets the "group" edge to the Group entity.
|
||||
func (gituo *GroupInvitationTokenUpdateOne) SetGroup(g *Group) *GroupInvitationTokenUpdateOne {
|
||||
return gituo.SetGroupID(g.ID)
|
||||
func (_u *GroupInvitationTokenUpdateOne) SetGroup(v *Group) *GroupInvitationTokenUpdateOne {
|
||||
return _u.SetGroupID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the GroupInvitationTokenMutation object of the builder.
|
||||
func (gituo *GroupInvitationTokenUpdateOne) Mutation() *GroupInvitationTokenMutation {
|
||||
return gituo.mutation
|
||||
func (_u *GroupInvitationTokenUpdateOne) Mutation() *GroupInvitationTokenMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// ClearGroup clears the "group" edge to the Group entity.
|
||||
func (gituo *GroupInvitationTokenUpdateOne) ClearGroup() *GroupInvitationTokenUpdateOne {
|
||||
gituo.mutation.ClearGroup()
|
||||
return gituo
|
||||
func (_u *GroupInvitationTokenUpdateOne) ClearGroup() *GroupInvitationTokenUpdateOne {
|
||||
_u.mutation.ClearGroup()
|
||||
return _u
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the GroupInvitationTokenUpdate builder.
|
||||
func (gituo *GroupInvitationTokenUpdateOne) Where(ps ...predicate.GroupInvitationToken) *GroupInvitationTokenUpdateOne {
|
||||
gituo.mutation.Where(ps...)
|
||||
return gituo
|
||||
func (_u *GroupInvitationTokenUpdateOne) Where(ps ...predicate.GroupInvitationToken) *GroupInvitationTokenUpdateOne {
|
||||
_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 (gituo *GroupInvitationTokenUpdateOne) Select(field string, fields ...string) *GroupInvitationTokenUpdateOne {
|
||||
gituo.fields = append([]string{field}, fields...)
|
||||
return gituo
|
||||
func (_u *GroupInvitationTokenUpdateOne) Select(field string, fields ...string) *GroupInvitationTokenUpdateOne {
|
||||
_u.fields = append([]string{field}, fields...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated GroupInvitationToken entity.
|
||||
func (gituo *GroupInvitationTokenUpdateOne) Save(ctx context.Context) (*GroupInvitationToken, error) {
|
||||
gituo.defaults()
|
||||
return withHooks(ctx, gituo.sqlSave, gituo.mutation, gituo.hooks)
|
||||
func (_u *GroupInvitationTokenUpdateOne) Save(ctx context.Context) (*GroupInvitationToken, error) {
|
||||
_u.defaults()
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (gituo *GroupInvitationTokenUpdateOne) SaveX(ctx context.Context) *GroupInvitationToken {
|
||||
node, err := gituo.Save(ctx)
|
||||
func (_u *GroupInvitationTokenUpdateOne) SaveX(ctx context.Context) *GroupInvitationToken {
|
||||
node, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -322,34 +322,34 @@ func (gituo *GroupInvitationTokenUpdateOne) SaveX(ctx context.Context) *GroupInv
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (gituo *GroupInvitationTokenUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := gituo.Save(ctx)
|
||||
func (_u *GroupInvitationTokenUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (gituo *GroupInvitationTokenUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := gituo.Exec(ctx); err != nil {
|
||||
func (_u *GroupInvitationTokenUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := _u.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (gituo *GroupInvitationTokenUpdateOne) defaults() {
|
||||
if _, ok := gituo.mutation.UpdatedAt(); !ok {
|
||||
func (_u *GroupInvitationTokenUpdateOne) defaults() {
|
||||
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
||||
v := groupinvitationtoken.UpdateDefaultUpdatedAt()
|
||||
gituo.mutation.SetUpdatedAt(v)
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
func (gituo *GroupInvitationTokenUpdateOne) sqlSave(ctx context.Context) (_node *GroupInvitationToken, err error) {
|
||||
func (_u *GroupInvitationTokenUpdateOne) sqlSave(ctx context.Context) (_node *GroupInvitationToken, err error) {
|
||||
_spec := sqlgraph.NewUpdateSpec(groupinvitationtoken.Table, groupinvitationtoken.Columns, sqlgraph.NewFieldSpec(groupinvitationtoken.FieldID, field.TypeUUID))
|
||||
id, ok := gituo.mutation.ID()
|
||||
id, ok := _u.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "GroupInvitationToken.id" for update`)}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
if fields := gituo.fields; len(fields) > 0 {
|
||||
if fields := _u.fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, groupinvitationtoken.FieldID)
|
||||
for _, f := range fields {
|
||||
@@ -361,29 +361,29 @@ func (gituo *GroupInvitationTokenUpdateOne) sqlSave(ctx context.Context) (_node
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := gituo.mutation.predicates; len(ps) > 0 {
|
||||
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := gituo.mutation.UpdatedAt(); ok {
|
||||
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(groupinvitationtoken.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := gituo.mutation.Token(); ok {
|
||||
if value, ok := _u.mutation.Token(); ok {
|
||||
_spec.SetField(groupinvitationtoken.FieldToken, field.TypeBytes, value)
|
||||
}
|
||||
if value, ok := gituo.mutation.ExpiresAt(); ok {
|
||||
if value, ok := _u.mutation.ExpiresAt(); ok {
|
||||
_spec.SetField(groupinvitationtoken.FieldExpiresAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := gituo.mutation.Uses(); ok {
|
||||
if value, ok := _u.mutation.Uses(); ok {
|
||||
_spec.SetField(groupinvitationtoken.FieldUses, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := gituo.mutation.AddedUses(); ok {
|
||||
if value, ok := _u.mutation.AddedUses(); ok {
|
||||
_spec.AddField(groupinvitationtoken.FieldUses, field.TypeInt, value)
|
||||
}
|
||||
if gituo.mutation.GroupCleared() {
|
||||
if _u.mutation.GroupCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -396,7 +396,7 @@ func (gituo *GroupInvitationTokenUpdateOne) sqlSave(ctx context.Context) (_node
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := gituo.mutation.GroupIDs(); len(nodes) > 0 {
|
||||
if nodes := _u.mutation.GroupIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -412,10 +412,10 @@ func (gituo *GroupInvitationTokenUpdateOne) sqlSave(ctx context.Context) (_node
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
_node = &GroupInvitationToken{config: gituo.config}
|
||||
_node = &GroupInvitationToken{config: _u.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
if err = sqlgraph.UpdateNode(ctx, gituo.driver, _spec); err != nil {
|
||||
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{groupinvitationtoken.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
@@ -423,6 +423,6 @@ func (gituo *GroupInvitationTokenUpdateOne) sqlSave(ctx context.Context) (_node
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
gituo.mutation.done = true
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
@@ -4,50 +4,50 @@ package ent
|
||||
|
||||
import "github.com/google/uuid"
|
||||
|
||||
func (a *Attachment) GetID() uuid.UUID {
|
||||
return a.ID
|
||||
func (_m *Attachment) GetID() uuid.UUID {
|
||||
return _m.ID
|
||||
}
|
||||
|
||||
func (ar *AuthRoles) GetID() int {
|
||||
return ar.ID
|
||||
func (_m *AuthRoles) GetID() int {
|
||||
return _m.ID
|
||||
}
|
||||
|
||||
func (at *AuthTokens) GetID() uuid.UUID {
|
||||
return at.ID
|
||||
func (_m *AuthTokens) GetID() uuid.UUID {
|
||||
return _m.ID
|
||||
}
|
||||
|
||||
func (e *Entity) GetID() uuid.UUID {
|
||||
return e.ID
|
||||
func (_m *Entity) GetID() uuid.UUID {
|
||||
return _m.ID
|
||||
}
|
||||
|
||||
func (ef *EntityField) GetID() uuid.UUID {
|
||||
return ef.ID
|
||||
func (_m *EntityField) GetID() uuid.UUID {
|
||||
return _m.ID
|
||||
}
|
||||
|
||||
func (et *EntityType) GetID() uuid.UUID {
|
||||
return et.ID
|
||||
func (_m *EntityType) GetID() uuid.UUID {
|
||||
return _m.ID
|
||||
}
|
||||
|
||||
func (gr *Group) GetID() uuid.UUID {
|
||||
return gr.ID
|
||||
func (_m *Group) GetID() uuid.UUID {
|
||||
return _m.ID
|
||||
}
|
||||
|
||||
func (git *GroupInvitationToken) GetID() uuid.UUID {
|
||||
return git.ID
|
||||
func (_m *GroupInvitationToken) GetID() uuid.UUID {
|
||||
return _m.ID
|
||||
}
|
||||
|
||||
func (l *Label) GetID() uuid.UUID {
|
||||
return l.ID
|
||||
func (_m *Label) GetID() uuid.UUID {
|
||||
return _m.ID
|
||||
}
|
||||
|
||||
func (me *MaintenanceEntry) GetID() uuid.UUID {
|
||||
return me.ID
|
||||
func (_m *MaintenanceEntry) GetID() uuid.UUID {
|
||||
return _m.ID
|
||||
}
|
||||
|
||||
func (n *Notifier) GetID() uuid.UUID {
|
||||
return n.ID
|
||||
func (_m *Notifier) GetID() uuid.UUID {
|
||||
return _m.ID
|
||||
}
|
||||
|
||||
func (u *User) GetID() uuid.UUID {
|
||||
return u.ID
|
||||
func (_m *User) GetID() uuid.UUID {
|
||||
return _m.ID
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ func (*Label) scanValues(columns []string) ([]any, error) {
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the Label fields.
|
||||
func (l *Label) assignValues(columns []string, values []any) error {
|
||||
func (_m *Label) assignValues(columns []string, values []any) error {
|
||||
if m, n := len(values), len(columns); m < n {
|
||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||
}
|
||||
@@ -99,47 +99,47 @@ func (l *Label) assignValues(columns []string, values []any) error {
|
||||
if value, ok := values[i].(*uuid.UUID); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", values[i])
|
||||
} else if value != nil {
|
||||
l.ID = *value
|
||||
_m.ID = *value
|
||||
}
|
||||
case label.FieldCreatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
||||
} else if value.Valid {
|
||||
l.CreatedAt = value.Time
|
||||
_m.CreatedAt = value.Time
|
||||
}
|
||||
case label.FieldUpdatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
|
||||
} else if value.Valid {
|
||||
l.UpdatedAt = value.Time
|
||||
_m.UpdatedAt = value.Time
|
||||
}
|
||||
case label.FieldName:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field name", values[i])
|
||||
} else if value.Valid {
|
||||
l.Name = value.String
|
||||
_m.Name = value.String
|
||||
}
|
||||
case label.FieldDescription:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field description", values[i])
|
||||
} else if value.Valid {
|
||||
l.Description = value.String
|
||||
_m.Description = value.String
|
||||
}
|
||||
case label.FieldColor:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field color", values[i])
|
||||
} else if value.Valid {
|
||||
l.Color = value.String
|
||||
_m.Color = value.String
|
||||
}
|
||||
case label.ForeignKeys[0]:
|
||||
if value, ok := values[i].(*sql.NullScanner); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field group_labels", values[i])
|
||||
} else if value.Valid {
|
||||
l.group_labels = new(uuid.UUID)
|
||||
*l.group_labels = *value.S.(*uuid.UUID)
|
||||
_m.group_labels = new(uuid.UUID)
|
||||
*_m.group_labels = *value.S.(*uuid.UUID)
|
||||
}
|
||||
default:
|
||||
l.selectValues.Set(columns[i], values[i])
|
||||
_m.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -147,57 +147,57 @@ func (l *Label) assignValues(columns []string, values []any) error {
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the Label.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (l *Label) Value(name string) (ent.Value, error) {
|
||||
return l.selectValues.Get(name)
|
||||
func (_m *Label) Value(name string) (ent.Value, error) {
|
||||
return _m.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// QueryGroup queries the "group" edge of the Label entity.
|
||||
func (l *Label) QueryGroup() *GroupQuery {
|
||||
return NewLabelClient(l.config).QueryGroup(l)
|
||||
func (_m *Label) QueryGroup() *GroupQuery {
|
||||
return NewLabelClient(_m.config).QueryGroup(_m)
|
||||
}
|
||||
|
||||
// QueryEntities queries the "entities" edge of the Label entity.
|
||||
func (l *Label) QueryEntities() *EntityQuery {
|
||||
return NewLabelClient(l.config).QueryEntities(l)
|
||||
func (_m *Label) QueryEntities() *EntityQuery {
|
||||
return NewLabelClient(_m.config).QueryEntities(_m)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this Label.
|
||||
// Note that you need to call Label.Unwrap() before calling this method if this Label
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (l *Label) Update() *LabelUpdateOne {
|
||||
return NewLabelClient(l.config).UpdateOne(l)
|
||||
func (_m *Label) Update() *LabelUpdateOne {
|
||||
return NewLabelClient(_m.config).UpdateOne(_m)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the Label entity that was returned from a transaction after it was closed,
|
||||
// so that all future queries will be executed through the driver which created the transaction.
|
||||
func (l *Label) Unwrap() *Label {
|
||||
_tx, ok := l.config.driver.(*txDriver)
|
||||
func (_m *Label) Unwrap() *Label {
|
||||
_tx, ok := _m.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: Label is not a transactional entity")
|
||||
}
|
||||
l.config.driver = _tx.drv
|
||||
return l
|
||||
_m.config.driver = _tx.drv
|
||||
return _m
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (l *Label) String() string {
|
||||
func (_m *Label) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("Label(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", l.ID))
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||||
builder.WriteString("created_at=")
|
||||
builder.WriteString(l.CreatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("updated_at=")
|
||||
builder.WriteString(l.UpdatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("name=")
|
||||
builder.WriteString(l.Name)
|
||||
builder.WriteString(_m.Name)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("description=")
|
||||
builder.WriteString(l.Description)
|
||||
builder.WriteString(_m.Description)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("color=")
|
||||
builder.WriteString(l.Color)
|
||||
builder.WriteString(_m.Color)
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
@@ -24,121 +24,121 @@ type LabelCreate struct {
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (lc *LabelCreate) SetCreatedAt(t time.Time) *LabelCreate {
|
||||
lc.mutation.SetCreatedAt(t)
|
||||
return lc
|
||||
func (_c *LabelCreate) SetCreatedAt(v time.Time) *LabelCreate {
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||
func (lc *LabelCreate) SetNillableCreatedAt(t *time.Time) *LabelCreate {
|
||||
if t != nil {
|
||||
lc.SetCreatedAt(*t)
|
||||
func (_c *LabelCreate) SetNillableCreatedAt(v *time.Time) *LabelCreate {
|
||||
if v != nil {
|
||||
_c.SetCreatedAt(*v)
|
||||
}
|
||||
return lc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (lc *LabelCreate) SetUpdatedAt(t time.Time) *LabelCreate {
|
||||
lc.mutation.SetUpdatedAt(t)
|
||||
return lc
|
||||
func (_c *LabelCreate) SetUpdatedAt(v time.Time) *LabelCreate {
|
||||
_c.mutation.SetUpdatedAt(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
||||
func (lc *LabelCreate) SetNillableUpdatedAt(t *time.Time) *LabelCreate {
|
||||
if t != nil {
|
||||
lc.SetUpdatedAt(*t)
|
||||
func (_c *LabelCreate) SetNillableUpdatedAt(v *time.Time) *LabelCreate {
|
||||
if v != nil {
|
||||
_c.SetUpdatedAt(*v)
|
||||
}
|
||||
return lc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (lc *LabelCreate) SetName(s string) *LabelCreate {
|
||||
lc.mutation.SetName(s)
|
||||
return lc
|
||||
func (_c *LabelCreate) SetName(v string) *LabelCreate {
|
||||
_c.mutation.SetName(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetDescription sets the "description" field.
|
||||
func (lc *LabelCreate) SetDescription(s string) *LabelCreate {
|
||||
lc.mutation.SetDescription(s)
|
||||
return lc
|
||||
func (_c *LabelCreate) SetDescription(v string) *LabelCreate {
|
||||
_c.mutation.SetDescription(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableDescription sets the "description" field if the given value is not nil.
|
||||
func (lc *LabelCreate) SetNillableDescription(s *string) *LabelCreate {
|
||||
if s != nil {
|
||||
lc.SetDescription(*s)
|
||||
func (_c *LabelCreate) SetNillableDescription(v *string) *LabelCreate {
|
||||
if v != nil {
|
||||
_c.SetDescription(*v)
|
||||
}
|
||||
return lc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetColor sets the "color" field.
|
||||
func (lc *LabelCreate) SetColor(s string) *LabelCreate {
|
||||
lc.mutation.SetColor(s)
|
||||
return lc
|
||||
func (_c *LabelCreate) SetColor(v string) *LabelCreate {
|
||||
_c.mutation.SetColor(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableColor sets the "color" field if the given value is not nil.
|
||||
func (lc *LabelCreate) SetNillableColor(s *string) *LabelCreate {
|
||||
if s != nil {
|
||||
lc.SetColor(*s)
|
||||
func (_c *LabelCreate) SetNillableColor(v *string) *LabelCreate {
|
||||
if v != nil {
|
||||
_c.SetColor(*v)
|
||||
}
|
||||
return lc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetID sets the "id" field.
|
||||
func (lc *LabelCreate) SetID(u uuid.UUID) *LabelCreate {
|
||||
lc.mutation.SetID(u)
|
||||
return lc
|
||||
func (_c *LabelCreate) SetID(v uuid.UUID) *LabelCreate {
|
||||
_c.mutation.SetID(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableID sets the "id" field if the given value is not nil.
|
||||
func (lc *LabelCreate) SetNillableID(u *uuid.UUID) *LabelCreate {
|
||||
if u != nil {
|
||||
lc.SetID(*u)
|
||||
func (_c *LabelCreate) SetNillableID(v *uuid.UUID) *LabelCreate {
|
||||
if v != nil {
|
||||
_c.SetID(*v)
|
||||
}
|
||||
return lc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetGroupID sets the "group" edge to the Group entity by ID.
|
||||
func (lc *LabelCreate) SetGroupID(id uuid.UUID) *LabelCreate {
|
||||
lc.mutation.SetGroupID(id)
|
||||
return lc
|
||||
func (_c *LabelCreate) SetGroupID(id uuid.UUID) *LabelCreate {
|
||||
_c.mutation.SetGroupID(id)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetGroup sets the "group" edge to the Group entity.
|
||||
func (lc *LabelCreate) SetGroup(g *Group) *LabelCreate {
|
||||
return lc.SetGroupID(g.ID)
|
||||
func (_c *LabelCreate) SetGroup(v *Group) *LabelCreate {
|
||||
return _c.SetGroupID(v.ID)
|
||||
}
|
||||
|
||||
// AddEntityIDs adds the "entities" edge to the Entity entity by IDs.
|
||||
func (lc *LabelCreate) AddEntityIDs(ids ...uuid.UUID) *LabelCreate {
|
||||
lc.mutation.AddEntityIDs(ids...)
|
||||
return lc
|
||||
func (_c *LabelCreate) AddEntityIDs(ids ...uuid.UUID) *LabelCreate {
|
||||
_c.mutation.AddEntityIDs(ids...)
|
||||
return _c
|
||||
}
|
||||
|
||||
// AddEntities adds the "entities" edges to the Entity entity.
|
||||
func (lc *LabelCreate) AddEntities(e ...*Entity) *LabelCreate {
|
||||
ids := make([]uuid.UUID, len(e))
|
||||
for i := range e {
|
||||
ids[i] = e[i].ID
|
||||
func (_c *LabelCreate) AddEntities(v ...*Entity) *LabelCreate {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return lc.AddEntityIDs(ids...)
|
||||
return _c.AddEntityIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the LabelMutation object of the builder.
|
||||
func (lc *LabelCreate) Mutation() *LabelMutation {
|
||||
return lc.mutation
|
||||
func (_c *LabelCreate) Mutation() *LabelMutation {
|
||||
return _c.mutation
|
||||
}
|
||||
|
||||
// Save creates the Label in the database.
|
||||
func (lc *LabelCreate) Save(ctx context.Context) (*Label, error) {
|
||||
lc.defaults()
|
||||
return withHooks(ctx, lc.sqlSave, lc.mutation, lc.hooks)
|
||||
func (_c *LabelCreate) Save(ctx context.Context) (*Label, error) {
|
||||
_c.defaults()
|
||||
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (lc *LabelCreate) SaveX(ctx context.Context) *Label {
|
||||
v, err := lc.Save(ctx)
|
||||
func (_c *LabelCreate) SaveX(ctx context.Context) *Label {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -146,72 +146,72 @@ func (lc *LabelCreate) SaveX(ctx context.Context) *Label {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (lc *LabelCreate) Exec(ctx context.Context) error {
|
||||
_, err := lc.Save(ctx)
|
||||
func (_c *LabelCreate) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (lc *LabelCreate) ExecX(ctx context.Context) {
|
||||
if err := lc.Exec(ctx); err != nil {
|
||||
func (_c *LabelCreate) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (lc *LabelCreate) defaults() {
|
||||
if _, ok := lc.mutation.CreatedAt(); !ok {
|
||||
func (_c *LabelCreate) defaults() {
|
||||
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||
v := label.DefaultCreatedAt()
|
||||
lc.mutation.SetCreatedAt(v)
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
}
|
||||
if _, ok := lc.mutation.UpdatedAt(); !ok {
|
||||
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
||||
v := label.DefaultUpdatedAt()
|
||||
lc.mutation.SetUpdatedAt(v)
|
||||
_c.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
if _, ok := lc.mutation.ID(); !ok {
|
||||
if _, ok := _c.mutation.ID(); !ok {
|
||||
v := label.DefaultID()
|
||||
lc.mutation.SetID(v)
|
||||
_c.mutation.SetID(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (lc *LabelCreate) check() error {
|
||||
if _, ok := lc.mutation.CreatedAt(); !ok {
|
||||
func (_c *LabelCreate) check() error {
|
||||
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Label.created_at"`)}
|
||||
}
|
||||
if _, ok := lc.mutation.UpdatedAt(); !ok {
|
||||
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
||||
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Label.updated_at"`)}
|
||||
}
|
||||
if _, ok := lc.mutation.Name(); !ok {
|
||||
if _, ok := _c.mutation.Name(); !ok {
|
||||
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Label.name"`)}
|
||||
}
|
||||
if v, ok := lc.mutation.Name(); ok {
|
||||
if v, ok := _c.mutation.Name(); ok {
|
||||
if err := label.NameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Label.name": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := lc.mutation.Description(); ok {
|
||||
if v, ok := _c.mutation.Description(); ok {
|
||||
if err := label.DescriptionValidator(v); err != nil {
|
||||
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Label.description": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := lc.mutation.Color(); ok {
|
||||
if v, ok := _c.mutation.Color(); ok {
|
||||
if err := label.ColorValidator(v); err != nil {
|
||||
return &ValidationError{Name: "color", err: fmt.Errorf(`ent: validator failed for field "Label.color": %w`, err)}
|
||||
}
|
||||
}
|
||||
if len(lc.mutation.GroupIDs()) == 0 {
|
||||
if len(_c.mutation.GroupIDs()) == 0 {
|
||||
return &ValidationError{Name: "group", err: errors.New(`ent: missing required edge "Label.group"`)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (lc *LabelCreate) sqlSave(ctx context.Context) (*Label, error) {
|
||||
if err := lc.check(); err != nil {
|
||||
func (_c *LabelCreate) sqlSave(ctx context.Context) (*Label, error) {
|
||||
if err := _c.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_node, _spec := lc.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, lc.driver, _spec); err != nil {
|
||||
_node, _spec := _c.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
@@ -224,41 +224,41 @@ func (lc *LabelCreate) sqlSave(ctx context.Context) (*Label, error) {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
lc.mutation.id = &_node.ID
|
||||
lc.mutation.done = true
|
||||
_c.mutation.id = &_node.ID
|
||||
_c.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
func (lc *LabelCreate) createSpec() (*Label, *sqlgraph.CreateSpec) {
|
||||
func (_c *LabelCreate) createSpec() (*Label, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &Label{config: lc.config}
|
||||
_node = &Label{config: _c.config}
|
||||
_spec = sqlgraph.NewCreateSpec(label.Table, sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID))
|
||||
)
|
||||
if id, ok := lc.mutation.ID(); ok {
|
||||
if id, ok := _c.mutation.ID(); ok {
|
||||
_node.ID = id
|
||||
_spec.ID.Value = &id
|
||||
}
|
||||
if value, ok := lc.mutation.CreatedAt(); ok {
|
||||
if value, ok := _c.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(label.FieldCreatedAt, field.TypeTime, value)
|
||||
_node.CreatedAt = value
|
||||
}
|
||||
if value, ok := lc.mutation.UpdatedAt(); ok {
|
||||
if value, ok := _c.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(label.FieldUpdatedAt, field.TypeTime, value)
|
||||
_node.UpdatedAt = value
|
||||
}
|
||||
if value, ok := lc.mutation.Name(); ok {
|
||||
if value, ok := _c.mutation.Name(); ok {
|
||||
_spec.SetField(label.FieldName, field.TypeString, value)
|
||||
_node.Name = value
|
||||
}
|
||||
if value, ok := lc.mutation.Description(); ok {
|
||||
if value, ok := _c.mutation.Description(); ok {
|
||||
_spec.SetField(label.FieldDescription, field.TypeString, value)
|
||||
_node.Description = value
|
||||
}
|
||||
if value, ok := lc.mutation.Color(); ok {
|
||||
if value, ok := _c.mutation.Color(); ok {
|
||||
_spec.SetField(label.FieldColor, field.TypeString, value)
|
||||
_node.Color = value
|
||||
}
|
||||
if nodes := lc.mutation.GroupIDs(); len(nodes) > 0 {
|
||||
if nodes := _c.mutation.GroupIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -275,7 +275,7 @@ func (lc *LabelCreate) createSpec() (*Label, *sqlgraph.CreateSpec) {
|
||||
_node.group_labels = &nodes[0]
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
if nodes := lc.mutation.EntitiesIDs(); len(nodes) > 0 {
|
||||
if nodes := _c.mutation.EntitiesIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2M,
|
||||
Inverse: false,
|
||||
@@ -302,16 +302,16 @@ type LabelCreateBulk struct {
|
||||
}
|
||||
|
||||
// Save creates the Label entities in the database.
|
||||
func (lcb *LabelCreateBulk) Save(ctx context.Context) ([]*Label, error) {
|
||||
if lcb.err != nil {
|
||||
return nil, lcb.err
|
||||
func (_c *LabelCreateBulk) Save(ctx context.Context) ([]*Label, error) {
|
||||
if _c.err != nil {
|
||||
return nil, _c.err
|
||||
}
|
||||
specs := make([]*sqlgraph.CreateSpec, len(lcb.builders))
|
||||
nodes := make([]*Label, len(lcb.builders))
|
||||
mutators := make([]Mutator, len(lcb.builders))
|
||||
for i := range lcb.builders {
|
||||
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
||||
nodes := make([]*Label, len(_c.builders))
|
||||
mutators := make([]Mutator, len(_c.builders))
|
||||
for i := range _c.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := lcb.builders[i]
|
||||
builder := _c.builders[i]
|
||||
builder.defaults()
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*LabelMutation)
|
||||
@@ -325,11 +325,11 @@ func (lcb *LabelCreateBulk) Save(ctx context.Context) ([]*Label, error) {
|
||||
var err error
|
||||
nodes[i], specs[i] = builder.createSpec()
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, lcb.builders[i+1].mutation)
|
||||
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
|
||||
} else {
|
||||
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
||||
// Invoke the actual operation on the latest mutation in the chain.
|
||||
if err = sqlgraph.BatchCreate(ctx, lcb.driver, spec); err != nil {
|
||||
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
@@ -349,7 +349,7 @@ func (lcb *LabelCreateBulk) Save(ctx context.Context) ([]*Label, error) {
|
||||
}(i, ctx)
|
||||
}
|
||||
if len(mutators) > 0 {
|
||||
if _, err := mutators[0].Mutate(ctx, lcb.builders[0].mutation); err != nil {
|
||||
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
@@ -357,8 +357,8 @@ func (lcb *LabelCreateBulk) Save(ctx context.Context) ([]*Label, error) {
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (lcb *LabelCreateBulk) SaveX(ctx context.Context) []*Label {
|
||||
v, err := lcb.Save(ctx)
|
||||
func (_c *LabelCreateBulk) SaveX(ctx context.Context) []*Label {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -366,14 +366,14 @@ func (lcb *LabelCreateBulk) SaveX(ctx context.Context) []*Label {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (lcb *LabelCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := lcb.Save(ctx)
|
||||
func (_c *LabelCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (lcb *LabelCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := lcb.Exec(ctx); err != nil {
|
||||
func (_c *LabelCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,56 +20,56 @@ type LabelDelete struct {
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the LabelDelete builder.
|
||||
func (ld *LabelDelete) Where(ps ...predicate.Label) *LabelDelete {
|
||||
ld.mutation.Where(ps...)
|
||||
return ld
|
||||
func (_d *LabelDelete) Where(ps ...predicate.Label) *LabelDelete {
|
||||
_d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (ld *LabelDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, ld.sqlExec, ld.mutation, ld.hooks)
|
||||
func (_d *LabelDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (ld *LabelDelete) ExecX(ctx context.Context) int {
|
||||
n, err := ld.Exec(ctx)
|
||||
func (_d *LabelDelete) ExecX(ctx context.Context) int {
|
||||
n, err := _d.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (ld *LabelDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
func (_d *LabelDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := sqlgraph.NewDeleteSpec(label.Table, sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID))
|
||||
if ps := ld.mutation.predicates; len(ps) > 0 {
|
||||
if ps := _d.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, ld.driver, _spec)
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec)
|
||||
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
ld.mutation.done = true
|
||||
_d.mutation.done = true
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// LabelDeleteOne is the builder for deleting a single Label entity.
|
||||
type LabelDeleteOne struct {
|
||||
ld *LabelDelete
|
||||
_d *LabelDelete
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the LabelDelete builder.
|
||||
func (ldo *LabelDeleteOne) Where(ps ...predicate.Label) *LabelDeleteOne {
|
||||
ldo.ld.mutation.Where(ps...)
|
||||
return ldo
|
||||
func (_d *LabelDeleteOne) Where(ps ...predicate.Label) *LabelDeleteOne {
|
||||
_d._d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (ldo *LabelDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := ldo.ld.Exec(ctx)
|
||||
func (_d *LabelDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := _d._d.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
@@ -81,8 +81,8 @@ func (ldo *LabelDeleteOne) Exec(ctx context.Context) error {
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (ldo *LabelDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := ldo.Exec(ctx); err != nil {
|
||||
func (_d *LabelDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := _d.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,44 +35,44 @@ type LabelQuery struct {
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the LabelQuery builder.
|
||||
func (lq *LabelQuery) Where(ps ...predicate.Label) *LabelQuery {
|
||||
lq.predicates = append(lq.predicates, ps...)
|
||||
return lq
|
||||
func (_q *LabelQuery) Where(ps ...predicate.Label) *LabelQuery {
|
||||
_q.predicates = append(_q.predicates, ps...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// Limit the number of records to be returned by this query.
|
||||
func (lq *LabelQuery) Limit(limit int) *LabelQuery {
|
||||
lq.ctx.Limit = &limit
|
||||
return lq
|
||||
func (_q *LabelQuery) Limit(limit int) *LabelQuery {
|
||||
_q.ctx.Limit = &limit
|
||||
return _q
|
||||
}
|
||||
|
||||
// Offset to start from.
|
||||
func (lq *LabelQuery) Offset(offset int) *LabelQuery {
|
||||
lq.ctx.Offset = &offset
|
||||
return lq
|
||||
func (_q *LabelQuery) Offset(offset int) *LabelQuery {
|
||||
_q.ctx.Offset = &offset
|
||||
return _q
|
||||
}
|
||||
|
||||
// Unique configures the query builder to filter duplicate records on query.
|
||||
// By default, unique is set to true, and can be disabled using this method.
|
||||
func (lq *LabelQuery) Unique(unique bool) *LabelQuery {
|
||||
lq.ctx.Unique = &unique
|
||||
return lq
|
||||
func (_q *LabelQuery) Unique(unique bool) *LabelQuery {
|
||||
_q.ctx.Unique = &unique
|
||||
return _q
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (lq *LabelQuery) Order(o ...label.OrderOption) *LabelQuery {
|
||||
lq.order = append(lq.order, o...)
|
||||
return lq
|
||||
func (_q *LabelQuery) Order(o ...label.OrderOption) *LabelQuery {
|
||||
_q.order = append(_q.order, o...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// QueryGroup chains the current query on the "group" edge.
|
||||
func (lq *LabelQuery) QueryGroup() *GroupQuery {
|
||||
query := (&GroupClient{config: lq.config}).Query()
|
||||
func (_q *LabelQuery) QueryGroup() *GroupQuery {
|
||||
query := (&GroupClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := lq.prepareQuery(ctx); err != nil {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := lq.sqlQuery(ctx)
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -81,20 +81,20 @@ func (lq *LabelQuery) QueryGroup() *GroupQuery {
|
||||
sqlgraph.To(group.Table, group.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, label.GroupTable, label.GroupColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(lq.driver.Dialect(), step)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryEntities chains the current query on the "entities" edge.
|
||||
func (lq *LabelQuery) QueryEntities() *EntityQuery {
|
||||
query := (&EntityClient{config: lq.config}).Query()
|
||||
func (_q *LabelQuery) QueryEntities() *EntityQuery {
|
||||
query := (&EntityClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := lq.prepareQuery(ctx); err != nil {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := lq.sqlQuery(ctx)
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -103,7 +103,7 @@ func (lq *LabelQuery) QueryEntities() *EntityQuery {
|
||||
sqlgraph.To(entity.Table, entity.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2M, false, label.EntitiesTable, label.EntitiesPrimaryKey...),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(lq.driver.Dialect(), step)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
@@ -111,8 +111,8 @@ func (lq *LabelQuery) QueryEntities() *EntityQuery {
|
||||
|
||||
// First returns the first Label entity from the query.
|
||||
// Returns a *NotFoundError when no Label was found.
|
||||
func (lq *LabelQuery) First(ctx context.Context) (*Label, error) {
|
||||
nodes, err := lq.Limit(1).All(setContextOp(ctx, lq.ctx, ent.OpQueryFirst))
|
||||
func (_q *LabelQuery) First(ctx context.Context) (*Label, error) {
|
||||
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -123,8 +123,8 @@ func (lq *LabelQuery) First(ctx context.Context) (*Label, error) {
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (lq *LabelQuery) FirstX(ctx context.Context) *Label {
|
||||
node, err := lq.First(ctx)
|
||||
func (_q *LabelQuery) FirstX(ctx context.Context) *Label {
|
||||
node, err := _q.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
@@ -133,9 +133,9 @@ func (lq *LabelQuery) FirstX(ctx context.Context) *Label {
|
||||
|
||||
// FirstID returns the first Label ID from the query.
|
||||
// Returns a *NotFoundError when no Label ID was found.
|
||||
func (lq *LabelQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
func (_q *LabelQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
var ids []uuid.UUID
|
||||
if ids, err = lq.Limit(1).IDs(setContextOp(ctx, lq.ctx, ent.OpQueryFirstID)); err != nil {
|
||||
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
@@ -146,8 +146,8 @@ func (lq *LabelQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (lq *LabelQuery) FirstIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := lq.FirstID(ctx)
|
||||
func (_q *LabelQuery) FirstIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := _q.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
@@ -157,8 +157,8 @@ func (lq *LabelQuery) FirstIDX(ctx context.Context) uuid.UUID {
|
||||
// Only returns a single Label entity found by the query, ensuring it only returns one.
|
||||
// Returns a *NotSingularError when more than one Label entity is found.
|
||||
// Returns a *NotFoundError when no Label entities are found.
|
||||
func (lq *LabelQuery) Only(ctx context.Context) (*Label, error) {
|
||||
nodes, err := lq.Limit(2).All(setContextOp(ctx, lq.ctx, ent.OpQueryOnly))
|
||||
func (_q *LabelQuery) Only(ctx context.Context) (*Label, error) {
|
||||
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -173,8 +173,8 @@ func (lq *LabelQuery) Only(ctx context.Context) (*Label, error) {
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (lq *LabelQuery) OnlyX(ctx context.Context) *Label {
|
||||
node, err := lq.Only(ctx)
|
||||
func (_q *LabelQuery) OnlyX(ctx context.Context) *Label {
|
||||
node, err := _q.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -184,9 +184,9 @@ func (lq *LabelQuery) OnlyX(ctx context.Context) *Label {
|
||||
// OnlyID is like Only, but returns the only Label ID in the query.
|
||||
// Returns a *NotSingularError when more than one Label ID is found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (lq *LabelQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
func (_q *LabelQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
var ids []uuid.UUID
|
||||
if ids, err = lq.Limit(2).IDs(setContextOp(ctx, lq.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
@@ -201,8 +201,8 @@ func (lq *LabelQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (lq *LabelQuery) OnlyIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := lq.OnlyID(ctx)
|
||||
func (_q *LabelQuery) OnlyIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := _q.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -210,18 +210,18 @@ func (lq *LabelQuery) OnlyIDX(ctx context.Context) uuid.UUID {
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of Labels.
|
||||
func (lq *LabelQuery) All(ctx context.Context) ([]*Label, error) {
|
||||
ctx = setContextOp(ctx, lq.ctx, ent.OpQueryAll)
|
||||
if err := lq.prepareQuery(ctx); err != nil {
|
||||
func (_q *LabelQuery) All(ctx context.Context) ([]*Label, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qr := querierAll[[]*Label, *LabelQuery]()
|
||||
return withInterceptors[[]*Label](ctx, lq, qr, lq.inters)
|
||||
return withInterceptors[[]*Label](ctx, _q, qr, _q.inters)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (lq *LabelQuery) AllX(ctx context.Context) []*Label {
|
||||
nodes, err := lq.All(ctx)
|
||||
func (_q *LabelQuery) AllX(ctx context.Context) []*Label {
|
||||
nodes, err := _q.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -229,20 +229,20 @@ func (lq *LabelQuery) AllX(ctx context.Context) []*Label {
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of Label IDs.
|
||||
func (lq *LabelQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
|
||||
if lq.ctx.Unique == nil && lq.path != nil {
|
||||
lq.Unique(true)
|
||||
func (_q *LabelQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
|
||||
if _q.ctx.Unique == nil && _q.path != nil {
|
||||
_q.Unique(true)
|
||||
}
|
||||
ctx = setContextOp(ctx, lq.ctx, ent.OpQueryIDs)
|
||||
if err = lq.Select(label.FieldID).Scan(ctx, &ids); err != nil {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
|
||||
if err = _q.Select(label.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (lq *LabelQuery) IDsX(ctx context.Context) []uuid.UUID {
|
||||
ids, err := lq.IDs(ctx)
|
||||
func (_q *LabelQuery) IDsX(ctx context.Context) []uuid.UUID {
|
||||
ids, err := _q.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -250,17 +250,17 @@ func (lq *LabelQuery) IDsX(ctx context.Context) []uuid.UUID {
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (lq *LabelQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, lq.ctx, ent.OpQueryCount)
|
||||
if err := lq.prepareQuery(ctx); err != nil {
|
||||
func (_q *LabelQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return withInterceptors[int](ctx, lq, querierCount[*LabelQuery](), lq.inters)
|
||||
return withInterceptors[int](ctx, _q, querierCount[*LabelQuery](), _q.inters)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (lq *LabelQuery) CountX(ctx context.Context) int {
|
||||
count, err := lq.Count(ctx)
|
||||
func (_q *LabelQuery) CountX(ctx context.Context) int {
|
||||
count, err := _q.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -268,9 +268,9 @@ func (lq *LabelQuery) CountX(ctx context.Context) int {
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (lq *LabelQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, lq.ctx, ent.OpQueryExist)
|
||||
switch _, err := lq.FirstID(ctx); {
|
||||
func (_q *LabelQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
|
||||
switch _, err := _q.FirstID(ctx); {
|
||||
case IsNotFound(err):
|
||||
return false, nil
|
||||
case err != nil:
|
||||
@@ -281,8 +281,8 @@ func (lq *LabelQuery) Exist(ctx context.Context) (bool, error) {
|
||||
}
|
||||
|
||||
// ExistX is like Exist, but panics if an error occurs.
|
||||
func (lq *LabelQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := lq.Exist(ctx)
|
||||
func (_q *LabelQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := _q.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -291,44 +291,44 @@ func (lq *LabelQuery) ExistX(ctx context.Context) bool {
|
||||
|
||||
// Clone returns a duplicate of the LabelQuery builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (lq *LabelQuery) Clone() *LabelQuery {
|
||||
if lq == nil {
|
||||
func (_q *LabelQuery) Clone() *LabelQuery {
|
||||
if _q == nil {
|
||||
return nil
|
||||
}
|
||||
return &LabelQuery{
|
||||
config: lq.config,
|
||||
ctx: lq.ctx.Clone(),
|
||||
order: append([]label.OrderOption{}, lq.order...),
|
||||
inters: append([]Interceptor{}, lq.inters...),
|
||||
predicates: append([]predicate.Label{}, lq.predicates...),
|
||||
withGroup: lq.withGroup.Clone(),
|
||||
withEntities: lq.withEntities.Clone(),
|
||||
config: _q.config,
|
||||
ctx: _q.ctx.Clone(),
|
||||
order: append([]label.OrderOption{}, _q.order...),
|
||||
inters: append([]Interceptor{}, _q.inters...),
|
||||
predicates: append([]predicate.Label{}, _q.predicates...),
|
||||
withGroup: _q.withGroup.Clone(),
|
||||
withEntities: _q.withEntities.Clone(),
|
||||
// clone intermediate query.
|
||||
sql: lq.sql.Clone(),
|
||||
path: lq.path,
|
||||
sql: _q.sql.Clone(),
|
||||
path: _q.path,
|
||||
}
|
||||
}
|
||||
|
||||
// WithGroup tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "group" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (lq *LabelQuery) WithGroup(opts ...func(*GroupQuery)) *LabelQuery {
|
||||
query := (&GroupClient{config: lq.config}).Query()
|
||||
func (_q *LabelQuery) WithGroup(opts ...func(*GroupQuery)) *LabelQuery {
|
||||
query := (&GroupClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
lq.withGroup = query
|
||||
return lq
|
||||
_q.withGroup = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// WithEntities tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "entities" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (lq *LabelQuery) WithEntities(opts ...func(*EntityQuery)) *LabelQuery {
|
||||
query := (&EntityClient{config: lq.config}).Query()
|
||||
func (_q *LabelQuery) WithEntities(opts ...func(*EntityQuery)) *LabelQuery {
|
||||
query := (&EntityClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
lq.withEntities = query
|
||||
return lq
|
||||
_q.withEntities = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// GroupBy is used to group vertices by one or more fields/columns.
|
||||
@@ -345,10 +345,10 @@ func (lq *LabelQuery) WithEntities(opts ...func(*EntityQuery)) *LabelQuery {
|
||||
// GroupBy(label.FieldCreatedAt).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (lq *LabelQuery) GroupBy(field string, fields ...string) *LabelGroupBy {
|
||||
lq.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &LabelGroupBy{build: lq}
|
||||
grbuild.flds = &lq.ctx.Fields
|
||||
func (_q *LabelQuery) GroupBy(field string, fields ...string) *LabelGroupBy {
|
||||
_q.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &LabelGroupBy{build: _q}
|
||||
grbuild.flds = &_q.ctx.Fields
|
||||
grbuild.label = label.Label
|
||||
grbuild.scan = grbuild.Scan
|
||||
return grbuild
|
||||
@@ -366,56 +366,56 @@ func (lq *LabelQuery) GroupBy(field string, fields ...string) *LabelGroupBy {
|
||||
// client.Label.Query().
|
||||
// Select(label.FieldCreatedAt).
|
||||
// Scan(ctx, &v)
|
||||
func (lq *LabelQuery) Select(fields ...string) *LabelSelect {
|
||||
lq.ctx.Fields = append(lq.ctx.Fields, fields...)
|
||||
sbuild := &LabelSelect{LabelQuery: lq}
|
||||
func (_q *LabelQuery) Select(fields ...string) *LabelSelect {
|
||||
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
||||
sbuild := &LabelSelect{LabelQuery: _q}
|
||||
sbuild.label = label.Label
|
||||
sbuild.flds, sbuild.scan = &lq.ctx.Fields, sbuild.Scan
|
||||
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
|
||||
return sbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a LabelSelect configured with the given aggregations.
|
||||
func (lq *LabelQuery) Aggregate(fns ...AggregateFunc) *LabelSelect {
|
||||
return lq.Select().Aggregate(fns...)
|
||||
func (_q *LabelQuery) Aggregate(fns ...AggregateFunc) *LabelSelect {
|
||||
return _q.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (lq *LabelQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range lq.inters {
|
||||
func (_q *LabelQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range _q.inters {
|
||||
if inter == nil {
|
||||
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
|
||||
}
|
||||
if trv, ok := inter.(Traverser); ok {
|
||||
if err := trv.Traverse(ctx, lq); err != nil {
|
||||
if err := trv.Traverse(ctx, _q); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, f := range lq.ctx.Fields {
|
||||
for _, f := range _q.ctx.Fields {
|
||||
if !label.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
}
|
||||
if lq.path != nil {
|
||||
prev, err := lq.path(ctx)
|
||||
if _q.path != nil {
|
||||
prev, err := _q.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
lq.sql = prev
|
||||
_q.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (lq *LabelQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Label, error) {
|
||||
func (_q *LabelQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Label, error) {
|
||||
var (
|
||||
nodes = []*Label{}
|
||||
withFKs = lq.withFKs
|
||||
_spec = lq.querySpec()
|
||||
withFKs = _q.withFKs
|
||||
_spec = _q.querySpec()
|
||||
loadedTypes = [2]bool{
|
||||
lq.withGroup != nil,
|
||||
lq.withEntities != nil,
|
||||
_q.withGroup != nil,
|
||||
_q.withEntities != nil,
|
||||
}
|
||||
)
|
||||
if lq.withGroup != nil {
|
||||
if _q.withGroup != nil {
|
||||
withFKs = true
|
||||
}
|
||||
if withFKs {
|
||||
@@ -425,7 +425,7 @@ func (lq *LabelQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Label,
|
||||
return (*Label).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &Label{config: lq.config}
|
||||
node := &Label{config: _q.config}
|
||||
nodes = append(nodes, node)
|
||||
node.Edges.loadedTypes = loadedTypes
|
||||
return node.assignValues(columns, values)
|
||||
@@ -433,20 +433,20 @@ func (lq *LabelQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Label,
|
||||
for i := range hooks {
|
||||
hooks[i](ctx, _spec)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, lq.driver, _spec); err != nil {
|
||||
if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
if query := lq.withGroup; query != nil {
|
||||
if err := lq.loadGroup(ctx, query, nodes, nil,
|
||||
if query := _q.withGroup; query != nil {
|
||||
if err := _q.loadGroup(ctx, query, nodes, nil,
|
||||
func(n *Label, e *Group) { n.Edges.Group = e }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if query := lq.withEntities; query != nil {
|
||||
if err := lq.loadEntities(ctx, query, nodes,
|
||||
if query := _q.withEntities; query != nil {
|
||||
if err := _q.loadEntities(ctx, query, nodes,
|
||||
func(n *Label) { n.Edges.Entities = []*Entity{} },
|
||||
func(n *Label, e *Entity) { n.Edges.Entities = append(n.Edges.Entities, e) }); err != nil {
|
||||
return nil, err
|
||||
@@ -455,7 +455,7 @@ func (lq *LabelQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Label,
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (lq *LabelQuery) loadGroup(ctx context.Context, query *GroupQuery, nodes []*Label, init func(*Label), assign func(*Label, *Group)) error {
|
||||
func (_q *LabelQuery) loadGroup(ctx context.Context, query *GroupQuery, nodes []*Label, init func(*Label), assign func(*Label, *Group)) error {
|
||||
ids := make([]uuid.UUID, 0, len(nodes))
|
||||
nodeids := make(map[uuid.UUID][]*Label)
|
||||
for i := range nodes {
|
||||
@@ -487,7 +487,7 @@ func (lq *LabelQuery) loadGroup(ctx context.Context, query *GroupQuery, nodes []
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (lq *LabelQuery) loadEntities(ctx context.Context, query *EntityQuery, nodes []*Label, init func(*Label), assign func(*Label, *Entity)) error {
|
||||
func (_q *LabelQuery) loadEntities(ctx context.Context, query *EntityQuery, nodes []*Label, init func(*Label), assign func(*Label, *Entity)) error {
|
||||
edgeIDs := make([]driver.Value, len(nodes))
|
||||
byID := make(map[uuid.UUID]*Label)
|
||||
nids := make(map[uuid.UUID]map[*Label]struct{})
|
||||
@@ -549,24 +549,24 @@ func (lq *LabelQuery) loadEntities(ctx context.Context, query *EntityQuery, node
|
||||
return nil
|
||||
}
|
||||
|
||||
func (lq *LabelQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := lq.querySpec()
|
||||
_spec.Node.Columns = lq.ctx.Fields
|
||||
if len(lq.ctx.Fields) > 0 {
|
||||
_spec.Unique = lq.ctx.Unique != nil && *lq.ctx.Unique
|
||||
func (_q *LabelQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := _q.querySpec()
|
||||
_spec.Node.Columns = _q.ctx.Fields
|
||||
if len(_q.ctx.Fields) > 0 {
|
||||
_spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, lq.driver, _spec)
|
||||
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
|
||||
}
|
||||
|
||||
func (lq *LabelQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
func (_q *LabelQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := sqlgraph.NewQuerySpec(label.Table, label.Columns, sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID))
|
||||
_spec.From = lq.sql
|
||||
if unique := lq.ctx.Unique; unique != nil {
|
||||
_spec.From = _q.sql
|
||||
if unique := _q.ctx.Unique; unique != nil {
|
||||
_spec.Unique = *unique
|
||||
} else if lq.path != nil {
|
||||
} else if _q.path != nil {
|
||||
_spec.Unique = true
|
||||
}
|
||||
if fields := lq.ctx.Fields; len(fields) > 0 {
|
||||
if fields := _q.ctx.Fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, label.FieldID)
|
||||
for i := range fields {
|
||||
@@ -575,20 +575,20 @@ func (lq *LabelQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := lq.predicates; len(ps) > 0 {
|
||||
if ps := _q.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := lq.ctx.Limit; limit != nil {
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := lq.ctx.Offset; offset != nil {
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := lq.order; len(ps) > 0 {
|
||||
if ps := _q.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
@@ -598,33 +598,33 @@ func (lq *LabelQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (lq *LabelQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(lq.driver.Dialect())
|
||||
func (_q *LabelQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(_q.driver.Dialect())
|
||||
t1 := builder.Table(label.Table)
|
||||
columns := lq.ctx.Fields
|
||||
columns := _q.ctx.Fields
|
||||
if len(columns) == 0 {
|
||||
columns = label.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if lq.sql != nil {
|
||||
selector = lq.sql
|
||||
if _q.sql != nil {
|
||||
selector = _q.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
if lq.ctx.Unique != nil && *lq.ctx.Unique {
|
||||
if _q.ctx.Unique != nil && *_q.ctx.Unique {
|
||||
selector.Distinct()
|
||||
}
|
||||
for _, p := range lq.predicates {
|
||||
for _, p := range _q.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range lq.order {
|
||||
for _, p := range _q.order {
|
||||
p(selector)
|
||||
}
|
||||
if offset := lq.ctx.Offset; offset != nil {
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
// limit is mandatory for offset clause. We start
|
||||
// with default value, and override it below if needed.
|
||||
selector.Offset(*offset).Limit(math.MaxInt32)
|
||||
}
|
||||
if limit := lq.ctx.Limit; limit != nil {
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
@@ -637,41 +637,41 @@ type LabelGroupBy struct {
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (lgb *LabelGroupBy) Aggregate(fns ...AggregateFunc) *LabelGroupBy {
|
||||
lgb.fns = append(lgb.fns, fns...)
|
||||
return lgb
|
||||
func (_g *LabelGroupBy) Aggregate(fns ...AggregateFunc) *LabelGroupBy {
|
||||
_g.fns = append(_g.fns, fns...)
|
||||
return _g
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (lgb *LabelGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, lgb.build.ctx, ent.OpQueryGroupBy)
|
||||
if err := lgb.build.prepareQuery(ctx); err != nil {
|
||||
func (_g *LabelGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
|
||||
if err := _g.build.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*LabelQuery, *LabelGroupBy](ctx, lgb.build, lgb, lgb.build.inters, v)
|
||||
return scanWithInterceptors[*LabelQuery, *LabelGroupBy](ctx, _g.build, _g, _g.build.inters, v)
|
||||
}
|
||||
|
||||
func (lgb *LabelGroupBy) sqlScan(ctx context.Context, root *LabelQuery, v any) error {
|
||||
func (_g *LabelGroupBy) sqlScan(ctx context.Context, root *LabelQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx).Select()
|
||||
aggregation := make([]string, 0, len(lgb.fns))
|
||||
for _, fn := range lgb.fns {
|
||||
aggregation := make([]string, 0, len(_g.fns))
|
||||
for _, fn := range _g.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(*lgb.flds)+len(lgb.fns))
|
||||
for _, f := range *lgb.flds {
|
||||
columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
|
||||
for _, f := range *_g.flds {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
columns = append(columns, aggregation...)
|
||||
selector.Select(columns...)
|
||||
}
|
||||
selector.GroupBy(selector.Columns(*lgb.flds...)...)
|
||||
selector.GroupBy(selector.Columns(*_g.flds...)...)
|
||||
if err := selector.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := lgb.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
@@ -685,27 +685,27 @@ type LabelSelect struct {
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (ls *LabelSelect) Aggregate(fns ...AggregateFunc) *LabelSelect {
|
||||
ls.fns = append(ls.fns, fns...)
|
||||
return ls
|
||||
func (_s *LabelSelect) Aggregate(fns ...AggregateFunc) *LabelSelect {
|
||||
_s.fns = append(_s.fns, fns...)
|
||||
return _s
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (ls *LabelSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, ls.ctx, ent.OpQuerySelect)
|
||||
if err := ls.prepareQuery(ctx); err != nil {
|
||||
func (_s *LabelSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
|
||||
if err := _s.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*LabelQuery, *LabelSelect](ctx, ls.LabelQuery, ls, ls.inters, v)
|
||||
return scanWithInterceptors[*LabelQuery, *LabelSelect](ctx, _s.LabelQuery, _s, _s.inters, v)
|
||||
}
|
||||
|
||||
func (ls *LabelSelect) sqlScan(ctx context.Context, root *LabelQuery, v any) error {
|
||||
func (_s *LabelSelect) sqlScan(ctx context.Context, root *LabelQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx)
|
||||
aggregation := make([]string, 0, len(ls.fns))
|
||||
for _, fn := range ls.fns {
|
||||
aggregation := make([]string, 0, len(_s.fns))
|
||||
for _, fn := range _s.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
switch n := len(*ls.selector.flds); {
|
||||
switch n := len(*_s.selector.flds); {
|
||||
case n == 0 && len(aggregation) > 0:
|
||||
selector.Select(aggregation...)
|
||||
case n != 0 && len(aggregation) > 0:
|
||||
@@ -713,7 +713,7 @@ func (ls *LabelSelect) sqlScan(ctx context.Context, root *LabelQuery, v any) err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := ls.driver.Query(ctx, query, args, rows); err != nil {
|
||||
if err := _s.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
@@ -26,138 +26,138 @@ type LabelUpdate struct {
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the LabelUpdate builder.
|
||||
func (lu *LabelUpdate) Where(ps ...predicate.Label) *LabelUpdate {
|
||||
lu.mutation.Where(ps...)
|
||||
return lu
|
||||
func (_u *LabelUpdate) Where(ps ...predicate.Label) *LabelUpdate {
|
||||
_u.mutation.Where(ps...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (lu *LabelUpdate) SetUpdatedAt(t time.Time) *LabelUpdate {
|
||||
lu.mutation.SetUpdatedAt(t)
|
||||
return lu
|
||||
func (_u *LabelUpdate) SetUpdatedAt(v time.Time) *LabelUpdate {
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (lu *LabelUpdate) SetName(s string) *LabelUpdate {
|
||||
lu.mutation.SetName(s)
|
||||
return lu
|
||||
func (_u *LabelUpdate) SetName(v string) *LabelUpdate {
|
||||
_u.mutation.SetName(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableName sets the "name" field if the given value is not nil.
|
||||
func (lu *LabelUpdate) SetNillableName(s *string) *LabelUpdate {
|
||||
if s != nil {
|
||||
lu.SetName(*s)
|
||||
func (_u *LabelUpdate) SetNillableName(v *string) *LabelUpdate {
|
||||
if v != nil {
|
||||
_u.SetName(*v)
|
||||
}
|
||||
return lu
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetDescription sets the "description" field.
|
||||
func (lu *LabelUpdate) SetDescription(s string) *LabelUpdate {
|
||||
lu.mutation.SetDescription(s)
|
||||
return lu
|
||||
func (_u *LabelUpdate) SetDescription(v string) *LabelUpdate {
|
||||
_u.mutation.SetDescription(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableDescription sets the "description" field if the given value is not nil.
|
||||
func (lu *LabelUpdate) SetNillableDescription(s *string) *LabelUpdate {
|
||||
if s != nil {
|
||||
lu.SetDescription(*s)
|
||||
func (_u *LabelUpdate) SetNillableDescription(v *string) *LabelUpdate {
|
||||
if v != nil {
|
||||
_u.SetDescription(*v)
|
||||
}
|
||||
return lu
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearDescription clears the value of the "description" field.
|
||||
func (lu *LabelUpdate) ClearDescription() *LabelUpdate {
|
||||
lu.mutation.ClearDescription()
|
||||
return lu
|
||||
func (_u *LabelUpdate) ClearDescription() *LabelUpdate {
|
||||
_u.mutation.ClearDescription()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetColor sets the "color" field.
|
||||
func (lu *LabelUpdate) SetColor(s string) *LabelUpdate {
|
||||
lu.mutation.SetColor(s)
|
||||
return lu
|
||||
func (_u *LabelUpdate) SetColor(v string) *LabelUpdate {
|
||||
_u.mutation.SetColor(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableColor sets the "color" field if the given value is not nil.
|
||||
func (lu *LabelUpdate) SetNillableColor(s *string) *LabelUpdate {
|
||||
if s != nil {
|
||||
lu.SetColor(*s)
|
||||
func (_u *LabelUpdate) SetNillableColor(v *string) *LabelUpdate {
|
||||
if v != nil {
|
||||
_u.SetColor(*v)
|
||||
}
|
||||
return lu
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearColor clears the value of the "color" field.
|
||||
func (lu *LabelUpdate) ClearColor() *LabelUpdate {
|
||||
lu.mutation.ClearColor()
|
||||
return lu
|
||||
func (_u *LabelUpdate) ClearColor() *LabelUpdate {
|
||||
_u.mutation.ClearColor()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetGroupID sets the "group" edge to the Group entity by ID.
|
||||
func (lu *LabelUpdate) SetGroupID(id uuid.UUID) *LabelUpdate {
|
||||
lu.mutation.SetGroupID(id)
|
||||
return lu
|
||||
func (_u *LabelUpdate) SetGroupID(id uuid.UUID) *LabelUpdate {
|
||||
_u.mutation.SetGroupID(id)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetGroup sets the "group" edge to the Group entity.
|
||||
func (lu *LabelUpdate) SetGroup(g *Group) *LabelUpdate {
|
||||
return lu.SetGroupID(g.ID)
|
||||
func (_u *LabelUpdate) SetGroup(v *Group) *LabelUpdate {
|
||||
return _u.SetGroupID(v.ID)
|
||||
}
|
||||
|
||||
// AddEntityIDs adds the "entities" edge to the Entity entity by IDs.
|
||||
func (lu *LabelUpdate) AddEntityIDs(ids ...uuid.UUID) *LabelUpdate {
|
||||
lu.mutation.AddEntityIDs(ids...)
|
||||
return lu
|
||||
func (_u *LabelUpdate) AddEntityIDs(ids ...uuid.UUID) *LabelUpdate {
|
||||
_u.mutation.AddEntityIDs(ids...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddEntities adds the "entities" edges to the Entity entity.
|
||||
func (lu *LabelUpdate) AddEntities(e ...*Entity) *LabelUpdate {
|
||||
ids := make([]uuid.UUID, len(e))
|
||||
for i := range e {
|
||||
ids[i] = e[i].ID
|
||||
func (_u *LabelUpdate) AddEntities(v ...*Entity) *LabelUpdate {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return lu.AddEntityIDs(ids...)
|
||||
return _u.AddEntityIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the LabelMutation object of the builder.
|
||||
func (lu *LabelUpdate) Mutation() *LabelMutation {
|
||||
return lu.mutation
|
||||
func (_u *LabelUpdate) Mutation() *LabelMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// ClearGroup clears the "group" edge to the Group entity.
|
||||
func (lu *LabelUpdate) ClearGroup() *LabelUpdate {
|
||||
lu.mutation.ClearGroup()
|
||||
return lu
|
||||
func (_u *LabelUpdate) ClearGroup() *LabelUpdate {
|
||||
_u.mutation.ClearGroup()
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearEntities clears all "entities" edges to the Entity entity.
|
||||
func (lu *LabelUpdate) ClearEntities() *LabelUpdate {
|
||||
lu.mutation.ClearEntities()
|
||||
return lu
|
||||
func (_u *LabelUpdate) ClearEntities() *LabelUpdate {
|
||||
_u.mutation.ClearEntities()
|
||||
return _u
|
||||
}
|
||||
|
||||
// RemoveEntityIDs removes the "entities" edge to Entity entities by IDs.
|
||||
func (lu *LabelUpdate) RemoveEntityIDs(ids ...uuid.UUID) *LabelUpdate {
|
||||
lu.mutation.RemoveEntityIDs(ids...)
|
||||
return lu
|
||||
func (_u *LabelUpdate) RemoveEntityIDs(ids ...uuid.UUID) *LabelUpdate {
|
||||
_u.mutation.RemoveEntityIDs(ids...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// RemoveEntities removes "entities" edges to Entity entities.
|
||||
func (lu *LabelUpdate) RemoveEntities(e ...*Entity) *LabelUpdate {
|
||||
ids := make([]uuid.UUID, len(e))
|
||||
for i := range e {
|
||||
ids[i] = e[i].ID
|
||||
func (_u *LabelUpdate) RemoveEntities(v ...*Entity) *LabelUpdate {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return lu.RemoveEntityIDs(ids...)
|
||||
return _u.RemoveEntityIDs(ids...)
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (lu *LabelUpdate) Save(ctx context.Context) (int, error) {
|
||||
lu.defaults()
|
||||
return withHooks(ctx, lu.sqlSave, lu.mutation, lu.hooks)
|
||||
func (_u *LabelUpdate) Save(ctx context.Context) (int, error) {
|
||||
_u.defaults()
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (lu *LabelUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := lu.Save(ctx)
|
||||
func (_u *LabelUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -165,80 +165,80 @@ func (lu *LabelUpdate) SaveX(ctx context.Context) int {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (lu *LabelUpdate) Exec(ctx context.Context) error {
|
||||
_, err := lu.Save(ctx)
|
||||
func (_u *LabelUpdate) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (lu *LabelUpdate) ExecX(ctx context.Context) {
|
||||
if err := lu.Exec(ctx); err != nil {
|
||||
func (_u *LabelUpdate) ExecX(ctx context.Context) {
|
||||
if err := _u.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (lu *LabelUpdate) defaults() {
|
||||
if _, ok := lu.mutation.UpdatedAt(); !ok {
|
||||
func (_u *LabelUpdate) defaults() {
|
||||
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
||||
v := label.UpdateDefaultUpdatedAt()
|
||||
lu.mutation.SetUpdatedAt(v)
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (lu *LabelUpdate) check() error {
|
||||
if v, ok := lu.mutation.Name(); ok {
|
||||
func (_u *LabelUpdate) check() error {
|
||||
if v, ok := _u.mutation.Name(); ok {
|
||||
if err := label.NameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Label.name": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := lu.mutation.Description(); ok {
|
||||
if v, ok := _u.mutation.Description(); ok {
|
||||
if err := label.DescriptionValidator(v); err != nil {
|
||||
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Label.description": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := lu.mutation.Color(); ok {
|
||||
if v, ok := _u.mutation.Color(); ok {
|
||||
if err := label.ColorValidator(v); err != nil {
|
||||
return &ValidationError{Name: "color", err: fmt.Errorf(`ent: validator failed for field "Label.color": %w`, err)}
|
||||
}
|
||||
}
|
||||
if lu.mutation.GroupCleared() && len(lu.mutation.GroupIDs()) > 0 {
|
||||
if _u.mutation.GroupCleared() && len(_u.mutation.GroupIDs()) > 0 {
|
||||
return errors.New(`ent: clearing a required unique edge "Label.group"`)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (lu *LabelUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
if err := lu.check(); err != nil {
|
||||
return n, err
|
||||
func (_u *LabelUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
if err := _u.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(label.Table, label.Columns, sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID))
|
||||
if ps := lu.mutation.predicates; len(ps) > 0 {
|
||||
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := lu.mutation.UpdatedAt(); ok {
|
||||
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(label.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := lu.mutation.Name(); ok {
|
||||
if value, ok := _u.mutation.Name(); ok {
|
||||
_spec.SetField(label.FieldName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := lu.mutation.Description(); ok {
|
||||
if value, ok := _u.mutation.Description(); ok {
|
||||
_spec.SetField(label.FieldDescription, field.TypeString, value)
|
||||
}
|
||||
if lu.mutation.DescriptionCleared() {
|
||||
if _u.mutation.DescriptionCleared() {
|
||||
_spec.ClearField(label.FieldDescription, field.TypeString)
|
||||
}
|
||||
if value, ok := lu.mutation.Color(); ok {
|
||||
if value, ok := _u.mutation.Color(); ok {
|
||||
_spec.SetField(label.FieldColor, field.TypeString, value)
|
||||
}
|
||||
if lu.mutation.ColorCleared() {
|
||||
if _u.mutation.ColorCleared() {
|
||||
_spec.ClearField(label.FieldColor, field.TypeString)
|
||||
}
|
||||
if lu.mutation.GroupCleared() {
|
||||
if _u.mutation.GroupCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -251,7 +251,7 @@ func (lu *LabelUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := lu.mutation.GroupIDs(); len(nodes) > 0 {
|
||||
if nodes := _u.mutation.GroupIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -267,7 +267,7 @@ func (lu *LabelUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if lu.mutation.EntitiesCleared() {
|
||||
if _u.mutation.EntitiesCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2M,
|
||||
Inverse: false,
|
||||
@@ -280,7 +280,7 @@ func (lu *LabelUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := lu.mutation.RemovedEntitiesIDs(); len(nodes) > 0 && !lu.mutation.EntitiesCleared() {
|
||||
if nodes := _u.mutation.RemovedEntitiesIDs(); len(nodes) > 0 && !_u.mutation.EntitiesCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2M,
|
||||
Inverse: false,
|
||||
@@ -296,7 +296,7 @@ func (lu *LabelUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := lu.mutation.EntitiesIDs(); len(nodes) > 0 {
|
||||
if nodes := _u.mutation.EntitiesIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2M,
|
||||
Inverse: false,
|
||||
@@ -312,7 +312,7 @@ func (lu *LabelUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, lu.driver, _spec); err != nil {
|
||||
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{label.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
@@ -320,8 +320,8 @@ func (lu *LabelUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
lu.mutation.done = true
|
||||
return n, nil
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
// LabelUpdateOne is the builder for updating a single Label entity.
|
||||
@@ -333,145 +333,145 @@ type LabelUpdateOne struct {
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (luo *LabelUpdateOne) SetUpdatedAt(t time.Time) *LabelUpdateOne {
|
||||
luo.mutation.SetUpdatedAt(t)
|
||||
return luo
|
||||
func (_u *LabelUpdateOne) SetUpdatedAt(v time.Time) *LabelUpdateOne {
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (luo *LabelUpdateOne) SetName(s string) *LabelUpdateOne {
|
||||
luo.mutation.SetName(s)
|
||||
return luo
|
||||
func (_u *LabelUpdateOne) SetName(v string) *LabelUpdateOne {
|
||||
_u.mutation.SetName(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableName sets the "name" field if the given value is not nil.
|
||||
func (luo *LabelUpdateOne) SetNillableName(s *string) *LabelUpdateOne {
|
||||
if s != nil {
|
||||
luo.SetName(*s)
|
||||
func (_u *LabelUpdateOne) SetNillableName(v *string) *LabelUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetName(*v)
|
||||
}
|
||||
return luo
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetDescription sets the "description" field.
|
||||
func (luo *LabelUpdateOne) SetDescription(s string) *LabelUpdateOne {
|
||||
luo.mutation.SetDescription(s)
|
||||
return luo
|
||||
func (_u *LabelUpdateOne) SetDescription(v string) *LabelUpdateOne {
|
||||
_u.mutation.SetDescription(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableDescription sets the "description" field if the given value is not nil.
|
||||
func (luo *LabelUpdateOne) SetNillableDescription(s *string) *LabelUpdateOne {
|
||||
if s != nil {
|
||||
luo.SetDescription(*s)
|
||||
func (_u *LabelUpdateOne) SetNillableDescription(v *string) *LabelUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetDescription(*v)
|
||||
}
|
||||
return luo
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearDescription clears the value of the "description" field.
|
||||
func (luo *LabelUpdateOne) ClearDescription() *LabelUpdateOne {
|
||||
luo.mutation.ClearDescription()
|
||||
return luo
|
||||
func (_u *LabelUpdateOne) ClearDescription() *LabelUpdateOne {
|
||||
_u.mutation.ClearDescription()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetColor sets the "color" field.
|
||||
func (luo *LabelUpdateOne) SetColor(s string) *LabelUpdateOne {
|
||||
luo.mutation.SetColor(s)
|
||||
return luo
|
||||
func (_u *LabelUpdateOne) SetColor(v string) *LabelUpdateOne {
|
||||
_u.mutation.SetColor(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableColor sets the "color" field if the given value is not nil.
|
||||
func (luo *LabelUpdateOne) SetNillableColor(s *string) *LabelUpdateOne {
|
||||
if s != nil {
|
||||
luo.SetColor(*s)
|
||||
func (_u *LabelUpdateOne) SetNillableColor(v *string) *LabelUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetColor(*v)
|
||||
}
|
||||
return luo
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearColor clears the value of the "color" field.
|
||||
func (luo *LabelUpdateOne) ClearColor() *LabelUpdateOne {
|
||||
luo.mutation.ClearColor()
|
||||
return luo
|
||||
func (_u *LabelUpdateOne) ClearColor() *LabelUpdateOne {
|
||||
_u.mutation.ClearColor()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetGroupID sets the "group" edge to the Group entity by ID.
|
||||
func (luo *LabelUpdateOne) SetGroupID(id uuid.UUID) *LabelUpdateOne {
|
||||
luo.mutation.SetGroupID(id)
|
||||
return luo
|
||||
func (_u *LabelUpdateOne) SetGroupID(id uuid.UUID) *LabelUpdateOne {
|
||||
_u.mutation.SetGroupID(id)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetGroup sets the "group" edge to the Group entity.
|
||||
func (luo *LabelUpdateOne) SetGroup(g *Group) *LabelUpdateOne {
|
||||
return luo.SetGroupID(g.ID)
|
||||
func (_u *LabelUpdateOne) SetGroup(v *Group) *LabelUpdateOne {
|
||||
return _u.SetGroupID(v.ID)
|
||||
}
|
||||
|
||||
// AddEntityIDs adds the "entities" edge to the Entity entity by IDs.
|
||||
func (luo *LabelUpdateOne) AddEntityIDs(ids ...uuid.UUID) *LabelUpdateOne {
|
||||
luo.mutation.AddEntityIDs(ids...)
|
||||
return luo
|
||||
func (_u *LabelUpdateOne) AddEntityIDs(ids ...uuid.UUID) *LabelUpdateOne {
|
||||
_u.mutation.AddEntityIDs(ids...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddEntities adds the "entities" edges to the Entity entity.
|
||||
func (luo *LabelUpdateOne) AddEntities(e ...*Entity) *LabelUpdateOne {
|
||||
ids := make([]uuid.UUID, len(e))
|
||||
for i := range e {
|
||||
ids[i] = e[i].ID
|
||||
func (_u *LabelUpdateOne) AddEntities(v ...*Entity) *LabelUpdateOne {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return luo.AddEntityIDs(ids...)
|
||||
return _u.AddEntityIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the LabelMutation object of the builder.
|
||||
func (luo *LabelUpdateOne) Mutation() *LabelMutation {
|
||||
return luo.mutation
|
||||
func (_u *LabelUpdateOne) Mutation() *LabelMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// ClearGroup clears the "group" edge to the Group entity.
|
||||
func (luo *LabelUpdateOne) ClearGroup() *LabelUpdateOne {
|
||||
luo.mutation.ClearGroup()
|
||||
return luo
|
||||
func (_u *LabelUpdateOne) ClearGroup() *LabelUpdateOne {
|
||||
_u.mutation.ClearGroup()
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearEntities clears all "entities" edges to the Entity entity.
|
||||
func (luo *LabelUpdateOne) ClearEntities() *LabelUpdateOne {
|
||||
luo.mutation.ClearEntities()
|
||||
return luo
|
||||
func (_u *LabelUpdateOne) ClearEntities() *LabelUpdateOne {
|
||||
_u.mutation.ClearEntities()
|
||||
return _u
|
||||
}
|
||||
|
||||
// RemoveEntityIDs removes the "entities" edge to Entity entities by IDs.
|
||||
func (luo *LabelUpdateOne) RemoveEntityIDs(ids ...uuid.UUID) *LabelUpdateOne {
|
||||
luo.mutation.RemoveEntityIDs(ids...)
|
||||
return luo
|
||||
func (_u *LabelUpdateOne) RemoveEntityIDs(ids ...uuid.UUID) *LabelUpdateOne {
|
||||
_u.mutation.RemoveEntityIDs(ids...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// RemoveEntities removes "entities" edges to Entity entities.
|
||||
func (luo *LabelUpdateOne) RemoveEntities(e ...*Entity) *LabelUpdateOne {
|
||||
ids := make([]uuid.UUID, len(e))
|
||||
for i := range e {
|
||||
ids[i] = e[i].ID
|
||||
func (_u *LabelUpdateOne) RemoveEntities(v ...*Entity) *LabelUpdateOne {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return luo.RemoveEntityIDs(ids...)
|
||||
return _u.RemoveEntityIDs(ids...)
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the LabelUpdate builder.
|
||||
func (luo *LabelUpdateOne) Where(ps ...predicate.Label) *LabelUpdateOne {
|
||||
luo.mutation.Where(ps...)
|
||||
return luo
|
||||
func (_u *LabelUpdateOne) Where(ps ...predicate.Label) *LabelUpdateOne {
|
||||
_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 (luo *LabelUpdateOne) Select(field string, fields ...string) *LabelUpdateOne {
|
||||
luo.fields = append([]string{field}, fields...)
|
||||
return luo
|
||||
func (_u *LabelUpdateOne) Select(field string, fields ...string) *LabelUpdateOne {
|
||||
_u.fields = append([]string{field}, fields...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated Label entity.
|
||||
func (luo *LabelUpdateOne) Save(ctx context.Context) (*Label, error) {
|
||||
luo.defaults()
|
||||
return withHooks(ctx, luo.sqlSave, luo.mutation, luo.hooks)
|
||||
func (_u *LabelUpdateOne) Save(ctx context.Context) (*Label, error) {
|
||||
_u.defaults()
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (luo *LabelUpdateOne) SaveX(ctx context.Context) *Label {
|
||||
node, err := luo.Save(ctx)
|
||||
func (_u *LabelUpdateOne) SaveX(ctx context.Context) *Label {
|
||||
node, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -479,60 +479,60 @@ func (luo *LabelUpdateOne) SaveX(ctx context.Context) *Label {
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (luo *LabelUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := luo.Save(ctx)
|
||||
func (_u *LabelUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (luo *LabelUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := luo.Exec(ctx); err != nil {
|
||||
func (_u *LabelUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := _u.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (luo *LabelUpdateOne) defaults() {
|
||||
if _, ok := luo.mutation.UpdatedAt(); !ok {
|
||||
func (_u *LabelUpdateOne) defaults() {
|
||||
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
||||
v := label.UpdateDefaultUpdatedAt()
|
||||
luo.mutation.SetUpdatedAt(v)
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (luo *LabelUpdateOne) check() error {
|
||||
if v, ok := luo.mutation.Name(); ok {
|
||||
func (_u *LabelUpdateOne) check() error {
|
||||
if v, ok := _u.mutation.Name(); ok {
|
||||
if err := label.NameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Label.name": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := luo.mutation.Description(); ok {
|
||||
if v, ok := _u.mutation.Description(); ok {
|
||||
if err := label.DescriptionValidator(v); err != nil {
|
||||
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Label.description": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := luo.mutation.Color(); ok {
|
||||
if v, ok := _u.mutation.Color(); ok {
|
||||
if err := label.ColorValidator(v); err != nil {
|
||||
return &ValidationError{Name: "color", err: fmt.Errorf(`ent: validator failed for field "Label.color": %w`, err)}
|
||||
}
|
||||
}
|
||||
if luo.mutation.GroupCleared() && len(luo.mutation.GroupIDs()) > 0 {
|
||||
if _u.mutation.GroupCleared() && len(_u.mutation.GroupIDs()) > 0 {
|
||||
return errors.New(`ent: clearing a required unique edge "Label.group"`)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (luo *LabelUpdateOne) sqlSave(ctx context.Context) (_node *Label, err error) {
|
||||
if err := luo.check(); err != nil {
|
||||
func (_u *LabelUpdateOne) sqlSave(ctx context.Context) (_node *Label, err error) {
|
||||
if err := _u.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(label.Table, label.Columns, sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID))
|
||||
id, ok := luo.mutation.ID()
|
||||
id, ok := _u.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Label.id" for update`)}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
if fields := luo.fields; len(fields) > 0 {
|
||||
if fields := _u.fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, label.FieldID)
|
||||
for _, f := range fields {
|
||||
@@ -544,32 +544,32 @@ func (luo *LabelUpdateOne) sqlSave(ctx context.Context) (_node *Label, err error
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := luo.mutation.predicates; len(ps) > 0 {
|
||||
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := luo.mutation.UpdatedAt(); ok {
|
||||
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(label.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := luo.mutation.Name(); ok {
|
||||
if value, ok := _u.mutation.Name(); ok {
|
||||
_spec.SetField(label.FieldName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := luo.mutation.Description(); ok {
|
||||
if value, ok := _u.mutation.Description(); ok {
|
||||
_spec.SetField(label.FieldDescription, field.TypeString, value)
|
||||
}
|
||||
if luo.mutation.DescriptionCleared() {
|
||||
if _u.mutation.DescriptionCleared() {
|
||||
_spec.ClearField(label.FieldDescription, field.TypeString)
|
||||
}
|
||||
if value, ok := luo.mutation.Color(); ok {
|
||||
if value, ok := _u.mutation.Color(); ok {
|
||||
_spec.SetField(label.FieldColor, field.TypeString, value)
|
||||
}
|
||||
if luo.mutation.ColorCleared() {
|
||||
if _u.mutation.ColorCleared() {
|
||||
_spec.ClearField(label.FieldColor, field.TypeString)
|
||||
}
|
||||
if luo.mutation.GroupCleared() {
|
||||
if _u.mutation.GroupCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -582,7 +582,7 @@ func (luo *LabelUpdateOne) sqlSave(ctx context.Context) (_node *Label, err error
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := luo.mutation.GroupIDs(); len(nodes) > 0 {
|
||||
if nodes := _u.mutation.GroupIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -598,7 +598,7 @@ func (luo *LabelUpdateOne) sqlSave(ctx context.Context) (_node *Label, err error
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if luo.mutation.EntitiesCleared() {
|
||||
if _u.mutation.EntitiesCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2M,
|
||||
Inverse: false,
|
||||
@@ -611,7 +611,7 @@ func (luo *LabelUpdateOne) sqlSave(ctx context.Context) (_node *Label, err error
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := luo.mutation.RemovedEntitiesIDs(); len(nodes) > 0 && !luo.mutation.EntitiesCleared() {
|
||||
if nodes := _u.mutation.RemovedEntitiesIDs(); len(nodes) > 0 && !_u.mutation.EntitiesCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2M,
|
||||
Inverse: false,
|
||||
@@ -627,7 +627,7 @@ func (luo *LabelUpdateOne) sqlSave(ctx context.Context) (_node *Label, err error
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := luo.mutation.EntitiesIDs(); len(nodes) > 0 {
|
||||
if nodes := _u.mutation.EntitiesIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2M,
|
||||
Inverse: false,
|
||||
@@ -643,10 +643,10 @@ func (luo *LabelUpdateOne) sqlSave(ctx context.Context) (_node *Label, err error
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
_node = &Label{config: luo.config}
|
||||
_node = &Label{config: _u.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
if err = sqlgraph.UpdateNode(ctx, luo.driver, _spec); err != nil {
|
||||
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{label.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
@@ -654,6 +654,6 @@ func (luo *LabelUpdateOne) sqlSave(ctx context.Context) (_node *Label, err error
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
luo.mutation.done = true
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ func (*MaintenanceEntry) scanValues(columns []string) ([]any, error) {
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the MaintenanceEntry fields.
|
||||
func (me *MaintenanceEntry) assignValues(columns []string, values []any) error {
|
||||
func (_m *MaintenanceEntry) assignValues(columns []string, values []any) error {
|
||||
if m, n := len(values), len(columns); m < n {
|
||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||
}
|
||||
@@ -93,58 +93,58 @@ func (me *MaintenanceEntry) assignValues(columns []string, values []any) error {
|
||||
if value, ok := values[i].(*uuid.UUID); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", values[i])
|
||||
} else if value != nil {
|
||||
me.ID = *value
|
||||
_m.ID = *value
|
||||
}
|
||||
case maintenanceentry.FieldCreatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
||||
} else if value.Valid {
|
||||
me.CreatedAt = value.Time
|
||||
_m.CreatedAt = value.Time
|
||||
}
|
||||
case maintenanceentry.FieldUpdatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
|
||||
} else if value.Valid {
|
||||
me.UpdatedAt = value.Time
|
||||
_m.UpdatedAt = value.Time
|
||||
}
|
||||
case maintenanceentry.FieldEntityID:
|
||||
if value, ok := values[i].(*uuid.UUID); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field entity_id", values[i])
|
||||
} else if value != nil {
|
||||
me.EntityID = *value
|
||||
_m.EntityID = *value
|
||||
}
|
||||
case maintenanceentry.FieldDate:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field date", values[i])
|
||||
} else if value.Valid {
|
||||
me.Date = value.Time
|
||||
_m.Date = value.Time
|
||||
}
|
||||
case maintenanceentry.FieldScheduledDate:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field scheduled_date", values[i])
|
||||
} else if value.Valid {
|
||||
me.ScheduledDate = value.Time
|
||||
_m.ScheduledDate = value.Time
|
||||
}
|
||||
case maintenanceentry.FieldName:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field name", values[i])
|
||||
} else if value.Valid {
|
||||
me.Name = value.String
|
||||
_m.Name = value.String
|
||||
}
|
||||
case maintenanceentry.FieldDescription:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field description", values[i])
|
||||
} else if value.Valid {
|
||||
me.Description = value.String
|
||||
_m.Description = value.String
|
||||
}
|
||||
case maintenanceentry.FieldCost:
|
||||
if value, ok := values[i].(*sql.NullFloat64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field cost", values[i])
|
||||
} else if value.Valid {
|
||||
me.Cost = value.Float64
|
||||
_m.Cost = value.Float64
|
||||
}
|
||||
default:
|
||||
me.selectValues.Set(columns[i], values[i])
|
||||
_m.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -152,61 +152,61 @@ func (me *MaintenanceEntry) assignValues(columns []string, values []any) error {
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the MaintenanceEntry.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (me *MaintenanceEntry) Value(name string) (ent.Value, error) {
|
||||
return me.selectValues.Get(name)
|
||||
func (_m *MaintenanceEntry) Value(name string) (ent.Value, error) {
|
||||
return _m.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// QueryEntity queries the "entity" edge of the MaintenanceEntry entity.
|
||||
func (me *MaintenanceEntry) QueryEntity() *EntityQuery {
|
||||
return NewMaintenanceEntryClient(me.config).QueryEntity(me)
|
||||
func (_m *MaintenanceEntry) QueryEntity() *EntityQuery {
|
||||
return NewMaintenanceEntryClient(_m.config).QueryEntity(_m)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this MaintenanceEntry.
|
||||
// Note that you need to call MaintenanceEntry.Unwrap() before calling this method if this MaintenanceEntry
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (me *MaintenanceEntry) Update() *MaintenanceEntryUpdateOne {
|
||||
return NewMaintenanceEntryClient(me.config).UpdateOne(me)
|
||||
func (_m *MaintenanceEntry) Update() *MaintenanceEntryUpdateOne {
|
||||
return NewMaintenanceEntryClient(_m.config).UpdateOne(_m)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the MaintenanceEntry entity that was returned from a transaction after it was closed,
|
||||
// so that all future queries will be executed through the driver which created the transaction.
|
||||
func (me *MaintenanceEntry) Unwrap() *MaintenanceEntry {
|
||||
_tx, ok := me.config.driver.(*txDriver)
|
||||
func (_m *MaintenanceEntry) Unwrap() *MaintenanceEntry {
|
||||
_tx, ok := _m.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: MaintenanceEntry is not a transactional entity")
|
||||
}
|
||||
me.config.driver = _tx.drv
|
||||
return me
|
||||
_m.config.driver = _tx.drv
|
||||
return _m
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (me *MaintenanceEntry) String() string {
|
||||
func (_m *MaintenanceEntry) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("MaintenanceEntry(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", me.ID))
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||||
builder.WriteString("created_at=")
|
||||
builder.WriteString(me.CreatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("updated_at=")
|
||||
builder.WriteString(me.UpdatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("entity_id=")
|
||||
builder.WriteString(fmt.Sprintf("%v", me.EntityID))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.EntityID))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("date=")
|
||||
builder.WriteString(me.Date.Format(time.ANSIC))
|
||||
builder.WriteString(_m.Date.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("scheduled_date=")
|
||||
builder.WriteString(me.ScheduledDate.Format(time.ANSIC))
|
||||
builder.WriteString(_m.ScheduledDate.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("name=")
|
||||
builder.WriteString(me.Name)
|
||||
builder.WriteString(_m.Name)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("description=")
|
||||
builder.WriteString(me.Description)
|
||||
builder.WriteString(_m.Description)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("cost=")
|
||||
builder.WriteString(fmt.Sprintf("%v", me.Cost))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Cost))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
@@ -23,134 +23,134 @@ type MaintenanceEntryCreate struct {
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (mec *MaintenanceEntryCreate) SetCreatedAt(t time.Time) *MaintenanceEntryCreate {
|
||||
mec.mutation.SetCreatedAt(t)
|
||||
return mec
|
||||
func (_c *MaintenanceEntryCreate) SetCreatedAt(v time.Time) *MaintenanceEntryCreate {
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||
func (mec *MaintenanceEntryCreate) SetNillableCreatedAt(t *time.Time) *MaintenanceEntryCreate {
|
||||
if t != nil {
|
||||
mec.SetCreatedAt(*t)
|
||||
func (_c *MaintenanceEntryCreate) SetNillableCreatedAt(v *time.Time) *MaintenanceEntryCreate {
|
||||
if v != nil {
|
||||
_c.SetCreatedAt(*v)
|
||||
}
|
||||
return mec
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (mec *MaintenanceEntryCreate) SetUpdatedAt(t time.Time) *MaintenanceEntryCreate {
|
||||
mec.mutation.SetUpdatedAt(t)
|
||||
return mec
|
||||
func (_c *MaintenanceEntryCreate) SetUpdatedAt(v time.Time) *MaintenanceEntryCreate {
|
||||
_c.mutation.SetUpdatedAt(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
||||
func (mec *MaintenanceEntryCreate) SetNillableUpdatedAt(t *time.Time) *MaintenanceEntryCreate {
|
||||
if t != nil {
|
||||
mec.SetUpdatedAt(*t)
|
||||
func (_c *MaintenanceEntryCreate) SetNillableUpdatedAt(v *time.Time) *MaintenanceEntryCreate {
|
||||
if v != nil {
|
||||
_c.SetUpdatedAt(*v)
|
||||
}
|
||||
return mec
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetEntityID sets the "entity_id" field.
|
||||
func (mec *MaintenanceEntryCreate) SetEntityID(u uuid.UUID) *MaintenanceEntryCreate {
|
||||
mec.mutation.SetEntityID(u)
|
||||
return mec
|
||||
func (_c *MaintenanceEntryCreate) SetEntityID(v uuid.UUID) *MaintenanceEntryCreate {
|
||||
_c.mutation.SetEntityID(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetDate sets the "date" field.
|
||||
func (mec *MaintenanceEntryCreate) SetDate(t time.Time) *MaintenanceEntryCreate {
|
||||
mec.mutation.SetDate(t)
|
||||
return mec
|
||||
func (_c *MaintenanceEntryCreate) SetDate(v time.Time) *MaintenanceEntryCreate {
|
||||
_c.mutation.SetDate(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableDate sets the "date" field if the given value is not nil.
|
||||
func (mec *MaintenanceEntryCreate) SetNillableDate(t *time.Time) *MaintenanceEntryCreate {
|
||||
if t != nil {
|
||||
mec.SetDate(*t)
|
||||
func (_c *MaintenanceEntryCreate) SetNillableDate(v *time.Time) *MaintenanceEntryCreate {
|
||||
if v != nil {
|
||||
_c.SetDate(*v)
|
||||
}
|
||||
return mec
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetScheduledDate sets the "scheduled_date" field.
|
||||
func (mec *MaintenanceEntryCreate) SetScheduledDate(t time.Time) *MaintenanceEntryCreate {
|
||||
mec.mutation.SetScheduledDate(t)
|
||||
return mec
|
||||
func (_c *MaintenanceEntryCreate) SetScheduledDate(v time.Time) *MaintenanceEntryCreate {
|
||||
_c.mutation.SetScheduledDate(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableScheduledDate sets the "scheduled_date" field if the given value is not nil.
|
||||
func (mec *MaintenanceEntryCreate) SetNillableScheduledDate(t *time.Time) *MaintenanceEntryCreate {
|
||||
if t != nil {
|
||||
mec.SetScheduledDate(*t)
|
||||
func (_c *MaintenanceEntryCreate) SetNillableScheduledDate(v *time.Time) *MaintenanceEntryCreate {
|
||||
if v != nil {
|
||||
_c.SetScheduledDate(*v)
|
||||
}
|
||||
return mec
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (mec *MaintenanceEntryCreate) SetName(s string) *MaintenanceEntryCreate {
|
||||
mec.mutation.SetName(s)
|
||||
return mec
|
||||
func (_c *MaintenanceEntryCreate) SetName(v string) *MaintenanceEntryCreate {
|
||||
_c.mutation.SetName(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetDescription sets the "description" field.
|
||||
func (mec *MaintenanceEntryCreate) SetDescription(s string) *MaintenanceEntryCreate {
|
||||
mec.mutation.SetDescription(s)
|
||||
return mec
|
||||
func (_c *MaintenanceEntryCreate) SetDescription(v string) *MaintenanceEntryCreate {
|
||||
_c.mutation.SetDescription(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableDescription sets the "description" field if the given value is not nil.
|
||||
func (mec *MaintenanceEntryCreate) SetNillableDescription(s *string) *MaintenanceEntryCreate {
|
||||
if s != nil {
|
||||
mec.SetDescription(*s)
|
||||
func (_c *MaintenanceEntryCreate) SetNillableDescription(v *string) *MaintenanceEntryCreate {
|
||||
if v != nil {
|
||||
_c.SetDescription(*v)
|
||||
}
|
||||
return mec
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetCost sets the "cost" field.
|
||||
func (mec *MaintenanceEntryCreate) SetCost(f float64) *MaintenanceEntryCreate {
|
||||
mec.mutation.SetCost(f)
|
||||
return mec
|
||||
func (_c *MaintenanceEntryCreate) SetCost(v float64) *MaintenanceEntryCreate {
|
||||
_c.mutation.SetCost(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableCost sets the "cost" field if the given value is not nil.
|
||||
func (mec *MaintenanceEntryCreate) SetNillableCost(f *float64) *MaintenanceEntryCreate {
|
||||
if f != nil {
|
||||
mec.SetCost(*f)
|
||||
func (_c *MaintenanceEntryCreate) SetNillableCost(v *float64) *MaintenanceEntryCreate {
|
||||
if v != nil {
|
||||
_c.SetCost(*v)
|
||||
}
|
||||
return mec
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetID sets the "id" field.
|
||||
func (mec *MaintenanceEntryCreate) SetID(u uuid.UUID) *MaintenanceEntryCreate {
|
||||
mec.mutation.SetID(u)
|
||||
return mec
|
||||
func (_c *MaintenanceEntryCreate) SetID(v uuid.UUID) *MaintenanceEntryCreate {
|
||||
_c.mutation.SetID(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableID sets the "id" field if the given value is not nil.
|
||||
func (mec *MaintenanceEntryCreate) SetNillableID(u *uuid.UUID) *MaintenanceEntryCreate {
|
||||
if u != nil {
|
||||
mec.SetID(*u)
|
||||
func (_c *MaintenanceEntryCreate) SetNillableID(v *uuid.UUID) *MaintenanceEntryCreate {
|
||||
if v != nil {
|
||||
_c.SetID(*v)
|
||||
}
|
||||
return mec
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetEntity sets the "entity" edge to the Entity entity.
|
||||
func (mec *MaintenanceEntryCreate) SetEntity(e *Entity) *MaintenanceEntryCreate {
|
||||
return mec.SetEntityID(e.ID)
|
||||
func (_c *MaintenanceEntryCreate) SetEntity(v *Entity) *MaintenanceEntryCreate {
|
||||
return _c.SetEntityID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the MaintenanceEntryMutation object of the builder.
|
||||
func (mec *MaintenanceEntryCreate) Mutation() *MaintenanceEntryMutation {
|
||||
return mec.mutation
|
||||
func (_c *MaintenanceEntryCreate) Mutation() *MaintenanceEntryMutation {
|
||||
return _c.mutation
|
||||
}
|
||||
|
||||
// Save creates the MaintenanceEntry in the database.
|
||||
func (mec *MaintenanceEntryCreate) Save(ctx context.Context) (*MaintenanceEntry, error) {
|
||||
mec.defaults()
|
||||
return withHooks(ctx, mec.sqlSave, mec.mutation, mec.hooks)
|
||||
func (_c *MaintenanceEntryCreate) Save(ctx context.Context) (*MaintenanceEntry, error) {
|
||||
_c.defaults()
|
||||
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (mec *MaintenanceEntryCreate) SaveX(ctx context.Context) *MaintenanceEntry {
|
||||
v, err := mec.Save(ctx)
|
||||
func (_c *MaintenanceEntryCreate) SaveX(ctx context.Context) *MaintenanceEntry {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -158,77 +158,77 @@ func (mec *MaintenanceEntryCreate) SaveX(ctx context.Context) *MaintenanceEntry
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (mec *MaintenanceEntryCreate) Exec(ctx context.Context) error {
|
||||
_, err := mec.Save(ctx)
|
||||
func (_c *MaintenanceEntryCreate) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (mec *MaintenanceEntryCreate) ExecX(ctx context.Context) {
|
||||
if err := mec.Exec(ctx); err != nil {
|
||||
func (_c *MaintenanceEntryCreate) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (mec *MaintenanceEntryCreate) defaults() {
|
||||
if _, ok := mec.mutation.CreatedAt(); !ok {
|
||||
func (_c *MaintenanceEntryCreate) defaults() {
|
||||
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||
v := maintenanceentry.DefaultCreatedAt()
|
||||
mec.mutation.SetCreatedAt(v)
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
}
|
||||
if _, ok := mec.mutation.UpdatedAt(); !ok {
|
||||
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
||||
v := maintenanceentry.DefaultUpdatedAt()
|
||||
mec.mutation.SetUpdatedAt(v)
|
||||
_c.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
if _, ok := mec.mutation.Cost(); !ok {
|
||||
if _, ok := _c.mutation.Cost(); !ok {
|
||||
v := maintenanceentry.DefaultCost
|
||||
mec.mutation.SetCost(v)
|
||||
_c.mutation.SetCost(v)
|
||||
}
|
||||
if _, ok := mec.mutation.ID(); !ok {
|
||||
if _, ok := _c.mutation.ID(); !ok {
|
||||
v := maintenanceentry.DefaultID()
|
||||
mec.mutation.SetID(v)
|
||||
_c.mutation.SetID(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (mec *MaintenanceEntryCreate) check() error {
|
||||
if _, ok := mec.mutation.CreatedAt(); !ok {
|
||||
func (_c *MaintenanceEntryCreate) check() error {
|
||||
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "MaintenanceEntry.created_at"`)}
|
||||
}
|
||||
if _, ok := mec.mutation.UpdatedAt(); !ok {
|
||||
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
||||
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "MaintenanceEntry.updated_at"`)}
|
||||
}
|
||||
if _, ok := mec.mutation.EntityID(); !ok {
|
||||
if _, ok := _c.mutation.EntityID(); !ok {
|
||||
return &ValidationError{Name: "entity_id", err: errors.New(`ent: missing required field "MaintenanceEntry.entity_id"`)}
|
||||
}
|
||||
if _, ok := mec.mutation.Name(); !ok {
|
||||
if _, ok := _c.mutation.Name(); !ok {
|
||||
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "MaintenanceEntry.name"`)}
|
||||
}
|
||||
if v, ok := mec.mutation.Name(); ok {
|
||||
if v, ok := _c.mutation.Name(); ok {
|
||||
if err := maintenanceentry.NameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "MaintenanceEntry.name": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := mec.mutation.Description(); ok {
|
||||
if v, ok := _c.mutation.Description(); ok {
|
||||
if err := maintenanceentry.DescriptionValidator(v); err != nil {
|
||||
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "MaintenanceEntry.description": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := mec.mutation.Cost(); !ok {
|
||||
if _, ok := _c.mutation.Cost(); !ok {
|
||||
return &ValidationError{Name: "cost", err: errors.New(`ent: missing required field "MaintenanceEntry.cost"`)}
|
||||
}
|
||||
if len(mec.mutation.EntityIDs()) == 0 {
|
||||
if len(_c.mutation.EntityIDs()) == 0 {
|
||||
return &ValidationError{Name: "entity", err: errors.New(`ent: missing required edge "MaintenanceEntry.entity"`)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (mec *MaintenanceEntryCreate) sqlSave(ctx context.Context) (*MaintenanceEntry, error) {
|
||||
if err := mec.check(); err != nil {
|
||||
func (_c *MaintenanceEntryCreate) sqlSave(ctx context.Context) (*MaintenanceEntry, error) {
|
||||
if err := _c.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_node, _spec := mec.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, mec.driver, _spec); err != nil {
|
||||
_node, _spec := _c.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
@@ -241,49 +241,49 @@ func (mec *MaintenanceEntryCreate) sqlSave(ctx context.Context) (*MaintenanceEnt
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
mec.mutation.id = &_node.ID
|
||||
mec.mutation.done = true
|
||||
_c.mutation.id = &_node.ID
|
||||
_c.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
func (mec *MaintenanceEntryCreate) createSpec() (*MaintenanceEntry, *sqlgraph.CreateSpec) {
|
||||
func (_c *MaintenanceEntryCreate) createSpec() (*MaintenanceEntry, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &MaintenanceEntry{config: mec.config}
|
||||
_node = &MaintenanceEntry{config: _c.config}
|
||||
_spec = sqlgraph.NewCreateSpec(maintenanceentry.Table, sqlgraph.NewFieldSpec(maintenanceentry.FieldID, field.TypeUUID))
|
||||
)
|
||||
if id, ok := mec.mutation.ID(); ok {
|
||||
if id, ok := _c.mutation.ID(); ok {
|
||||
_node.ID = id
|
||||
_spec.ID.Value = &id
|
||||
}
|
||||
if value, ok := mec.mutation.CreatedAt(); ok {
|
||||
if value, ok := _c.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(maintenanceentry.FieldCreatedAt, field.TypeTime, value)
|
||||
_node.CreatedAt = value
|
||||
}
|
||||
if value, ok := mec.mutation.UpdatedAt(); ok {
|
||||
if value, ok := _c.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(maintenanceentry.FieldUpdatedAt, field.TypeTime, value)
|
||||
_node.UpdatedAt = value
|
||||
}
|
||||
if value, ok := mec.mutation.Date(); ok {
|
||||
if value, ok := _c.mutation.Date(); ok {
|
||||
_spec.SetField(maintenanceentry.FieldDate, field.TypeTime, value)
|
||||
_node.Date = value
|
||||
}
|
||||
if value, ok := mec.mutation.ScheduledDate(); ok {
|
||||
if value, ok := _c.mutation.ScheduledDate(); ok {
|
||||
_spec.SetField(maintenanceentry.FieldScheduledDate, field.TypeTime, value)
|
||||
_node.ScheduledDate = value
|
||||
}
|
||||
if value, ok := mec.mutation.Name(); ok {
|
||||
if value, ok := _c.mutation.Name(); ok {
|
||||
_spec.SetField(maintenanceentry.FieldName, field.TypeString, value)
|
||||
_node.Name = value
|
||||
}
|
||||
if value, ok := mec.mutation.Description(); ok {
|
||||
if value, ok := _c.mutation.Description(); ok {
|
||||
_spec.SetField(maintenanceentry.FieldDescription, field.TypeString, value)
|
||||
_node.Description = value
|
||||
}
|
||||
if value, ok := mec.mutation.Cost(); ok {
|
||||
if value, ok := _c.mutation.Cost(); ok {
|
||||
_spec.SetField(maintenanceentry.FieldCost, field.TypeFloat64, value)
|
||||
_node.Cost = value
|
||||
}
|
||||
if nodes := mec.mutation.EntityIDs(); len(nodes) > 0 {
|
||||
if nodes := _c.mutation.EntityIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -311,16 +311,16 @@ type MaintenanceEntryCreateBulk struct {
|
||||
}
|
||||
|
||||
// Save creates the MaintenanceEntry entities in the database.
|
||||
func (mecb *MaintenanceEntryCreateBulk) Save(ctx context.Context) ([]*MaintenanceEntry, error) {
|
||||
if mecb.err != nil {
|
||||
return nil, mecb.err
|
||||
func (_c *MaintenanceEntryCreateBulk) Save(ctx context.Context) ([]*MaintenanceEntry, error) {
|
||||
if _c.err != nil {
|
||||
return nil, _c.err
|
||||
}
|
||||
specs := make([]*sqlgraph.CreateSpec, len(mecb.builders))
|
||||
nodes := make([]*MaintenanceEntry, len(mecb.builders))
|
||||
mutators := make([]Mutator, len(mecb.builders))
|
||||
for i := range mecb.builders {
|
||||
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
||||
nodes := make([]*MaintenanceEntry, len(_c.builders))
|
||||
mutators := make([]Mutator, len(_c.builders))
|
||||
for i := range _c.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := mecb.builders[i]
|
||||
builder := _c.builders[i]
|
||||
builder.defaults()
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*MaintenanceEntryMutation)
|
||||
@@ -334,11 +334,11 @@ func (mecb *MaintenanceEntryCreateBulk) Save(ctx context.Context) ([]*Maintenanc
|
||||
var err error
|
||||
nodes[i], specs[i] = builder.createSpec()
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, mecb.builders[i+1].mutation)
|
||||
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
|
||||
} else {
|
||||
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
||||
// Invoke the actual operation on the latest mutation in the chain.
|
||||
if err = sqlgraph.BatchCreate(ctx, mecb.driver, spec); err != nil {
|
||||
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
@@ -358,7 +358,7 @@ func (mecb *MaintenanceEntryCreateBulk) Save(ctx context.Context) ([]*Maintenanc
|
||||
}(i, ctx)
|
||||
}
|
||||
if len(mutators) > 0 {
|
||||
if _, err := mutators[0].Mutate(ctx, mecb.builders[0].mutation); err != nil {
|
||||
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
@@ -366,8 +366,8 @@ func (mecb *MaintenanceEntryCreateBulk) Save(ctx context.Context) ([]*Maintenanc
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (mecb *MaintenanceEntryCreateBulk) SaveX(ctx context.Context) []*MaintenanceEntry {
|
||||
v, err := mecb.Save(ctx)
|
||||
func (_c *MaintenanceEntryCreateBulk) SaveX(ctx context.Context) []*MaintenanceEntry {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -375,14 +375,14 @@ func (mecb *MaintenanceEntryCreateBulk) SaveX(ctx context.Context) []*Maintenanc
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (mecb *MaintenanceEntryCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := mecb.Save(ctx)
|
||||
func (_c *MaintenanceEntryCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (mecb *MaintenanceEntryCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := mecb.Exec(ctx); err != nil {
|
||||
func (_c *MaintenanceEntryCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,56 +20,56 @@ type MaintenanceEntryDelete struct {
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the MaintenanceEntryDelete builder.
|
||||
func (med *MaintenanceEntryDelete) Where(ps ...predicate.MaintenanceEntry) *MaintenanceEntryDelete {
|
||||
med.mutation.Where(ps...)
|
||||
return med
|
||||
func (_d *MaintenanceEntryDelete) Where(ps ...predicate.MaintenanceEntry) *MaintenanceEntryDelete {
|
||||
_d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (med *MaintenanceEntryDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, med.sqlExec, med.mutation, med.hooks)
|
||||
func (_d *MaintenanceEntryDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (med *MaintenanceEntryDelete) ExecX(ctx context.Context) int {
|
||||
n, err := med.Exec(ctx)
|
||||
func (_d *MaintenanceEntryDelete) ExecX(ctx context.Context) int {
|
||||
n, err := _d.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (med *MaintenanceEntryDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
func (_d *MaintenanceEntryDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := sqlgraph.NewDeleteSpec(maintenanceentry.Table, sqlgraph.NewFieldSpec(maintenanceentry.FieldID, field.TypeUUID))
|
||||
if ps := med.mutation.predicates; len(ps) > 0 {
|
||||
if ps := _d.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, med.driver, _spec)
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec)
|
||||
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
med.mutation.done = true
|
||||
_d.mutation.done = true
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// MaintenanceEntryDeleteOne is the builder for deleting a single MaintenanceEntry entity.
|
||||
type MaintenanceEntryDeleteOne struct {
|
||||
med *MaintenanceEntryDelete
|
||||
_d *MaintenanceEntryDelete
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the MaintenanceEntryDelete builder.
|
||||
func (medo *MaintenanceEntryDeleteOne) Where(ps ...predicate.MaintenanceEntry) *MaintenanceEntryDeleteOne {
|
||||
medo.med.mutation.Where(ps...)
|
||||
return medo
|
||||
func (_d *MaintenanceEntryDeleteOne) Where(ps ...predicate.MaintenanceEntry) *MaintenanceEntryDeleteOne {
|
||||
_d._d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (medo *MaintenanceEntryDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := medo.med.Exec(ctx)
|
||||
func (_d *MaintenanceEntryDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := _d._d.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
@@ -81,8 +81,8 @@ func (medo *MaintenanceEntryDeleteOne) Exec(ctx context.Context) error {
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (medo *MaintenanceEntryDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := medo.Exec(ctx); err != nil {
|
||||
func (_d *MaintenanceEntryDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := _d.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,44 +31,44 @@ type MaintenanceEntryQuery struct {
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the MaintenanceEntryQuery builder.
|
||||
func (meq *MaintenanceEntryQuery) Where(ps ...predicate.MaintenanceEntry) *MaintenanceEntryQuery {
|
||||
meq.predicates = append(meq.predicates, ps...)
|
||||
return meq
|
||||
func (_q *MaintenanceEntryQuery) Where(ps ...predicate.MaintenanceEntry) *MaintenanceEntryQuery {
|
||||
_q.predicates = append(_q.predicates, ps...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// Limit the number of records to be returned by this query.
|
||||
func (meq *MaintenanceEntryQuery) Limit(limit int) *MaintenanceEntryQuery {
|
||||
meq.ctx.Limit = &limit
|
||||
return meq
|
||||
func (_q *MaintenanceEntryQuery) Limit(limit int) *MaintenanceEntryQuery {
|
||||
_q.ctx.Limit = &limit
|
||||
return _q
|
||||
}
|
||||
|
||||
// Offset to start from.
|
||||
func (meq *MaintenanceEntryQuery) Offset(offset int) *MaintenanceEntryQuery {
|
||||
meq.ctx.Offset = &offset
|
||||
return meq
|
||||
func (_q *MaintenanceEntryQuery) Offset(offset int) *MaintenanceEntryQuery {
|
||||
_q.ctx.Offset = &offset
|
||||
return _q
|
||||
}
|
||||
|
||||
// Unique configures the query builder to filter duplicate records on query.
|
||||
// By default, unique is set to true, and can be disabled using this method.
|
||||
func (meq *MaintenanceEntryQuery) Unique(unique bool) *MaintenanceEntryQuery {
|
||||
meq.ctx.Unique = &unique
|
||||
return meq
|
||||
func (_q *MaintenanceEntryQuery) Unique(unique bool) *MaintenanceEntryQuery {
|
||||
_q.ctx.Unique = &unique
|
||||
return _q
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (meq *MaintenanceEntryQuery) Order(o ...maintenanceentry.OrderOption) *MaintenanceEntryQuery {
|
||||
meq.order = append(meq.order, o...)
|
||||
return meq
|
||||
func (_q *MaintenanceEntryQuery) Order(o ...maintenanceentry.OrderOption) *MaintenanceEntryQuery {
|
||||
_q.order = append(_q.order, o...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// QueryEntity chains the current query on the "entity" edge.
|
||||
func (meq *MaintenanceEntryQuery) QueryEntity() *EntityQuery {
|
||||
query := (&EntityClient{config: meq.config}).Query()
|
||||
func (_q *MaintenanceEntryQuery) QueryEntity() *EntityQuery {
|
||||
query := (&EntityClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := meq.prepareQuery(ctx); err != nil {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := meq.sqlQuery(ctx)
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -77,7 +77,7 @@ func (meq *MaintenanceEntryQuery) QueryEntity() *EntityQuery {
|
||||
sqlgraph.To(entity.Table, entity.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, maintenanceentry.EntityTable, maintenanceentry.EntityColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(meq.driver.Dialect(), step)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
@@ -85,8 +85,8 @@ func (meq *MaintenanceEntryQuery) QueryEntity() *EntityQuery {
|
||||
|
||||
// First returns the first MaintenanceEntry entity from the query.
|
||||
// Returns a *NotFoundError when no MaintenanceEntry was found.
|
||||
func (meq *MaintenanceEntryQuery) First(ctx context.Context) (*MaintenanceEntry, error) {
|
||||
nodes, err := meq.Limit(1).All(setContextOp(ctx, meq.ctx, ent.OpQueryFirst))
|
||||
func (_q *MaintenanceEntryQuery) First(ctx context.Context) (*MaintenanceEntry, error) {
|
||||
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -97,8 +97,8 @@ func (meq *MaintenanceEntryQuery) First(ctx context.Context) (*MaintenanceEntry,
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (meq *MaintenanceEntryQuery) FirstX(ctx context.Context) *MaintenanceEntry {
|
||||
node, err := meq.First(ctx)
|
||||
func (_q *MaintenanceEntryQuery) FirstX(ctx context.Context) *MaintenanceEntry {
|
||||
node, err := _q.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
@@ -107,9 +107,9 @@ func (meq *MaintenanceEntryQuery) FirstX(ctx context.Context) *MaintenanceEntry
|
||||
|
||||
// FirstID returns the first MaintenanceEntry ID from the query.
|
||||
// Returns a *NotFoundError when no MaintenanceEntry ID was found.
|
||||
func (meq *MaintenanceEntryQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
func (_q *MaintenanceEntryQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
var ids []uuid.UUID
|
||||
if ids, err = meq.Limit(1).IDs(setContextOp(ctx, meq.ctx, ent.OpQueryFirstID)); err != nil {
|
||||
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
@@ -120,8 +120,8 @@ func (meq *MaintenanceEntryQuery) FirstID(ctx context.Context) (id uuid.UUID, er
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (meq *MaintenanceEntryQuery) FirstIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := meq.FirstID(ctx)
|
||||
func (_q *MaintenanceEntryQuery) FirstIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := _q.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
@@ -131,8 +131,8 @@ func (meq *MaintenanceEntryQuery) FirstIDX(ctx context.Context) uuid.UUID {
|
||||
// Only returns a single MaintenanceEntry entity found by the query, ensuring it only returns one.
|
||||
// Returns a *NotSingularError when more than one MaintenanceEntry entity is found.
|
||||
// Returns a *NotFoundError when no MaintenanceEntry entities are found.
|
||||
func (meq *MaintenanceEntryQuery) Only(ctx context.Context) (*MaintenanceEntry, error) {
|
||||
nodes, err := meq.Limit(2).All(setContextOp(ctx, meq.ctx, ent.OpQueryOnly))
|
||||
func (_q *MaintenanceEntryQuery) Only(ctx context.Context) (*MaintenanceEntry, error) {
|
||||
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -147,8 +147,8 @@ func (meq *MaintenanceEntryQuery) Only(ctx context.Context) (*MaintenanceEntry,
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (meq *MaintenanceEntryQuery) OnlyX(ctx context.Context) *MaintenanceEntry {
|
||||
node, err := meq.Only(ctx)
|
||||
func (_q *MaintenanceEntryQuery) OnlyX(ctx context.Context) *MaintenanceEntry {
|
||||
node, err := _q.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -158,9 +158,9 @@ func (meq *MaintenanceEntryQuery) OnlyX(ctx context.Context) *MaintenanceEntry {
|
||||
// OnlyID is like Only, but returns the only MaintenanceEntry ID in the query.
|
||||
// Returns a *NotSingularError when more than one MaintenanceEntry ID is found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (meq *MaintenanceEntryQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
func (_q *MaintenanceEntryQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
var ids []uuid.UUID
|
||||
if ids, err = meq.Limit(2).IDs(setContextOp(ctx, meq.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
@@ -175,8 +175,8 @@ func (meq *MaintenanceEntryQuery) OnlyID(ctx context.Context) (id uuid.UUID, err
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (meq *MaintenanceEntryQuery) OnlyIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := meq.OnlyID(ctx)
|
||||
func (_q *MaintenanceEntryQuery) OnlyIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := _q.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -184,18 +184,18 @@ func (meq *MaintenanceEntryQuery) OnlyIDX(ctx context.Context) uuid.UUID {
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of MaintenanceEntries.
|
||||
func (meq *MaintenanceEntryQuery) All(ctx context.Context) ([]*MaintenanceEntry, error) {
|
||||
ctx = setContextOp(ctx, meq.ctx, ent.OpQueryAll)
|
||||
if err := meq.prepareQuery(ctx); err != nil {
|
||||
func (_q *MaintenanceEntryQuery) All(ctx context.Context) ([]*MaintenanceEntry, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qr := querierAll[[]*MaintenanceEntry, *MaintenanceEntryQuery]()
|
||||
return withInterceptors[[]*MaintenanceEntry](ctx, meq, qr, meq.inters)
|
||||
return withInterceptors[[]*MaintenanceEntry](ctx, _q, qr, _q.inters)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (meq *MaintenanceEntryQuery) AllX(ctx context.Context) []*MaintenanceEntry {
|
||||
nodes, err := meq.All(ctx)
|
||||
func (_q *MaintenanceEntryQuery) AllX(ctx context.Context) []*MaintenanceEntry {
|
||||
nodes, err := _q.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -203,20 +203,20 @@ func (meq *MaintenanceEntryQuery) AllX(ctx context.Context) []*MaintenanceEntry
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of MaintenanceEntry IDs.
|
||||
func (meq *MaintenanceEntryQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
|
||||
if meq.ctx.Unique == nil && meq.path != nil {
|
||||
meq.Unique(true)
|
||||
func (_q *MaintenanceEntryQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
|
||||
if _q.ctx.Unique == nil && _q.path != nil {
|
||||
_q.Unique(true)
|
||||
}
|
||||
ctx = setContextOp(ctx, meq.ctx, ent.OpQueryIDs)
|
||||
if err = meq.Select(maintenanceentry.FieldID).Scan(ctx, &ids); err != nil {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
|
||||
if err = _q.Select(maintenanceentry.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (meq *MaintenanceEntryQuery) IDsX(ctx context.Context) []uuid.UUID {
|
||||
ids, err := meq.IDs(ctx)
|
||||
func (_q *MaintenanceEntryQuery) IDsX(ctx context.Context) []uuid.UUID {
|
||||
ids, err := _q.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -224,17 +224,17 @@ func (meq *MaintenanceEntryQuery) IDsX(ctx context.Context) []uuid.UUID {
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (meq *MaintenanceEntryQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, meq.ctx, ent.OpQueryCount)
|
||||
if err := meq.prepareQuery(ctx); err != nil {
|
||||
func (_q *MaintenanceEntryQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return withInterceptors[int](ctx, meq, querierCount[*MaintenanceEntryQuery](), meq.inters)
|
||||
return withInterceptors[int](ctx, _q, querierCount[*MaintenanceEntryQuery](), _q.inters)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (meq *MaintenanceEntryQuery) CountX(ctx context.Context) int {
|
||||
count, err := meq.Count(ctx)
|
||||
func (_q *MaintenanceEntryQuery) CountX(ctx context.Context) int {
|
||||
count, err := _q.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -242,9 +242,9 @@ func (meq *MaintenanceEntryQuery) CountX(ctx context.Context) int {
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (meq *MaintenanceEntryQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, meq.ctx, ent.OpQueryExist)
|
||||
switch _, err := meq.FirstID(ctx); {
|
||||
func (_q *MaintenanceEntryQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
|
||||
switch _, err := _q.FirstID(ctx); {
|
||||
case IsNotFound(err):
|
||||
return false, nil
|
||||
case err != nil:
|
||||
@@ -255,8 +255,8 @@ func (meq *MaintenanceEntryQuery) Exist(ctx context.Context) (bool, error) {
|
||||
}
|
||||
|
||||
// ExistX is like Exist, but panics if an error occurs.
|
||||
func (meq *MaintenanceEntryQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := meq.Exist(ctx)
|
||||
func (_q *MaintenanceEntryQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := _q.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -265,32 +265,32 @@ func (meq *MaintenanceEntryQuery) ExistX(ctx context.Context) bool {
|
||||
|
||||
// Clone returns a duplicate of the MaintenanceEntryQuery builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (meq *MaintenanceEntryQuery) Clone() *MaintenanceEntryQuery {
|
||||
if meq == nil {
|
||||
func (_q *MaintenanceEntryQuery) Clone() *MaintenanceEntryQuery {
|
||||
if _q == nil {
|
||||
return nil
|
||||
}
|
||||
return &MaintenanceEntryQuery{
|
||||
config: meq.config,
|
||||
ctx: meq.ctx.Clone(),
|
||||
order: append([]maintenanceentry.OrderOption{}, meq.order...),
|
||||
inters: append([]Interceptor{}, meq.inters...),
|
||||
predicates: append([]predicate.MaintenanceEntry{}, meq.predicates...),
|
||||
withEntity: meq.withEntity.Clone(),
|
||||
config: _q.config,
|
||||
ctx: _q.ctx.Clone(),
|
||||
order: append([]maintenanceentry.OrderOption{}, _q.order...),
|
||||
inters: append([]Interceptor{}, _q.inters...),
|
||||
predicates: append([]predicate.MaintenanceEntry{}, _q.predicates...),
|
||||
withEntity: _q.withEntity.Clone(),
|
||||
// clone intermediate query.
|
||||
sql: meq.sql.Clone(),
|
||||
path: meq.path,
|
||||
sql: _q.sql.Clone(),
|
||||
path: _q.path,
|
||||
}
|
||||
}
|
||||
|
||||
// WithEntity tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "entity" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (meq *MaintenanceEntryQuery) WithEntity(opts ...func(*EntityQuery)) *MaintenanceEntryQuery {
|
||||
query := (&EntityClient{config: meq.config}).Query()
|
||||
func (_q *MaintenanceEntryQuery) WithEntity(opts ...func(*EntityQuery)) *MaintenanceEntryQuery {
|
||||
query := (&EntityClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
meq.withEntity = query
|
||||
return meq
|
||||
_q.withEntity = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// GroupBy is used to group vertices by one or more fields/columns.
|
||||
@@ -307,10 +307,10 @@ func (meq *MaintenanceEntryQuery) WithEntity(opts ...func(*EntityQuery)) *Mainte
|
||||
// GroupBy(maintenanceentry.FieldCreatedAt).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (meq *MaintenanceEntryQuery) GroupBy(field string, fields ...string) *MaintenanceEntryGroupBy {
|
||||
meq.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &MaintenanceEntryGroupBy{build: meq}
|
||||
grbuild.flds = &meq.ctx.Fields
|
||||
func (_q *MaintenanceEntryQuery) GroupBy(field string, fields ...string) *MaintenanceEntryGroupBy {
|
||||
_q.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &MaintenanceEntryGroupBy{build: _q}
|
||||
grbuild.flds = &_q.ctx.Fields
|
||||
grbuild.label = maintenanceentry.Label
|
||||
grbuild.scan = grbuild.Scan
|
||||
return grbuild
|
||||
@@ -328,58 +328,58 @@ func (meq *MaintenanceEntryQuery) GroupBy(field string, fields ...string) *Maint
|
||||
// client.MaintenanceEntry.Query().
|
||||
// Select(maintenanceentry.FieldCreatedAt).
|
||||
// Scan(ctx, &v)
|
||||
func (meq *MaintenanceEntryQuery) Select(fields ...string) *MaintenanceEntrySelect {
|
||||
meq.ctx.Fields = append(meq.ctx.Fields, fields...)
|
||||
sbuild := &MaintenanceEntrySelect{MaintenanceEntryQuery: meq}
|
||||
func (_q *MaintenanceEntryQuery) Select(fields ...string) *MaintenanceEntrySelect {
|
||||
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
||||
sbuild := &MaintenanceEntrySelect{MaintenanceEntryQuery: _q}
|
||||
sbuild.label = maintenanceentry.Label
|
||||
sbuild.flds, sbuild.scan = &meq.ctx.Fields, sbuild.Scan
|
||||
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
|
||||
return sbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a MaintenanceEntrySelect configured with the given aggregations.
|
||||
func (meq *MaintenanceEntryQuery) Aggregate(fns ...AggregateFunc) *MaintenanceEntrySelect {
|
||||
return meq.Select().Aggregate(fns...)
|
||||
func (_q *MaintenanceEntryQuery) Aggregate(fns ...AggregateFunc) *MaintenanceEntrySelect {
|
||||
return _q.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (meq *MaintenanceEntryQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range meq.inters {
|
||||
func (_q *MaintenanceEntryQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range _q.inters {
|
||||
if inter == nil {
|
||||
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
|
||||
}
|
||||
if trv, ok := inter.(Traverser); ok {
|
||||
if err := trv.Traverse(ctx, meq); err != nil {
|
||||
if err := trv.Traverse(ctx, _q); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, f := range meq.ctx.Fields {
|
||||
for _, f := range _q.ctx.Fields {
|
||||
if !maintenanceentry.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
}
|
||||
if meq.path != nil {
|
||||
prev, err := meq.path(ctx)
|
||||
if _q.path != nil {
|
||||
prev, err := _q.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
meq.sql = prev
|
||||
_q.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (meq *MaintenanceEntryQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*MaintenanceEntry, error) {
|
||||
func (_q *MaintenanceEntryQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*MaintenanceEntry, error) {
|
||||
var (
|
||||
nodes = []*MaintenanceEntry{}
|
||||
_spec = meq.querySpec()
|
||||
_spec = _q.querySpec()
|
||||
loadedTypes = [1]bool{
|
||||
meq.withEntity != nil,
|
||||
_q.withEntity != nil,
|
||||
}
|
||||
)
|
||||
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||
return (*MaintenanceEntry).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &MaintenanceEntry{config: meq.config}
|
||||
node := &MaintenanceEntry{config: _q.config}
|
||||
nodes = append(nodes, node)
|
||||
node.Edges.loadedTypes = loadedTypes
|
||||
return node.assignValues(columns, values)
|
||||
@@ -387,14 +387,14 @@ func (meq *MaintenanceEntryQuery) sqlAll(ctx context.Context, hooks ...queryHook
|
||||
for i := range hooks {
|
||||
hooks[i](ctx, _spec)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, meq.driver, _spec); err != nil {
|
||||
if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
if query := meq.withEntity; query != nil {
|
||||
if err := meq.loadEntity(ctx, query, nodes, nil,
|
||||
if query := _q.withEntity; query != nil {
|
||||
if err := _q.loadEntity(ctx, query, nodes, nil,
|
||||
func(n *MaintenanceEntry, e *Entity) { n.Edges.Entity = e }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -402,7 +402,7 @@ func (meq *MaintenanceEntryQuery) sqlAll(ctx context.Context, hooks ...queryHook
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (meq *MaintenanceEntryQuery) loadEntity(ctx context.Context, query *EntityQuery, nodes []*MaintenanceEntry, init func(*MaintenanceEntry), assign func(*MaintenanceEntry, *Entity)) error {
|
||||
func (_q *MaintenanceEntryQuery) loadEntity(ctx context.Context, query *EntityQuery, nodes []*MaintenanceEntry, init func(*MaintenanceEntry), assign func(*MaintenanceEntry, *Entity)) error {
|
||||
ids := make([]uuid.UUID, 0, len(nodes))
|
||||
nodeids := make(map[uuid.UUID][]*MaintenanceEntry)
|
||||
for i := range nodes {
|
||||
@@ -432,24 +432,24 @@ func (meq *MaintenanceEntryQuery) loadEntity(ctx context.Context, query *EntityQ
|
||||
return nil
|
||||
}
|
||||
|
||||
func (meq *MaintenanceEntryQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := meq.querySpec()
|
||||
_spec.Node.Columns = meq.ctx.Fields
|
||||
if len(meq.ctx.Fields) > 0 {
|
||||
_spec.Unique = meq.ctx.Unique != nil && *meq.ctx.Unique
|
||||
func (_q *MaintenanceEntryQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := _q.querySpec()
|
||||
_spec.Node.Columns = _q.ctx.Fields
|
||||
if len(_q.ctx.Fields) > 0 {
|
||||
_spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, meq.driver, _spec)
|
||||
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
|
||||
}
|
||||
|
||||
func (meq *MaintenanceEntryQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
func (_q *MaintenanceEntryQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := sqlgraph.NewQuerySpec(maintenanceentry.Table, maintenanceentry.Columns, sqlgraph.NewFieldSpec(maintenanceentry.FieldID, field.TypeUUID))
|
||||
_spec.From = meq.sql
|
||||
if unique := meq.ctx.Unique; unique != nil {
|
||||
_spec.From = _q.sql
|
||||
if unique := _q.ctx.Unique; unique != nil {
|
||||
_spec.Unique = *unique
|
||||
} else if meq.path != nil {
|
||||
} else if _q.path != nil {
|
||||
_spec.Unique = true
|
||||
}
|
||||
if fields := meq.ctx.Fields; len(fields) > 0 {
|
||||
if fields := _q.ctx.Fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, maintenanceentry.FieldID)
|
||||
for i := range fields {
|
||||
@@ -457,24 +457,24 @@ func (meq *MaintenanceEntryQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
|
||||
}
|
||||
}
|
||||
if meq.withEntity != nil {
|
||||
if _q.withEntity != nil {
|
||||
_spec.Node.AddColumnOnce(maintenanceentry.FieldEntityID)
|
||||
}
|
||||
}
|
||||
if ps := meq.predicates; len(ps) > 0 {
|
||||
if ps := _q.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := meq.ctx.Limit; limit != nil {
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := meq.ctx.Offset; offset != nil {
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := meq.order; len(ps) > 0 {
|
||||
if ps := _q.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
@@ -484,33 +484,33 @@ func (meq *MaintenanceEntryQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (meq *MaintenanceEntryQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(meq.driver.Dialect())
|
||||
func (_q *MaintenanceEntryQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(_q.driver.Dialect())
|
||||
t1 := builder.Table(maintenanceentry.Table)
|
||||
columns := meq.ctx.Fields
|
||||
columns := _q.ctx.Fields
|
||||
if len(columns) == 0 {
|
||||
columns = maintenanceentry.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if meq.sql != nil {
|
||||
selector = meq.sql
|
||||
if _q.sql != nil {
|
||||
selector = _q.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
if meq.ctx.Unique != nil && *meq.ctx.Unique {
|
||||
if _q.ctx.Unique != nil && *_q.ctx.Unique {
|
||||
selector.Distinct()
|
||||
}
|
||||
for _, p := range meq.predicates {
|
||||
for _, p := range _q.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range meq.order {
|
||||
for _, p := range _q.order {
|
||||
p(selector)
|
||||
}
|
||||
if offset := meq.ctx.Offset; offset != nil {
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
// limit is mandatory for offset clause. We start
|
||||
// with default value, and override it below if needed.
|
||||
selector.Offset(*offset).Limit(math.MaxInt32)
|
||||
}
|
||||
if limit := meq.ctx.Limit; limit != nil {
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
@@ -523,41 +523,41 @@ type MaintenanceEntryGroupBy struct {
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (megb *MaintenanceEntryGroupBy) Aggregate(fns ...AggregateFunc) *MaintenanceEntryGroupBy {
|
||||
megb.fns = append(megb.fns, fns...)
|
||||
return megb
|
||||
func (_g *MaintenanceEntryGroupBy) Aggregate(fns ...AggregateFunc) *MaintenanceEntryGroupBy {
|
||||
_g.fns = append(_g.fns, fns...)
|
||||
return _g
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (megb *MaintenanceEntryGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, megb.build.ctx, ent.OpQueryGroupBy)
|
||||
if err := megb.build.prepareQuery(ctx); err != nil {
|
||||
func (_g *MaintenanceEntryGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
|
||||
if err := _g.build.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*MaintenanceEntryQuery, *MaintenanceEntryGroupBy](ctx, megb.build, megb, megb.build.inters, v)
|
||||
return scanWithInterceptors[*MaintenanceEntryQuery, *MaintenanceEntryGroupBy](ctx, _g.build, _g, _g.build.inters, v)
|
||||
}
|
||||
|
||||
func (megb *MaintenanceEntryGroupBy) sqlScan(ctx context.Context, root *MaintenanceEntryQuery, v any) error {
|
||||
func (_g *MaintenanceEntryGroupBy) sqlScan(ctx context.Context, root *MaintenanceEntryQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx).Select()
|
||||
aggregation := make([]string, 0, len(megb.fns))
|
||||
for _, fn := range megb.fns {
|
||||
aggregation := make([]string, 0, len(_g.fns))
|
||||
for _, fn := range _g.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(*megb.flds)+len(megb.fns))
|
||||
for _, f := range *megb.flds {
|
||||
columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
|
||||
for _, f := range *_g.flds {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
columns = append(columns, aggregation...)
|
||||
selector.Select(columns...)
|
||||
}
|
||||
selector.GroupBy(selector.Columns(*megb.flds...)...)
|
||||
selector.GroupBy(selector.Columns(*_g.flds...)...)
|
||||
if err := selector.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := megb.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
@@ -571,27 +571,27 @@ type MaintenanceEntrySelect struct {
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (mes *MaintenanceEntrySelect) Aggregate(fns ...AggregateFunc) *MaintenanceEntrySelect {
|
||||
mes.fns = append(mes.fns, fns...)
|
||||
return mes
|
||||
func (_s *MaintenanceEntrySelect) Aggregate(fns ...AggregateFunc) *MaintenanceEntrySelect {
|
||||
_s.fns = append(_s.fns, fns...)
|
||||
return _s
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (mes *MaintenanceEntrySelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, mes.ctx, ent.OpQuerySelect)
|
||||
if err := mes.prepareQuery(ctx); err != nil {
|
||||
func (_s *MaintenanceEntrySelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
|
||||
if err := _s.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*MaintenanceEntryQuery, *MaintenanceEntrySelect](ctx, mes.MaintenanceEntryQuery, mes, mes.inters, v)
|
||||
return scanWithInterceptors[*MaintenanceEntryQuery, *MaintenanceEntrySelect](ctx, _s.MaintenanceEntryQuery, _s, _s.inters, v)
|
||||
}
|
||||
|
||||
func (mes *MaintenanceEntrySelect) sqlScan(ctx context.Context, root *MaintenanceEntryQuery, v any) error {
|
||||
func (_s *MaintenanceEntrySelect) sqlScan(ctx context.Context, root *MaintenanceEntryQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx)
|
||||
aggregation := make([]string, 0, len(mes.fns))
|
||||
for _, fn := range mes.fns {
|
||||
aggregation := make([]string, 0, len(_s.fns))
|
||||
for _, fn := range _s.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
switch n := len(*mes.selector.flds); {
|
||||
switch n := len(*_s.selector.flds); {
|
||||
case n == 0 && len(aggregation) > 0:
|
||||
selector.Select(aggregation...)
|
||||
case n != 0 && len(aggregation) > 0:
|
||||
@@ -599,7 +599,7 @@ func (mes *MaintenanceEntrySelect) sqlScan(ctx context.Context, root *Maintenanc
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := mes.driver.Query(ctx, query, args, rows); err != nil {
|
||||
if err := _s.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
@@ -25,151 +25,151 @@ type MaintenanceEntryUpdate struct {
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the MaintenanceEntryUpdate builder.
|
||||
func (meu *MaintenanceEntryUpdate) Where(ps ...predicate.MaintenanceEntry) *MaintenanceEntryUpdate {
|
||||
meu.mutation.Where(ps...)
|
||||
return meu
|
||||
func (_u *MaintenanceEntryUpdate) Where(ps ...predicate.MaintenanceEntry) *MaintenanceEntryUpdate {
|
||||
_u.mutation.Where(ps...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (meu *MaintenanceEntryUpdate) SetUpdatedAt(t time.Time) *MaintenanceEntryUpdate {
|
||||
meu.mutation.SetUpdatedAt(t)
|
||||
return meu
|
||||
func (_u *MaintenanceEntryUpdate) SetUpdatedAt(v time.Time) *MaintenanceEntryUpdate {
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetEntityID sets the "entity_id" field.
|
||||
func (meu *MaintenanceEntryUpdate) SetEntityID(u uuid.UUID) *MaintenanceEntryUpdate {
|
||||
meu.mutation.SetEntityID(u)
|
||||
return meu
|
||||
func (_u *MaintenanceEntryUpdate) SetEntityID(v uuid.UUID) *MaintenanceEntryUpdate {
|
||||
_u.mutation.SetEntityID(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableEntityID sets the "entity_id" field if the given value is not nil.
|
||||
func (meu *MaintenanceEntryUpdate) SetNillableEntityID(u *uuid.UUID) *MaintenanceEntryUpdate {
|
||||
if u != nil {
|
||||
meu.SetEntityID(*u)
|
||||
func (_u *MaintenanceEntryUpdate) SetNillableEntityID(v *uuid.UUID) *MaintenanceEntryUpdate {
|
||||
if v != nil {
|
||||
_u.SetEntityID(*v)
|
||||
}
|
||||
return meu
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetDate sets the "date" field.
|
||||
func (meu *MaintenanceEntryUpdate) SetDate(t time.Time) *MaintenanceEntryUpdate {
|
||||
meu.mutation.SetDate(t)
|
||||
return meu
|
||||
func (_u *MaintenanceEntryUpdate) SetDate(v time.Time) *MaintenanceEntryUpdate {
|
||||
_u.mutation.SetDate(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableDate sets the "date" field if the given value is not nil.
|
||||
func (meu *MaintenanceEntryUpdate) SetNillableDate(t *time.Time) *MaintenanceEntryUpdate {
|
||||
if t != nil {
|
||||
meu.SetDate(*t)
|
||||
func (_u *MaintenanceEntryUpdate) SetNillableDate(v *time.Time) *MaintenanceEntryUpdate {
|
||||
if v != nil {
|
||||
_u.SetDate(*v)
|
||||
}
|
||||
return meu
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearDate clears the value of the "date" field.
|
||||
func (meu *MaintenanceEntryUpdate) ClearDate() *MaintenanceEntryUpdate {
|
||||
meu.mutation.ClearDate()
|
||||
return meu
|
||||
func (_u *MaintenanceEntryUpdate) ClearDate() *MaintenanceEntryUpdate {
|
||||
_u.mutation.ClearDate()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetScheduledDate sets the "scheduled_date" field.
|
||||
func (meu *MaintenanceEntryUpdate) SetScheduledDate(t time.Time) *MaintenanceEntryUpdate {
|
||||
meu.mutation.SetScheduledDate(t)
|
||||
return meu
|
||||
func (_u *MaintenanceEntryUpdate) SetScheduledDate(v time.Time) *MaintenanceEntryUpdate {
|
||||
_u.mutation.SetScheduledDate(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableScheduledDate sets the "scheduled_date" field if the given value is not nil.
|
||||
func (meu *MaintenanceEntryUpdate) SetNillableScheduledDate(t *time.Time) *MaintenanceEntryUpdate {
|
||||
if t != nil {
|
||||
meu.SetScheduledDate(*t)
|
||||
func (_u *MaintenanceEntryUpdate) SetNillableScheduledDate(v *time.Time) *MaintenanceEntryUpdate {
|
||||
if v != nil {
|
||||
_u.SetScheduledDate(*v)
|
||||
}
|
||||
return meu
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearScheduledDate clears the value of the "scheduled_date" field.
|
||||
func (meu *MaintenanceEntryUpdate) ClearScheduledDate() *MaintenanceEntryUpdate {
|
||||
meu.mutation.ClearScheduledDate()
|
||||
return meu
|
||||
func (_u *MaintenanceEntryUpdate) ClearScheduledDate() *MaintenanceEntryUpdate {
|
||||
_u.mutation.ClearScheduledDate()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (meu *MaintenanceEntryUpdate) SetName(s string) *MaintenanceEntryUpdate {
|
||||
meu.mutation.SetName(s)
|
||||
return meu
|
||||
func (_u *MaintenanceEntryUpdate) SetName(v string) *MaintenanceEntryUpdate {
|
||||
_u.mutation.SetName(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableName sets the "name" field if the given value is not nil.
|
||||
func (meu *MaintenanceEntryUpdate) SetNillableName(s *string) *MaintenanceEntryUpdate {
|
||||
if s != nil {
|
||||
meu.SetName(*s)
|
||||
func (_u *MaintenanceEntryUpdate) SetNillableName(v *string) *MaintenanceEntryUpdate {
|
||||
if v != nil {
|
||||
_u.SetName(*v)
|
||||
}
|
||||
return meu
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetDescription sets the "description" field.
|
||||
func (meu *MaintenanceEntryUpdate) SetDescription(s string) *MaintenanceEntryUpdate {
|
||||
meu.mutation.SetDescription(s)
|
||||
return meu
|
||||
func (_u *MaintenanceEntryUpdate) SetDescription(v string) *MaintenanceEntryUpdate {
|
||||
_u.mutation.SetDescription(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableDescription sets the "description" field if the given value is not nil.
|
||||
func (meu *MaintenanceEntryUpdate) SetNillableDescription(s *string) *MaintenanceEntryUpdate {
|
||||
if s != nil {
|
||||
meu.SetDescription(*s)
|
||||
func (_u *MaintenanceEntryUpdate) SetNillableDescription(v *string) *MaintenanceEntryUpdate {
|
||||
if v != nil {
|
||||
_u.SetDescription(*v)
|
||||
}
|
||||
return meu
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearDescription clears the value of the "description" field.
|
||||
func (meu *MaintenanceEntryUpdate) ClearDescription() *MaintenanceEntryUpdate {
|
||||
meu.mutation.ClearDescription()
|
||||
return meu
|
||||
func (_u *MaintenanceEntryUpdate) ClearDescription() *MaintenanceEntryUpdate {
|
||||
_u.mutation.ClearDescription()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetCost sets the "cost" field.
|
||||
func (meu *MaintenanceEntryUpdate) SetCost(f float64) *MaintenanceEntryUpdate {
|
||||
meu.mutation.ResetCost()
|
||||
meu.mutation.SetCost(f)
|
||||
return meu
|
||||
func (_u *MaintenanceEntryUpdate) SetCost(v float64) *MaintenanceEntryUpdate {
|
||||
_u.mutation.ResetCost()
|
||||
_u.mutation.SetCost(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableCost sets the "cost" field if the given value is not nil.
|
||||
func (meu *MaintenanceEntryUpdate) SetNillableCost(f *float64) *MaintenanceEntryUpdate {
|
||||
if f != nil {
|
||||
meu.SetCost(*f)
|
||||
func (_u *MaintenanceEntryUpdate) SetNillableCost(v *float64) *MaintenanceEntryUpdate {
|
||||
if v != nil {
|
||||
_u.SetCost(*v)
|
||||
}
|
||||
return meu
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddCost adds f to the "cost" field.
|
||||
func (meu *MaintenanceEntryUpdate) AddCost(f float64) *MaintenanceEntryUpdate {
|
||||
meu.mutation.AddCost(f)
|
||||
return meu
|
||||
// AddCost adds value to the "cost" field.
|
||||
func (_u *MaintenanceEntryUpdate) AddCost(v float64) *MaintenanceEntryUpdate {
|
||||
_u.mutation.AddCost(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetEntity sets the "entity" edge to the Entity entity.
|
||||
func (meu *MaintenanceEntryUpdate) SetEntity(e *Entity) *MaintenanceEntryUpdate {
|
||||
return meu.SetEntityID(e.ID)
|
||||
func (_u *MaintenanceEntryUpdate) SetEntity(v *Entity) *MaintenanceEntryUpdate {
|
||||
return _u.SetEntityID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the MaintenanceEntryMutation object of the builder.
|
||||
func (meu *MaintenanceEntryUpdate) Mutation() *MaintenanceEntryMutation {
|
||||
return meu.mutation
|
||||
func (_u *MaintenanceEntryUpdate) Mutation() *MaintenanceEntryMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// ClearEntity clears the "entity" edge to the Entity entity.
|
||||
func (meu *MaintenanceEntryUpdate) ClearEntity() *MaintenanceEntryUpdate {
|
||||
meu.mutation.ClearEntity()
|
||||
return meu
|
||||
func (_u *MaintenanceEntryUpdate) ClearEntity() *MaintenanceEntryUpdate {
|
||||
_u.mutation.ClearEntity()
|
||||
return _u
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (meu *MaintenanceEntryUpdate) Save(ctx context.Context) (int, error) {
|
||||
meu.defaults()
|
||||
return withHooks(ctx, meu.sqlSave, meu.mutation, meu.hooks)
|
||||
func (_u *MaintenanceEntryUpdate) Save(ctx context.Context) (int, error) {
|
||||
_u.defaults()
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (meu *MaintenanceEntryUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := meu.Save(ctx)
|
||||
func (_u *MaintenanceEntryUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -177,87 +177,87 @@ func (meu *MaintenanceEntryUpdate) SaveX(ctx context.Context) int {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (meu *MaintenanceEntryUpdate) Exec(ctx context.Context) error {
|
||||
_, err := meu.Save(ctx)
|
||||
func (_u *MaintenanceEntryUpdate) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (meu *MaintenanceEntryUpdate) ExecX(ctx context.Context) {
|
||||
if err := meu.Exec(ctx); err != nil {
|
||||
func (_u *MaintenanceEntryUpdate) ExecX(ctx context.Context) {
|
||||
if err := _u.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (meu *MaintenanceEntryUpdate) defaults() {
|
||||
if _, ok := meu.mutation.UpdatedAt(); !ok {
|
||||
func (_u *MaintenanceEntryUpdate) defaults() {
|
||||
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
||||
v := maintenanceentry.UpdateDefaultUpdatedAt()
|
||||
meu.mutation.SetUpdatedAt(v)
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (meu *MaintenanceEntryUpdate) check() error {
|
||||
if v, ok := meu.mutation.Name(); ok {
|
||||
func (_u *MaintenanceEntryUpdate) check() error {
|
||||
if v, ok := _u.mutation.Name(); ok {
|
||||
if err := maintenanceentry.NameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "MaintenanceEntry.name": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := meu.mutation.Description(); ok {
|
||||
if v, ok := _u.mutation.Description(); ok {
|
||||
if err := maintenanceentry.DescriptionValidator(v); err != nil {
|
||||
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "MaintenanceEntry.description": %w`, err)}
|
||||
}
|
||||
}
|
||||
if meu.mutation.EntityCleared() && len(meu.mutation.EntityIDs()) > 0 {
|
||||
if _u.mutation.EntityCleared() && len(_u.mutation.EntityIDs()) > 0 {
|
||||
return errors.New(`ent: clearing a required unique edge "MaintenanceEntry.entity"`)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (meu *MaintenanceEntryUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
if err := meu.check(); err != nil {
|
||||
return n, err
|
||||
func (_u *MaintenanceEntryUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
if err := _u.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(maintenanceentry.Table, maintenanceentry.Columns, sqlgraph.NewFieldSpec(maintenanceentry.FieldID, field.TypeUUID))
|
||||
if ps := meu.mutation.predicates; len(ps) > 0 {
|
||||
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := meu.mutation.UpdatedAt(); ok {
|
||||
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(maintenanceentry.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := meu.mutation.Date(); ok {
|
||||
if value, ok := _u.mutation.Date(); ok {
|
||||
_spec.SetField(maintenanceentry.FieldDate, field.TypeTime, value)
|
||||
}
|
||||
if meu.mutation.DateCleared() {
|
||||
if _u.mutation.DateCleared() {
|
||||
_spec.ClearField(maintenanceentry.FieldDate, field.TypeTime)
|
||||
}
|
||||
if value, ok := meu.mutation.ScheduledDate(); ok {
|
||||
if value, ok := _u.mutation.ScheduledDate(); ok {
|
||||
_spec.SetField(maintenanceentry.FieldScheduledDate, field.TypeTime, value)
|
||||
}
|
||||
if meu.mutation.ScheduledDateCleared() {
|
||||
if _u.mutation.ScheduledDateCleared() {
|
||||
_spec.ClearField(maintenanceentry.FieldScheduledDate, field.TypeTime)
|
||||
}
|
||||
if value, ok := meu.mutation.Name(); ok {
|
||||
if value, ok := _u.mutation.Name(); ok {
|
||||
_spec.SetField(maintenanceentry.FieldName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := meu.mutation.Description(); ok {
|
||||
if value, ok := _u.mutation.Description(); ok {
|
||||
_spec.SetField(maintenanceentry.FieldDescription, field.TypeString, value)
|
||||
}
|
||||
if meu.mutation.DescriptionCleared() {
|
||||
if _u.mutation.DescriptionCleared() {
|
||||
_spec.ClearField(maintenanceentry.FieldDescription, field.TypeString)
|
||||
}
|
||||
if value, ok := meu.mutation.Cost(); ok {
|
||||
if value, ok := _u.mutation.Cost(); ok {
|
||||
_spec.SetField(maintenanceentry.FieldCost, field.TypeFloat64, value)
|
||||
}
|
||||
if value, ok := meu.mutation.AddedCost(); ok {
|
||||
if value, ok := _u.mutation.AddedCost(); ok {
|
||||
_spec.AddField(maintenanceentry.FieldCost, field.TypeFloat64, value)
|
||||
}
|
||||
if meu.mutation.EntityCleared() {
|
||||
if _u.mutation.EntityCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -270,7 +270,7 @@ func (meu *MaintenanceEntryUpdate) sqlSave(ctx context.Context) (n int, err erro
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := meu.mutation.EntityIDs(); len(nodes) > 0 {
|
||||
if nodes := _u.mutation.EntityIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -286,7 +286,7 @@ func (meu *MaintenanceEntryUpdate) sqlSave(ctx context.Context) (n int, err erro
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, meu.driver, _spec); err != nil {
|
||||
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{maintenanceentry.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
@@ -294,8 +294,8 @@ func (meu *MaintenanceEntryUpdate) sqlSave(ctx context.Context) (n int, err erro
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
meu.mutation.done = true
|
||||
return n, nil
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
// MaintenanceEntryUpdateOne is the builder for updating a single MaintenanceEntry entity.
|
||||
@@ -307,158 +307,158 @@ type MaintenanceEntryUpdateOne struct {
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (meuo *MaintenanceEntryUpdateOne) SetUpdatedAt(t time.Time) *MaintenanceEntryUpdateOne {
|
||||
meuo.mutation.SetUpdatedAt(t)
|
||||
return meuo
|
||||
func (_u *MaintenanceEntryUpdateOne) SetUpdatedAt(v time.Time) *MaintenanceEntryUpdateOne {
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetEntityID sets the "entity_id" field.
|
||||
func (meuo *MaintenanceEntryUpdateOne) SetEntityID(u uuid.UUID) *MaintenanceEntryUpdateOne {
|
||||
meuo.mutation.SetEntityID(u)
|
||||
return meuo
|
||||
func (_u *MaintenanceEntryUpdateOne) SetEntityID(v uuid.UUID) *MaintenanceEntryUpdateOne {
|
||||
_u.mutation.SetEntityID(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableEntityID sets the "entity_id" field if the given value is not nil.
|
||||
func (meuo *MaintenanceEntryUpdateOne) SetNillableEntityID(u *uuid.UUID) *MaintenanceEntryUpdateOne {
|
||||
if u != nil {
|
||||
meuo.SetEntityID(*u)
|
||||
func (_u *MaintenanceEntryUpdateOne) SetNillableEntityID(v *uuid.UUID) *MaintenanceEntryUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetEntityID(*v)
|
||||
}
|
||||
return meuo
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetDate sets the "date" field.
|
||||
func (meuo *MaintenanceEntryUpdateOne) SetDate(t time.Time) *MaintenanceEntryUpdateOne {
|
||||
meuo.mutation.SetDate(t)
|
||||
return meuo
|
||||
func (_u *MaintenanceEntryUpdateOne) SetDate(v time.Time) *MaintenanceEntryUpdateOne {
|
||||
_u.mutation.SetDate(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableDate sets the "date" field if the given value is not nil.
|
||||
func (meuo *MaintenanceEntryUpdateOne) SetNillableDate(t *time.Time) *MaintenanceEntryUpdateOne {
|
||||
if t != nil {
|
||||
meuo.SetDate(*t)
|
||||
func (_u *MaintenanceEntryUpdateOne) SetNillableDate(v *time.Time) *MaintenanceEntryUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetDate(*v)
|
||||
}
|
||||
return meuo
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearDate clears the value of the "date" field.
|
||||
func (meuo *MaintenanceEntryUpdateOne) ClearDate() *MaintenanceEntryUpdateOne {
|
||||
meuo.mutation.ClearDate()
|
||||
return meuo
|
||||
func (_u *MaintenanceEntryUpdateOne) ClearDate() *MaintenanceEntryUpdateOne {
|
||||
_u.mutation.ClearDate()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetScheduledDate sets the "scheduled_date" field.
|
||||
func (meuo *MaintenanceEntryUpdateOne) SetScheduledDate(t time.Time) *MaintenanceEntryUpdateOne {
|
||||
meuo.mutation.SetScheduledDate(t)
|
||||
return meuo
|
||||
func (_u *MaintenanceEntryUpdateOne) SetScheduledDate(v time.Time) *MaintenanceEntryUpdateOne {
|
||||
_u.mutation.SetScheduledDate(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableScheduledDate sets the "scheduled_date" field if the given value is not nil.
|
||||
func (meuo *MaintenanceEntryUpdateOne) SetNillableScheduledDate(t *time.Time) *MaintenanceEntryUpdateOne {
|
||||
if t != nil {
|
||||
meuo.SetScheduledDate(*t)
|
||||
func (_u *MaintenanceEntryUpdateOne) SetNillableScheduledDate(v *time.Time) *MaintenanceEntryUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetScheduledDate(*v)
|
||||
}
|
||||
return meuo
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearScheduledDate clears the value of the "scheduled_date" field.
|
||||
func (meuo *MaintenanceEntryUpdateOne) ClearScheduledDate() *MaintenanceEntryUpdateOne {
|
||||
meuo.mutation.ClearScheduledDate()
|
||||
return meuo
|
||||
func (_u *MaintenanceEntryUpdateOne) ClearScheduledDate() *MaintenanceEntryUpdateOne {
|
||||
_u.mutation.ClearScheduledDate()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (meuo *MaintenanceEntryUpdateOne) SetName(s string) *MaintenanceEntryUpdateOne {
|
||||
meuo.mutation.SetName(s)
|
||||
return meuo
|
||||
func (_u *MaintenanceEntryUpdateOne) SetName(v string) *MaintenanceEntryUpdateOne {
|
||||
_u.mutation.SetName(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableName sets the "name" field if the given value is not nil.
|
||||
func (meuo *MaintenanceEntryUpdateOne) SetNillableName(s *string) *MaintenanceEntryUpdateOne {
|
||||
if s != nil {
|
||||
meuo.SetName(*s)
|
||||
func (_u *MaintenanceEntryUpdateOne) SetNillableName(v *string) *MaintenanceEntryUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetName(*v)
|
||||
}
|
||||
return meuo
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetDescription sets the "description" field.
|
||||
func (meuo *MaintenanceEntryUpdateOne) SetDescription(s string) *MaintenanceEntryUpdateOne {
|
||||
meuo.mutation.SetDescription(s)
|
||||
return meuo
|
||||
func (_u *MaintenanceEntryUpdateOne) SetDescription(v string) *MaintenanceEntryUpdateOne {
|
||||
_u.mutation.SetDescription(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableDescription sets the "description" field if the given value is not nil.
|
||||
func (meuo *MaintenanceEntryUpdateOne) SetNillableDescription(s *string) *MaintenanceEntryUpdateOne {
|
||||
if s != nil {
|
||||
meuo.SetDescription(*s)
|
||||
func (_u *MaintenanceEntryUpdateOne) SetNillableDescription(v *string) *MaintenanceEntryUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetDescription(*v)
|
||||
}
|
||||
return meuo
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearDescription clears the value of the "description" field.
|
||||
func (meuo *MaintenanceEntryUpdateOne) ClearDescription() *MaintenanceEntryUpdateOne {
|
||||
meuo.mutation.ClearDescription()
|
||||
return meuo
|
||||
func (_u *MaintenanceEntryUpdateOne) ClearDescription() *MaintenanceEntryUpdateOne {
|
||||
_u.mutation.ClearDescription()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetCost sets the "cost" field.
|
||||
func (meuo *MaintenanceEntryUpdateOne) SetCost(f float64) *MaintenanceEntryUpdateOne {
|
||||
meuo.mutation.ResetCost()
|
||||
meuo.mutation.SetCost(f)
|
||||
return meuo
|
||||
func (_u *MaintenanceEntryUpdateOne) SetCost(v float64) *MaintenanceEntryUpdateOne {
|
||||
_u.mutation.ResetCost()
|
||||
_u.mutation.SetCost(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableCost sets the "cost" field if the given value is not nil.
|
||||
func (meuo *MaintenanceEntryUpdateOne) SetNillableCost(f *float64) *MaintenanceEntryUpdateOne {
|
||||
if f != nil {
|
||||
meuo.SetCost(*f)
|
||||
func (_u *MaintenanceEntryUpdateOne) SetNillableCost(v *float64) *MaintenanceEntryUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetCost(*v)
|
||||
}
|
||||
return meuo
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddCost adds f to the "cost" field.
|
||||
func (meuo *MaintenanceEntryUpdateOne) AddCost(f float64) *MaintenanceEntryUpdateOne {
|
||||
meuo.mutation.AddCost(f)
|
||||
return meuo
|
||||
// AddCost adds value to the "cost" field.
|
||||
func (_u *MaintenanceEntryUpdateOne) AddCost(v float64) *MaintenanceEntryUpdateOne {
|
||||
_u.mutation.AddCost(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetEntity sets the "entity" edge to the Entity entity.
|
||||
func (meuo *MaintenanceEntryUpdateOne) SetEntity(e *Entity) *MaintenanceEntryUpdateOne {
|
||||
return meuo.SetEntityID(e.ID)
|
||||
func (_u *MaintenanceEntryUpdateOne) SetEntity(v *Entity) *MaintenanceEntryUpdateOne {
|
||||
return _u.SetEntityID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the MaintenanceEntryMutation object of the builder.
|
||||
func (meuo *MaintenanceEntryUpdateOne) Mutation() *MaintenanceEntryMutation {
|
||||
return meuo.mutation
|
||||
func (_u *MaintenanceEntryUpdateOne) Mutation() *MaintenanceEntryMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// ClearEntity clears the "entity" edge to the Entity entity.
|
||||
func (meuo *MaintenanceEntryUpdateOne) ClearEntity() *MaintenanceEntryUpdateOne {
|
||||
meuo.mutation.ClearEntity()
|
||||
return meuo
|
||||
func (_u *MaintenanceEntryUpdateOne) ClearEntity() *MaintenanceEntryUpdateOne {
|
||||
_u.mutation.ClearEntity()
|
||||
return _u
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the MaintenanceEntryUpdate builder.
|
||||
func (meuo *MaintenanceEntryUpdateOne) Where(ps ...predicate.MaintenanceEntry) *MaintenanceEntryUpdateOne {
|
||||
meuo.mutation.Where(ps...)
|
||||
return meuo
|
||||
func (_u *MaintenanceEntryUpdateOne) Where(ps ...predicate.MaintenanceEntry) *MaintenanceEntryUpdateOne {
|
||||
_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 (meuo *MaintenanceEntryUpdateOne) Select(field string, fields ...string) *MaintenanceEntryUpdateOne {
|
||||
meuo.fields = append([]string{field}, fields...)
|
||||
return meuo
|
||||
func (_u *MaintenanceEntryUpdateOne) Select(field string, fields ...string) *MaintenanceEntryUpdateOne {
|
||||
_u.fields = append([]string{field}, fields...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated MaintenanceEntry entity.
|
||||
func (meuo *MaintenanceEntryUpdateOne) Save(ctx context.Context) (*MaintenanceEntry, error) {
|
||||
meuo.defaults()
|
||||
return withHooks(ctx, meuo.sqlSave, meuo.mutation, meuo.hooks)
|
||||
func (_u *MaintenanceEntryUpdateOne) Save(ctx context.Context) (*MaintenanceEntry, error) {
|
||||
_u.defaults()
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (meuo *MaintenanceEntryUpdateOne) SaveX(ctx context.Context) *MaintenanceEntry {
|
||||
node, err := meuo.Save(ctx)
|
||||
func (_u *MaintenanceEntryUpdateOne) SaveX(ctx context.Context) *MaintenanceEntry {
|
||||
node, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -466,55 +466,55 @@ func (meuo *MaintenanceEntryUpdateOne) SaveX(ctx context.Context) *MaintenanceEn
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (meuo *MaintenanceEntryUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := meuo.Save(ctx)
|
||||
func (_u *MaintenanceEntryUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (meuo *MaintenanceEntryUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := meuo.Exec(ctx); err != nil {
|
||||
func (_u *MaintenanceEntryUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := _u.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (meuo *MaintenanceEntryUpdateOne) defaults() {
|
||||
if _, ok := meuo.mutation.UpdatedAt(); !ok {
|
||||
func (_u *MaintenanceEntryUpdateOne) defaults() {
|
||||
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
||||
v := maintenanceentry.UpdateDefaultUpdatedAt()
|
||||
meuo.mutation.SetUpdatedAt(v)
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (meuo *MaintenanceEntryUpdateOne) check() error {
|
||||
if v, ok := meuo.mutation.Name(); ok {
|
||||
func (_u *MaintenanceEntryUpdateOne) check() error {
|
||||
if v, ok := _u.mutation.Name(); ok {
|
||||
if err := maintenanceentry.NameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "MaintenanceEntry.name": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := meuo.mutation.Description(); ok {
|
||||
if v, ok := _u.mutation.Description(); ok {
|
||||
if err := maintenanceentry.DescriptionValidator(v); err != nil {
|
||||
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "MaintenanceEntry.description": %w`, err)}
|
||||
}
|
||||
}
|
||||
if meuo.mutation.EntityCleared() && len(meuo.mutation.EntityIDs()) > 0 {
|
||||
if _u.mutation.EntityCleared() && len(_u.mutation.EntityIDs()) > 0 {
|
||||
return errors.New(`ent: clearing a required unique edge "MaintenanceEntry.entity"`)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (meuo *MaintenanceEntryUpdateOne) sqlSave(ctx context.Context) (_node *MaintenanceEntry, err error) {
|
||||
if err := meuo.check(); err != nil {
|
||||
func (_u *MaintenanceEntryUpdateOne) sqlSave(ctx context.Context) (_node *MaintenanceEntry, err error) {
|
||||
if err := _u.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(maintenanceentry.Table, maintenanceentry.Columns, sqlgraph.NewFieldSpec(maintenanceentry.FieldID, field.TypeUUID))
|
||||
id, ok := meuo.mutation.ID()
|
||||
id, ok := _u.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "MaintenanceEntry.id" for update`)}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
if fields := meuo.fields; len(fields) > 0 {
|
||||
if fields := _u.fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, maintenanceentry.FieldID)
|
||||
for _, f := range fields {
|
||||
@@ -526,44 +526,44 @@ func (meuo *MaintenanceEntryUpdateOne) sqlSave(ctx context.Context) (_node *Main
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := meuo.mutation.predicates; len(ps) > 0 {
|
||||
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := meuo.mutation.UpdatedAt(); ok {
|
||||
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(maintenanceentry.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := meuo.mutation.Date(); ok {
|
||||
if value, ok := _u.mutation.Date(); ok {
|
||||
_spec.SetField(maintenanceentry.FieldDate, field.TypeTime, value)
|
||||
}
|
||||
if meuo.mutation.DateCleared() {
|
||||
if _u.mutation.DateCleared() {
|
||||
_spec.ClearField(maintenanceentry.FieldDate, field.TypeTime)
|
||||
}
|
||||
if value, ok := meuo.mutation.ScheduledDate(); ok {
|
||||
if value, ok := _u.mutation.ScheduledDate(); ok {
|
||||
_spec.SetField(maintenanceentry.FieldScheduledDate, field.TypeTime, value)
|
||||
}
|
||||
if meuo.mutation.ScheduledDateCleared() {
|
||||
if _u.mutation.ScheduledDateCleared() {
|
||||
_spec.ClearField(maintenanceentry.FieldScheduledDate, field.TypeTime)
|
||||
}
|
||||
if value, ok := meuo.mutation.Name(); ok {
|
||||
if value, ok := _u.mutation.Name(); ok {
|
||||
_spec.SetField(maintenanceentry.FieldName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := meuo.mutation.Description(); ok {
|
||||
if value, ok := _u.mutation.Description(); ok {
|
||||
_spec.SetField(maintenanceentry.FieldDescription, field.TypeString, value)
|
||||
}
|
||||
if meuo.mutation.DescriptionCleared() {
|
||||
if _u.mutation.DescriptionCleared() {
|
||||
_spec.ClearField(maintenanceentry.FieldDescription, field.TypeString)
|
||||
}
|
||||
if value, ok := meuo.mutation.Cost(); ok {
|
||||
if value, ok := _u.mutation.Cost(); ok {
|
||||
_spec.SetField(maintenanceentry.FieldCost, field.TypeFloat64, value)
|
||||
}
|
||||
if value, ok := meuo.mutation.AddedCost(); ok {
|
||||
if value, ok := _u.mutation.AddedCost(); ok {
|
||||
_spec.AddField(maintenanceentry.FieldCost, field.TypeFloat64, value)
|
||||
}
|
||||
if meuo.mutation.EntityCleared() {
|
||||
if _u.mutation.EntityCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -576,7 +576,7 @@ func (meuo *MaintenanceEntryUpdateOne) sqlSave(ctx context.Context) (_node *Main
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := meuo.mutation.EntityIDs(); len(nodes) > 0 {
|
||||
if nodes := _u.mutation.EntityIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -592,10 +592,10 @@ func (meuo *MaintenanceEntryUpdateOne) sqlSave(ctx context.Context) (_node *Main
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
_node = &MaintenanceEntry{config: meuo.config}
|
||||
_node = &MaintenanceEntry{config: _u.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
if err = sqlgraph.UpdateNode(ctx, meuo.driver, _spec); err != nil {
|
||||
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{maintenanceentry.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
@@ -603,6 +603,6 @@ func (meuo *MaintenanceEntryUpdateOne) sqlSave(ctx context.Context) (_node *Main
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
meuo.mutation.done = true
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ func (*Notifier) scanValues(columns []string) ([]any, error) {
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the Notifier fields.
|
||||
func (n *Notifier) assignValues(columns []string, values []any) error {
|
||||
func (_m *Notifier) assignValues(columns []string, values []any) error {
|
||||
if m, n := len(values), len(columns); m < n {
|
||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||
}
|
||||
@@ -105,52 +105,52 @@ func (n *Notifier) assignValues(columns []string, values []any) error {
|
||||
if value, ok := values[i].(*uuid.UUID); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", values[i])
|
||||
} else if value != nil {
|
||||
n.ID = *value
|
||||
_m.ID = *value
|
||||
}
|
||||
case notifier.FieldCreatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
||||
} else if value.Valid {
|
||||
n.CreatedAt = value.Time
|
||||
_m.CreatedAt = value.Time
|
||||
}
|
||||
case notifier.FieldUpdatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
|
||||
} else if value.Valid {
|
||||
n.UpdatedAt = value.Time
|
||||
_m.UpdatedAt = value.Time
|
||||
}
|
||||
case notifier.FieldGroupID:
|
||||
if value, ok := values[i].(*uuid.UUID); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field group_id", values[i])
|
||||
} else if value != nil {
|
||||
n.GroupID = *value
|
||||
_m.GroupID = *value
|
||||
}
|
||||
case notifier.FieldUserID:
|
||||
if value, ok := values[i].(*uuid.UUID); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field user_id", values[i])
|
||||
} else if value != nil {
|
||||
n.UserID = *value
|
||||
_m.UserID = *value
|
||||
}
|
||||
case notifier.FieldName:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field name", values[i])
|
||||
} else if value.Valid {
|
||||
n.Name = value.String
|
||||
_m.Name = value.String
|
||||
}
|
||||
case notifier.FieldURL:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field url", values[i])
|
||||
} else if value.Valid {
|
||||
n.URL = value.String
|
||||
_m.URL = value.String
|
||||
}
|
||||
case notifier.FieldIsActive:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field is_active", values[i])
|
||||
} else if value.Valid {
|
||||
n.IsActive = value.Bool
|
||||
_m.IsActive = value.Bool
|
||||
}
|
||||
default:
|
||||
n.selectValues.Set(columns[i], values[i])
|
||||
_m.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -158,62 +158,62 @@ func (n *Notifier) assignValues(columns []string, values []any) error {
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the Notifier.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (n *Notifier) Value(name string) (ent.Value, error) {
|
||||
return n.selectValues.Get(name)
|
||||
func (_m *Notifier) Value(name string) (ent.Value, error) {
|
||||
return _m.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// QueryGroup queries the "group" edge of the Notifier entity.
|
||||
func (n *Notifier) QueryGroup() *GroupQuery {
|
||||
return NewNotifierClient(n.config).QueryGroup(n)
|
||||
func (_m *Notifier) QueryGroup() *GroupQuery {
|
||||
return NewNotifierClient(_m.config).QueryGroup(_m)
|
||||
}
|
||||
|
||||
// QueryUser queries the "user" edge of the Notifier entity.
|
||||
func (n *Notifier) QueryUser() *UserQuery {
|
||||
return NewNotifierClient(n.config).QueryUser(n)
|
||||
func (_m *Notifier) QueryUser() *UserQuery {
|
||||
return NewNotifierClient(_m.config).QueryUser(_m)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this Notifier.
|
||||
// Note that you need to call Notifier.Unwrap() before calling this method if this Notifier
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (n *Notifier) Update() *NotifierUpdateOne {
|
||||
return NewNotifierClient(n.config).UpdateOne(n)
|
||||
func (_m *Notifier) Update() *NotifierUpdateOne {
|
||||
return NewNotifierClient(_m.config).UpdateOne(_m)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the Notifier entity that was returned from a transaction after it was closed,
|
||||
// so that all future queries will be executed through the driver which created the transaction.
|
||||
func (n *Notifier) Unwrap() *Notifier {
|
||||
_tx, ok := n.config.driver.(*txDriver)
|
||||
func (_m *Notifier) Unwrap() *Notifier {
|
||||
_tx, ok := _m.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: Notifier is not a transactional entity")
|
||||
}
|
||||
n.config.driver = _tx.drv
|
||||
return n
|
||||
_m.config.driver = _tx.drv
|
||||
return _m
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (n *Notifier) String() string {
|
||||
func (_m *Notifier) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("Notifier(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", n.ID))
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||||
builder.WriteString("created_at=")
|
||||
builder.WriteString(n.CreatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("updated_at=")
|
||||
builder.WriteString(n.UpdatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("group_id=")
|
||||
builder.WriteString(fmt.Sprintf("%v", n.GroupID))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.GroupID))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("user_id=")
|
||||
builder.WriteString(fmt.Sprintf("%v", n.UserID))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.UserID))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("name=")
|
||||
builder.WriteString(n.Name)
|
||||
builder.WriteString(_m.Name)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("url=<sensitive>")
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("is_active=")
|
||||
builder.WriteString(fmt.Sprintf("%v", n.IsActive))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.IsActive))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
@@ -24,109 +24,109 @@ type NotifierCreate struct {
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (nc *NotifierCreate) SetCreatedAt(t time.Time) *NotifierCreate {
|
||||
nc.mutation.SetCreatedAt(t)
|
||||
return nc
|
||||
func (_c *NotifierCreate) SetCreatedAt(v time.Time) *NotifierCreate {
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||
func (nc *NotifierCreate) SetNillableCreatedAt(t *time.Time) *NotifierCreate {
|
||||
if t != nil {
|
||||
nc.SetCreatedAt(*t)
|
||||
func (_c *NotifierCreate) SetNillableCreatedAt(v *time.Time) *NotifierCreate {
|
||||
if v != nil {
|
||||
_c.SetCreatedAt(*v)
|
||||
}
|
||||
return nc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (nc *NotifierCreate) SetUpdatedAt(t time.Time) *NotifierCreate {
|
||||
nc.mutation.SetUpdatedAt(t)
|
||||
return nc
|
||||
func (_c *NotifierCreate) SetUpdatedAt(v time.Time) *NotifierCreate {
|
||||
_c.mutation.SetUpdatedAt(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
||||
func (nc *NotifierCreate) SetNillableUpdatedAt(t *time.Time) *NotifierCreate {
|
||||
if t != nil {
|
||||
nc.SetUpdatedAt(*t)
|
||||
func (_c *NotifierCreate) SetNillableUpdatedAt(v *time.Time) *NotifierCreate {
|
||||
if v != nil {
|
||||
_c.SetUpdatedAt(*v)
|
||||
}
|
||||
return nc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetGroupID sets the "group_id" field.
|
||||
func (nc *NotifierCreate) SetGroupID(u uuid.UUID) *NotifierCreate {
|
||||
nc.mutation.SetGroupID(u)
|
||||
return nc
|
||||
func (_c *NotifierCreate) SetGroupID(v uuid.UUID) *NotifierCreate {
|
||||
_c.mutation.SetGroupID(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetUserID sets the "user_id" field.
|
||||
func (nc *NotifierCreate) SetUserID(u uuid.UUID) *NotifierCreate {
|
||||
nc.mutation.SetUserID(u)
|
||||
return nc
|
||||
func (_c *NotifierCreate) SetUserID(v uuid.UUID) *NotifierCreate {
|
||||
_c.mutation.SetUserID(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (nc *NotifierCreate) SetName(s string) *NotifierCreate {
|
||||
nc.mutation.SetName(s)
|
||||
return nc
|
||||
func (_c *NotifierCreate) SetName(v string) *NotifierCreate {
|
||||
_c.mutation.SetName(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetURL sets the "url" field.
|
||||
func (nc *NotifierCreate) SetURL(s string) *NotifierCreate {
|
||||
nc.mutation.SetURL(s)
|
||||
return nc
|
||||
func (_c *NotifierCreate) SetURL(v string) *NotifierCreate {
|
||||
_c.mutation.SetURL(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetIsActive sets the "is_active" field.
|
||||
func (nc *NotifierCreate) SetIsActive(b bool) *NotifierCreate {
|
||||
nc.mutation.SetIsActive(b)
|
||||
return nc
|
||||
func (_c *NotifierCreate) SetIsActive(v bool) *NotifierCreate {
|
||||
_c.mutation.SetIsActive(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableIsActive sets the "is_active" field if the given value is not nil.
|
||||
func (nc *NotifierCreate) SetNillableIsActive(b *bool) *NotifierCreate {
|
||||
if b != nil {
|
||||
nc.SetIsActive(*b)
|
||||
func (_c *NotifierCreate) SetNillableIsActive(v *bool) *NotifierCreate {
|
||||
if v != nil {
|
||||
_c.SetIsActive(*v)
|
||||
}
|
||||
return nc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetID sets the "id" field.
|
||||
func (nc *NotifierCreate) SetID(u uuid.UUID) *NotifierCreate {
|
||||
nc.mutation.SetID(u)
|
||||
return nc
|
||||
func (_c *NotifierCreate) SetID(v uuid.UUID) *NotifierCreate {
|
||||
_c.mutation.SetID(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableID sets the "id" field if the given value is not nil.
|
||||
func (nc *NotifierCreate) SetNillableID(u *uuid.UUID) *NotifierCreate {
|
||||
if u != nil {
|
||||
nc.SetID(*u)
|
||||
func (_c *NotifierCreate) SetNillableID(v *uuid.UUID) *NotifierCreate {
|
||||
if v != nil {
|
||||
_c.SetID(*v)
|
||||
}
|
||||
return nc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetGroup sets the "group" edge to the Group entity.
|
||||
func (nc *NotifierCreate) SetGroup(g *Group) *NotifierCreate {
|
||||
return nc.SetGroupID(g.ID)
|
||||
func (_c *NotifierCreate) SetGroup(v *Group) *NotifierCreate {
|
||||
return _c.SetGroupID(v.ID)
|
||||
}
|
||||
|
||||
// SetUser sets the "user" edge to the User entity.
|
||||
func (nc *NotifierCreate) SetUser(u *User) *NotifierCreate {
|
||||
return nc.SetUserID(u.ID)
|
||||
func (_c *NotifierCreate) SetUser(v *User) *NotifierCreate {
|
||||
return _c.SetUserID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the NotifierMutation object of the builder.
|
||||
func (nc *NotifierCreate) Mutation() *NotifierMutation {
|
||||
return nc.mutation
|
||||
func (_c *NotifierCreate) Mutation() *NotifierMutation {
|
||||
return _c.mutation
|
||||
}
|
||||
|
||||
// Save creates the Notifier in the database.
|
||||
func (nc *NotifierCreate) Save(ctx context.Context) (*Notifier, error) {
|
||||
nc.defaults()
|
||||
return withHooks(ctx, nc.sqlSave, nc.mutation, nc.hooks)
|
||||
func (_c *NotifierCreate) Save(ctx context.Context) (*Notifier, error) {
|
||||
_c.defaults()
|
||||
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (nc *NotifierCreate) SaveX(ctx context.Context) *Notifier {
|
||||
v, err := nc.Save(ctx)
|
||||
func (_c *NotifierCreate) SaveX(ctx context.Context) *Notifier {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -134,86 +134,86 @@ func (nc *NotifierCreate) SaveX(ctx context.Context) *Notifier {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (nc *NotifierCreate) Exec(ctx context.Context) error {
|
||||
_, err := nc.Save(ctx)
|
||||
func (_c *NotifierCreate) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (nc *NotifierCreate) ExecX(ctx context.Context) {
|
||||
if err := nc.Exec(ctx); err != nil {
|
||||
func (_c *NotifierCreate) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (nc *NotifierCreate) defaults() {
|
||||
if _, ok := nc.mutation.CreatedAt(); !ok {
|
||||
func (_c *NotifierCreate) defaults() {
|
||||
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||
v := notifier.DefaultCreatedAt()
|
||||
nc.mutation.SetCreatedAt(v)
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
}
|
||||
if _, ok := nc.mutation.UpdatedAt(); !ok {
|
||||
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
||||
v := notifier.DefaultUpdatedAt()
|
||||
nc.mutation.SetUpdatedAt(v)
|
||||
_c.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
if _, ok := nc.mutation.IsActive(); !ok {
|
||||
if _, ok := _c.mutation.IsActive(); !ok {
|
||||
v := notifier.DefaultIsActive
|
||||
nc.mutation.SetIsActive(v)
|
||||
_c.mutation.SetIsActive(v)
|
||||
}
|
||||
if _, ok := nc.mutation.ID(); !ok {
|
||||
if _, ok := _c.mutation.ID(); !ok {
|
||||
v := notifier.DefaultID()
|
||||
nc.mutation.SetID(v)
|
||||
_c.mutation.SetID(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (nc *NotifierCreate) check() error {
|
||||
if _, ok := nc.mutation.CreatedAt(); !ok {
|
||||
func (_c *NotifierCreate) check() error {
|
||||
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Notifier.created_at"`)}
|
||||
}
|
||||
if _, ok := nc.mutation.UpdatedAt(); !ok {
|
||||
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
||||
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Notifier.updated_at"`)}
|
||||
}
|
||||
if _, ok := nc.mutation.GroupID(); !ok {
|
||||
if _, ok := _c.mutation.GroupID(); !ok {
|
||||
return &ValidationError{Name: "group_id", err: errors.New(`ent: missing required field "Notifier.group_id"`)}
|
||||
}
|
||||
if _, ok := nc.mutation.UserID(); !ok {
|
||||
if _, ok := _c.mutation.UserID(); !ok {
|
||||
return &ValidationError{Name: "user_id", err: errors.New(`ent: missing required field "Notifier.user_id"`)}
|
||||
}
|
||||
if _, ok := nc.mutation.Name(); !ok {
|
||||
if _, ok := _c.mutation.Name(); !ok {
|
||||
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Notifier.name"`)}
|
||||
}
|
||||
if v, ok := nc.mutation.Name(); ok {
|
||||
if v, ok := _c.mutation.Name(); ok {
|
||||
if err := notifier.NameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Notifier.name": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := nc.mutation.URL(); !ok {
|
||||
if _, ok := _c.mutation.URL(); !ok {
|
||||
return &ValidationError{Name: "url", err: errors.New(`ent: missing required field "Notifier.url"`)}
|
||||
}
|
||||
if v, ok := nc.mutation.URL(); ok {
|
||||
if v, ok := _c.mutation.URL(); ok {
|
||||
if err := notifier.URLValidator(v); err != nil {
|
||||
return &ValidationError{Name: "url", err: fmt.Errorf(`ent: validator failed for field "Notifier.url": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := nc.mutation.IsActive(); !ok {
|
||||
if _, ok := _c.mutation.IsActive(); !ok {
|
||||
return &ValidationError{Name: "is_active", err: errors.New(`ent: missing required field "Notifier.is_active"`)}
|
||||
}
|
||||
if len(nc.mutation.GroupIDs()) == 0 {
|
||||
if len(_c.mutation.GroupIDs()) == 0 {
|
||||
return &ValidationError{Name: "group", err: errors.New(`ent: missing required edge "Notifier.group"`)}
|
||||
}
|
||||
if len(nc.mutation.UserIDs()) == 0 {
|
||||
if len(_c.mutation.UserIDs()) == 0 {
|
||||
return &ValidationError{Name: "user", err: errors.New(`ent: missing required edge "Notifier.user"`)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (nc *NotifierCreate) sqlSave(ctx context.Context) (*Notifier, error) {
|
||||
if err := nc.check(); err != nil {
|
||||
func (_c *NotifierCreate) sqlSave(ctx context.Context) (*Notifier, error) {
|
||||
if err := _c.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_node, _spec := nc.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, nc.driver, _spec); err != nil {
|
||||
_node, _spec := _c.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
@@ -226,41 +226,41 @@ func (nc *NotifierCreate) sqlSave(ctx context.Context) (*Notifier, error) {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
nc.mutation.id = &_node.ID
|
||||
nc.mutation.done = true
|
||||
_c.mutation.id = &_node.ID
|
||||
_c.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
func (nc *NotifierCreate) createSpec() (*Notifier, *sqlgraph.CreateSpec) {
|
||||
func (_c *NotifierCreate) createSpec() (*Notifier, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &Notifier{config: nc.config}
|
||||
_node = &Notifier{config: _c.config}
|
||||
_spec = sqlgraph.NewCreateSpec(notifier.Table, sqlgraph.NewFieldSpec(notifier.FieldID, field.TypeUUID))
|
||||
)
|
||||
if id, ok := nc.mutation.ID(); ok {
|
||||
if id, ok := _c.mutation.ID(); ok {
|
||||
_node.ID = id
|
||||
_spec.ID.Value = &id
|
||||
}
|
||||
if value, ok := nc.mutation.CreatedAt(); ok {
|
||||
if value, ok := _c.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(notifier.FieldCreatedAt, field.TypeTime, value)
|
||||
_node.CreatedAt = value
|
||||
}
|
||||
if value, ok := nc.mutation.UpdatedAt(); ok {
|
||||
if value, ok := _c.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(notifier.FieldUpdatedAt, field.TypeTime, value)
|
||||
_node.UpdatedAt = value
|
||||
}
|
||||
if value, ok := nc.mutation.Name(); ok {
|
||||
if value, ok := _c.mutation.Name(); ok {
|
||||
_spec.SetField(notifier.FieldName, field.TypeString, value)
|
||||
_node.Name = value
|
||||
}
|
||||
if value, ok := nc.mutation.URL(); ok {
|
||||
if value, ok := _c.mutation.URL(); ok {
|
||||
_spec.SetField(notifier.FieldURL, field.TypeString, value)
|
||||
_node.URL = value
|
||||
}
|
||||
if value, ok := nc.mutation.IsActive(); ok {
|
||||
if value, ok := _c.mutation.IsActive(); ok {
|
||||
_spec.SetField(notifier.FieldIsActive, field.TypeBool, value)
|
||||
_node.IsActive = value
|
||||
}
|
||||
if nodes := nc.mutation.GroupIDs(); len(nodes) > 0 {
|
||||
if nodes := _c.mutation.GroupIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -277,7 +277,7 @@ func (nc *NotifierCreate) createSpec() (*Notifier, *sqlgraph.CreateSpec) {
|
||||
_node.GroupID = nodes[0]
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
if nodes := nc.mutation.UserIDs(); len(nodes) > 0 {
|
||||
if nodes := _c.mutation.UserIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -305,16 +305,16 @@ type NotifierCreateBulk struct {
|
||||
}
|
||||
|
||||
// Save creates the Notifier entities in the database.
|
||||
func (ncb *NotifierCreateBulk) Save(ctx context.Context) ([]*Notifier, error) {
|
||||
if ncb.err != nil {
|
||||
return nil, ncb.err
|
||||
func (_c *NotifierCreateBulk) Save(ctx context.Context) ([]*Notifier, error) {
|
||||
if _c.err != nil {
|
||||
return nil, _c.err
|
||||
}
|
||||
specs := make([]*sqlgraph.CreateSpec, len(ncb.builders))
|
||||
nodes := make([]*Notifier, len(ncb.builders))
|
||||
mutators := make([]Mutator, len(ncb.builders))
|
||||
for i := range ncb.builders {
|
||||
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
||||
nodes := make([]*Notifier, len(_c.builders))
|
||||
mutators := make([]Mutator, len(_c.builders))
|
||||
for i := range _c.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := ncb.builders[i]
|
||||
builder := _c.builders[i]
|
||||
builder.defaults()
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*NotifierMutation)
|
||||
@@ -328,11 +328,11 @@ func (ncb *NotifierCreateBulk) Save(ctx context.Context) ([]*Notifier, error) {
|
||||
var err error
|
||||
nodes[i], specs[i] = builder.createSpec()
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, ncb.builders[i+1].mutation)
|
||||
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
|
||||
} else {
|
||||
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
||||
// Invoke the actual operation on the latest mutation in the chain.
|
||||
if err = sqlgraph.BatchCreate(ctx, ncb.driver, spec); err != nil {
|
||||
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
@@ -352,7 +352,7 @@ func (ncb *NotifierCreateBulk) Save(ctx context.Context) ([]*Notifier, error) {
|
||||
}(i, ctx)
|
||||
}
|
||||
if len(mutators) > 0 {
|
||||
if _, err := mutators[0].Mutate(ctx, ncb.builders[0].mutation); err != nil {
|
||||
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
@@ -360,8 +360,8 @@ func (ncb *NotifierCreateBulk) Save(ctx context.Context) ([]*Notifier, error) {
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (ncb *NotifierCreateBulk) SaveX(ctx context.Context) []*Notifier {
|
||||
v, err := ncb.Save(ctx)
|
||||
func (_c *NotifierCreateBulk) SaveX(ctx context.Context) []*Notifier {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -369,14 +369,14 @@ func (ncb *NotifierCreateBulk) SaveX(ctx context.Context) []*Notifier {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (ncb *NotifierCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := ncb.Save(ctx)
|
||||
func (_c *NotifierCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (ncb *NotifierCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := ncb.Exec(ctx); err != nil {
|
||||
func (_c *NotifierCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,56 +20,56 @@ type NotifierDelete struct {
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the NotifierDelete builder.
|
||||
func (nd *NotifierDelete) Where(ps ...predicate.Notifier) *NotifierDelete {
|
||||
nd.mutation.Where(ps...)
|
||||
return nd
|
||||
func (_d *NotifierDelete) Where(ps ...predicate.Notifier) *NotifierDelete {
|
||||
_d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (nd *NotifierDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, nd.sqlExec, nd.mutation, nd.hooks)
|
||||
func (_d *NotifierDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (nd *NotifierDelete) ExecX(ctx context.Context) int {
|
||||
n, err := nd.Exec(ctx)
|
||||
func (_d *NotifierDelete) ExecX(ctx context.Context) int {
|
||||
n, err := _d.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (nd *NotifierDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
func (_d *NotifierDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := sqlgraph.NewDeleteSpec(notifier.Table, sqlgraph.NewFieldSpec(notifier.FieldID, field.TypeUUID))
|
||||
if ps := nd.mutation.predicates; len(ps) > 0 {
|
||||
if ps := _d.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, nd.driver, _spec)
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec)
|
||||
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
nd.mutation.done = true
|
||||
_d.mutation.done = true
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// NotifierDeleteOne is the builder for deleting a single Notifier entity.
|
||||
type NotifierDeleteOne struct {
|
||||
nd *NotifierDelete
|
||||
_d *NotifierDelete
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the NotifierDelete builder.
|
||||
func (ndo *NotifierDeleteOne) Where(ps ...predicate.Notifier) *NotifierDeleteOne {
|
||||
ndo.nd.mutation.Where(ps...)
|
||||
return ndo
|
||||
func (_d *NotifierDeleteOne) Where(ps ...predicate.Notifier) *NotifierDeleteOne {
|
||||
_d._d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (ndo *NotifierDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := ndo.nd.Exec(ctx)
|
||||
func (_d *NotifierDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := _d._d.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
@@ -81,8 +81,8 @@ func (ndo *NotifierDeleteOne) Exec(ctx context.Context) error {
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (ndo *NotifierDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := ndo.Exec(ctx); err != nil {
|
||||
func (_d *NotifierDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := _d.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,44 +33,44 @@ type NotifierQuery struct {
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the NotifierQuery builder.
|
||||
func (nq *NotifierQuery) Where(ps ...predicate.Notifier) *NotifierQuery {
|
||||
nq.predicates = append(nq.predicates, ps...)
|
||||
return nq
|
||||
func (_q *NotifierQuery) Where(ps ...predicate.Notifier) *NotifierQuery {
|
||||
_q.predicates = append(_q.predicates, ps...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// Limit the number of records to be returned by this query.
|
||||
func (nq *NotifierQuery) Limit(limit int) *NotifierQuery {
|
||||
nq.ctx.Limit = &limit
|
||||
return nq
|
||||
func (_q *NotifierQuery) Limit(limit int) *NotifierQuery {
|
||||
_q.ctx.Limit = &limit
|
||||
return _q
|
||||
}
|
||||
|
||||
// Offset to start from.
|
||||
func (nq *NotifierQuery) Offset(offset int) *NotifierQuery {
|
||||
nq.ctx.Offset = &offset
|
||||
return nq
|
||||
func (_q *NotifierQuery) Offset(offset int) *NotifierQuery {
|
||||
_q.ctx.Offset = &offset
|
||||
return _q
|
||||
}
|
||||
|
||||
// Unique configures the query builder to filter duplicate records on query.
|
||||
// By default, unique is set to true, and can be disabled using this method.
|
||||
func (nq *NotifierQuery) Unique(unique bool) *NotifierQuery {
|
||||
nq.ctx.Unique = &unique
|
||||
return nq
|
||||
func (_q *NotifierQuery) Unique(unique bool) *NotifierQuery {
|
||||
_q.ctx.Unique = &unique
|
||||
return _q
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (nq *NotifierQuery) Order(o ...notifier.OrderOption) *NotifierQuery {
|
||||
nq.order = append(nq.order, o...)
|
||||
return nq
|
||||
func (_q *NotifierQuery) Order(o ...notifier.OrderOption) *NotifierQuery {
|
||||
_q.order = append(_q.order, o...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// QueryGroup chains the current query on the "group" edge.
|
||||
func (nq *NotifierQuery) QueryGroup() *GroupQuery {
|
||||
query := (&GroupClient{config: nq.config}).Query()
|
||||
func (_q *NotifierQuery) QueryGroup() *GroupQuery {
|
||||
query := (&GroupClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := nq.prepareQuery(ctx); err != nil {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := nq.sqlQuery(ctx)
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -79,20 +79,20 @@ func (nq *NotifierQuery) QueryGroup() *GroupQuery {
|
||||
sqlgraph.To(group.Table, group.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, notifier.GroupTable, notifier.GroupColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(nq.driver.Dialect(), step)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryUser chains the current query on the "user" edge.
|
||||
func (nq *NotifierQuery) QueryUser() *UserQuery {
|
||||
query := (&UserClient{config: nq.config}).Query()
|
||||
func (_q *NotifierQuery) QueryUser() *UserQuery {
|
||||
query := (&UserClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := nq.prepareQuery(ctx); err != nil {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := nq.sqlQuery(ctx)
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -101,7 +101,7 @@ func (nq *NotifierQuery) QueryUser() *UserQuery {
|
||||
sqlgraph.To(user.Table, user.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, notifier.UserTable, notifier.UserColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(nq.driver.Dialect(), step)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
@@ -109,8 +109,8 @@ func (nq *NotifierQuery) QueryUser() *UserQuery {
|
||||
|
||||
// First returns the first Notifier entity from the query.
|
||||
// Returns a *NotFoundError when no Notifier was found.
|
||||
func (nq *NotifierQuery) First(ctx context.Context) (*Notifier, error) {
|
||||
nodes, err := nq.Limit(1).All(setContextOp(ctx, nq.ctx, ent.OpQueryFirst))
|
||||
func (_q *NotifierQuery) First(ctx context.Context) (*Notifier, error) {
|
||||
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -121,8 +121,8 @@ func (nq *NotifierQuery) First(ctx context.Context) (*Notifier, error) {
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (nq *NotifierQuery) FirstX(ctx context.Context) *Notifier {
|
||||
node, err := nq.First(ctx)
|
||||
func (_q *NotifierQuery) FirstX(ctx context.Context) *Notifier {
|
||||
node, err := _q.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
@@ -131,9 +131,9 @@ func (nq *NotifierQuery) FirstX(ctx context.Context) *Notifier {
|
||||
|
||||
// FirstID returns the first Notifier ID from the query.
|
||||
// Returns a *NotFoundError when no Notifier ID was found.
|
||||
func (nq *NotifierQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
func (_q *NotifierQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
var ids []uuid.UUID
|
||||
if ids, err = nq.Limit(1).IDs(setContextOp(ctx, nq.ctx, ent.OpQueryFirstID)); err != nil {
|
||||
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
@@ -144,8 +144,8 @@ func (nq *NotifierQuery) FirstID(ctx context.Context) (id uuid.UUID, err error)
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (nq *NotifierQuery) FirstIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := nq.FirstID(ctx)
|
||||
func (_q *NotifierQuery) FirstIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := _q.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
@@ -155,8 +155,8 @@ func (nq *NotifierQuery) FirstIDX(ctx context.Context) uuid.UUID {
|
||||
// Only returns a single Notifier entity found by the query, ensuring it only returns one.
|
||||
// Returns a *NotSingularError when more than one Notifier entity is found.
|
||||
// Returns a *NotFoundError when no Notifier entities are found.
|
||||
func (nq *NotifierQuery) Only(ctx context.Context) (*Notifier, error) {
|
||||
nodes, err := nq.Limit(2).All(setContextOp(ctx, nq.ctx, ent.OpQueryOnly))
|
||||
func (_q *NotifierQuery) Only(ctx context.Context) (*Notifier, error) {
|
||||
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -171,8 +171,8 @@ func (nq *NotifierQuery) Only(ctx context.Context) (*Notifier, error) {
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (nq *NotifierQuery) OnlyX(ctx context.Context) *Notifier {
|
||||
node, err := nq.Only(ctx)
|
||||
func (_q *NotifierQuery) OnlyX(ctx context.Context) *Notifier {
|
||||
node, err := _q.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -182,9 +182,9 @@ func (nq *NotifierQuery) OnlyX(ctx context.Context) *Notifier {
|
||||
// OnlyID is like Only, but returns the only Notifier ID in the query.
|
||||
// Returns a *NotSingularError when more than one Notifier ID is found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (nq *NotifierQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
func (_q *NotifierQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
var ids []uuid.UUID
|
||||
if ids, err = nq.Limit(2).IDs(setContextOp(ctx, nq.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
@@ -199,8 +199,8 @@ func (nq *NotifierQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (nq *NotifierQuery) OnlyIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := nq.OnlyID(ctx)
|
||||
func (_q *NotifierQuery) OnlyIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := _q.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -208,18 +208,18 @@ func (nq *NotifierQuery) OnlyIDX(ctx context.Context) uuid.UUID {
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of Notifiers.
|
||||
func (nq *NotifierQuery) All(ctx context.Context) ([]*Notifier, error) {
|
||||
ctx = setContextOp(ctx, nq.ctx, ent.OpQueryAll)
|
||||
if err := nq.prepareQuery(ctx); err != nil {
|
||||
func (_q *NotifierQuery) All(ctx context.Context) ([]*Notifier, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qr := querierAll[[]*Notifier, *NotifierQuery]()
|
||||
return withInterceptors[[]*Notifier](ctx, nq, qr, nq.inters)
|
||||
return withInterceptors[[]*Notifier](ctx, _q, qr, _q.inters)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (nq *NotifierQuery) AllX(ctx context.Context) []*Notifier {
|
||||
nodes, err := nq.All(ctx)
|
||||
func (_q *NotifierQuery) AllX(ctx context.Context) []*Notifier {
|
||||
nodes, err := _q.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -227,20 +227,20 @@ func (nq *NotifierQuery) AllX(ctx context.Context) []*Notifier {
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of Notifier IDs.
|
||||
func (nq *NotifierQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
|
||||
if nq.ctx.Unique == nil && nq.path != nil {
|
||||
nq.Unique(true)
|
||||
func (_q *NotifierQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
|
||||
if _q.ctx.Unique == nil && _q.path != nil {
|
||||
_q.Unique(true)
|
||||
}
|
||||
ctx = setContextOp(ctx, nq.ctx, ent.OpQueryIDs)
|
||||
if err = nq.Select(notifier.FieldID).Scan(ctx, &ids); err != nil {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
|
||||
if err = _q.Select(notifier.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (nq *NotifierQuery) IDsX(ctx context.Context) []uuid.UUID {
|
||||
ids, err := nq.IDs(ctx)
|
||||
func (_q *NotifierQuery) IDsX(ctx context.Context) []uuid.UUID {
|
||||
ids, err := _q.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -248,17 +248,17 @@ func (nq *NotifierQuery) IDsX(ctx context.Context) []uuid.UUID {
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (nq *NotifierQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, nq.ctx, ent.OpQueryCount)
|
||||
if err := nq.prepareQuery(ctx); err != nil {
|
||||
func (_q *NotifierQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return withInterceptors[int](ctx, nq, querierCount[*NotifierQuery](), nq.inters)
|
||||
return withInterceptors[int](ctx, _q, querierCount[*NotifierQuery](), _q.inters)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (nq *NotifierQuery) CountX(ctx context.Context) int {
|
||||
count, err := nq.Count(ctx)
|
||||
func (_q *NotifierQuery) CountX(ctx context.Context) int {
|
||||
count, err := _q.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -266,9 +266,9 @@ func (nq *NotifierQuery) CountX(ctx context.Context) int {
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (nq *NotifierQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, nq.ctx, ent.OpQueryExist)
|
||||
switch _, err := nq.FirstID(ctx); {
|
||||
func (_q *NotifierQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
|
||||
switch _, err := _q.FirstID(ctx); {
|
||||
case IsNotFound(err):
|
||||
return false, nil
|
||||
case err != nil:
|
||||
@@ -279,8 +279,8 @@ func (nq *NotifierQuery) Exist(ctx context.Context) (bool, error) {
|
||||
}
|
||||
|
||||
// ExistX is like Exist, but panics if an error occurs.
|
||||
func (nq *NotifierQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := nq.Exist(ctx)
|
||||
func (_q *NotifierQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := _q.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -289,44 +289,44 @@ func (nq *NotifierQuery) ExistX(ctx context.Context) bool {
|
||||
|
||||
// Clone returns a duplicate of the NotifierQuery builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (nq *NotifierQuery) Clone() *NotifierQuery {
|
||||
if nq == nil {
|
||||
func (_q *NotifierQuery) Clone() *NotifierQuery {
|
||||
if _q == nil {
|
||||
return nil
|
||||
}
|
||||
return &NotifierQuery{
|
||||
config: nq.config,
|
||||
ctx: nq.ctx.Clone(),
|
||||
order: append([]notifier.OrderOption{}, nq.order...),
|
||||
inters: append([]Interceptor{}, nq.inters...),
|
||||
predicates: append([]predicate.Notifier{}, nq.predicates...),
|
||||
withGroup: nq.withGroup.Clone(),
|
||||
withUser: nq.withUser.Clone(),
|
||||
config: _q.config,
|
||||
ctx: _q.ctx.Clone(),
|
||||
order: append([]notifier.OrderOption{}, _q.order...),
|
||||
inters: append([]Interceptor{}, _q.inters...),
|
||||
predicates: append([]predicate.Notifier{}, _q.predicates...),
|
||||
withGroup: _q.withGroup.Clone(),
|
||||
withUser: _q.withUser.Clone(),
|
||||
// clone intermediate query.
|
||||
sql: nq.sql.Clone(),
|
||||
path: nq.path,
|
||||
sql: _q.sql.Clone(),
|
||||
path: _q.path,
|
||||
}
|
||||
}
|
||||
|
||||
// WithGroup tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "group" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (nq *NotifierQuery) WithGroup(opts ...func(*GroupQuery)) *NotifierQuery {
|
||||
query := (&GroupClient{config: nq.config}).Query()
|
||||
func (_q *NotifierQuery) WithGroup(opts ...func(*GroupQuery)) *NotifierQuery {
|
||||
query := (&GroupClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
nq.withGroup = query
|
||||
return nq
|
||||
_q.withGroup = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// WithUser tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "user" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (nq *NotifierQuery) WithUser(opts ...func(*UserQuery)) *NotifierQuery {
|
||||
query := (&UserClient{config: nq.config}).Query()
|
||||
func (_q *NotifierQuery) WithUser(opts ...func(*UserQuery)) *NotifierQuery {
|
||||
query := (&UserClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
nq.withUser = query
|
||||
return nq
|
||||
_q.withUser = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// GroupBy is used to group vertices by one or more fields/columns.
|
||||
@@ -343,10 +343,10 @@ func (nq *NotifierQuery) WithUser(opts ...func(*UserQuery)) *NotifierQuery {
|
||||
// GroupBy(notifier.FieldCreatedAt).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (nq *NotifierQuery) GroupBy(field string, fields ...string) *NotifierGroupBy {
|
||||
nq.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &NotifierGroupBy{build: nq}
|
||||
grbuild.flds = &nq.ctx.Fields
|
||||
func (_q *NotifierQuery) GroupBy(field string, fields ...string) *NotifierGroupBy {
|
||||
_q.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &NotifierGroupBy{build: _q}
|
||||
grbuild.flds = &_q.ctx.Fields
|
||||
grbuild.label = notifier.Label
|
||||
grbuild.scan = grbuild.Scan
|
||||
return grbuild
|
||||
@@ -364,59 +364,59 @@ func (nq *NotifierQuery) GroupBy(field string, fields ...string) *NotifierGroupB
|
||||
// client.Notifier.Query().
|
||||
// Select(notifier.FieldCreatedAt).
|
||||
// Scan(ctx, &v)
|
||||
func (nq *NotifierQuery) Select(fields ...string) *NotifierSelect {
|
||||
nq.ctx.Fields = append(nq.ctx.Fields, fields...)
|
||||
sbuild := &NotifierSelect{NotifierQuery: nq}
|
||||
func (_q *NotifierQuery) Select(fields ...string) *NotifierSelect {
|
||||
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
||||
sbuild := &NotifierSelect{NotifierQuery: _q}
|
||||
sbuild.label = notifier.Label
|
||||
sbuild.flds, sbuild.scan = &nq.ctx.Fields, sbuild.Scan
|
||||
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
|
||||
return sbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a NotifierSelect configured with the given aggregations.
|
||||
func (nq *NotifierQuery) Aggregate(fns ...AggregateFunc) *NotifierSelect {
|
||||
return nq.Select().Aggregate(fns...)
|
||||
func (_q *NotifierQuery) Aggregate(fns ...AggregateFunc) *NotifierSelect {
|
||||
return _q.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (nq *NotifierQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range nq.inters {
|
||||
func (_q *NotifierQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range _q.inters {
|
||||
if inter == nil {
|
||||
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
|
||||
}
|
||||
if trv, ok := inter.(Traverser); ok {
|
||||
if err := trv.Traverse(ctx, nq); err != nil {
|
||||
if err := trv.Traverse(ctx, _q); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, f := range nq.ctx.Fields {
|
||||
for _, f := range _q.ctx.Fields {
|
||||
if !notifier.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
}
|
||||
if nq.path != nil {
|
||||
prev, err := nq.path(ctx)
|
||||
if _q.path != nil {
|
||||
prev, err := _q.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
nq.sql = prev
|
||||
_q.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (nq *NotifierQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Notifier, error) {
|
||||
func (_q *NotifierQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Notifier, error) {
|
||||
var (
|
||||
nodes = []*Notifier{}
|
||||
_spec = nq.querySpec()
|
||||
_spec = _q.querySpec()
|
||||
loadedTypes = [2]bool{
|
||||
nq.withGroup != nil,
|
||||
nq.withUser != nil,
|
||||
_q.withGroup != nil,
|
||||
_q.withUser != nil,
|
||||
}
|
||||
)
|
||||
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||
return (*Notifier).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &Notifier{config: nq.config}
|
||||
node := &Notifier{config: _q.config}
|
||||
nodes = append(nodes, node)
|
||||
node.Edges.loadedTypes = loadedTypes
|
||||
return node.assignValues(columns, values)
|
||||
@@ -424,20 +424,20 @@ func (nq *NotifierQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Not
|
||||
for i := range hooks {
|
||||
hooks[i](ctx, _spec)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, nq.driver, _spec); err != nil {
|
||||
if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
if query := nq.withGroup; query != nil {
|
||||
if err := nq.loadGroup(ctx, query, nodes, nil,
|
||||
if query := _q.withGroup; query != nil {
|
||||
if err := _q.loadGroup(ctx, query, nodes, nil,
|
||||
func(n *Notifier, e *Group) { n.Edges.Group = e }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if query := nq.withUser; query != nil {
|
||||
if err := nq.loadUser(ctx, query, nodes, nil,
|
||||
if query := _q.withUser; query != nil {
|
||||
if err := _q.loadUser(ctx, query, nodes, nil,
|
||||
func(n *Notifier, e *User) { n.Edges.User = e }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -445,7 +445,7 @@ func (nq *NotifierQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Not
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (nq *NotifierQuery) loadGroup(ctx context.Context, query *GroupQuery, nodes []*Notifier, init func(*Notifier), assign func(*Notifier, *Group)) error {
|
||||
func (_q *NotifierQuery) loadGroup(ctx context.Context, query *GroupQuery, nodes []*Notifier, init func(*Notifier), assign func(*Notifier, *Group)) error {
|
||||
ids := make([]uuid.UUID, 0, len(nodes))
|
||||
nodeids := make(map[uuid.UUID][]*Notifier)
|
||||
for i := range nodes {
|
||||
@@ -474,7 +474,7 @@ func (nq *NotifierQuery) loadGroup(ctx context.Context, query *GroupQuery, nodes
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (nq *NotifierQuery) loadUser(ctx context.Context, query *UserQuery, nodes []*Notifier, init func(*Notifier), assign func(*Notifier, *User)) error {
|
||||
func (_q *NotifierQuery) loadUser(ctx context.Context, query *UserQuery, nodes []*Notifier, init func(*Notifier), assign func(*Notifier, *User)) error {
|
||||
ids := make([]uuid.UUID, 0, len(nodes))
|
||||
nodeids := make(map[uuid.UUID][]*Notifier)
|
||||
for i := range nodes {
|
||||
@@ -504,24 +504,24 @@ func (nq *NotifierQuery) loadUser(ctx context.Context, query *UserQuery, nodes [
|
||||
return nil
|
||||
}
|
||||
|
||||
func (nq *NotifierQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := nq.querySpec()
|
||||
_spec.Node.Columns = nq.ctx.Fields
|
||||
if len(nq.ctx.Fields) > 0 {
|
||||
_spec.Unique = nq.ctx.Unique != nil && *nq.ctx.Unique
|
||||
func (_q *NotifierQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := _q.querySpec()
|
||||
_spec.Node.Columns = _q.ctx.Fields
|
||||
if len(_q.ctx.Fields) > 0 {
|
||||
_spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, nq.driver, _spec)
|
||||
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
|
||||
}
|
||||
|
||||
func (nq *NotifierQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
func (_q *NotifierQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := sqlgraph.NewQuerySpec(notifier.Table, notifier.Columns, sqlgraph.NewFieldSpec(notifier.FieldID, field.TypeUUID))
|
||||
_spec.From = nq.sql
|
||||
if unique := nq.ctx.Unique; unique != nil {
|
||||
_spec.From = _q.sql
|
||||
if unique := _q.ctx.Unique; unique != nil {
|
||||
_spec.Unique = *unique
|
||||
} else if nq.path != nil {
|
||||
} else if _q.path != nil {
|
||||
_spec.Unique = true
|
||||
}
|
||||
if fields := nq.ctx.Fields; len(fields) > 0 {
|
||||
if fields := _q.ctx.Fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, notifier.FieldID)
|
||||
for i := range fields {
|
||||
@@ -529,27 +529,27 @@ func (nq *NotifierQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
|
||||
}
|
||||
}
|
||||
if nq.withGroup != nil {
|
||||
if _q.withGroup != nil {
|
||||
_spec.Node.AddColumnOnce(notifier.FieldGroupID)
|
||||
}
|
||||
if nq.withUser != nil {
|
||||
if _q.withUser != nil {
|
||||
_spec.Node.AddColumnOnce(notifier.FieldUserID)
|
||||
}
|
||||
}
|
||||
if ps := nq.predicates; len(ps) > 0 {
|
||||
if ps := _q.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := nq.ctx.Limit; limit != nil {
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := nq.ctx.Offset; offset != nil {
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := nq.order; len(ps) > 0 {
|
||||
if ps := _q.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
@@ -559,33 +559,33 @@ func (nq *NotifierQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (nq *NotifierQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(nq.driver.Dialect())
|
||||
func (_q *NotifierQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(_q.driver.Dialect())
|
||||
t1 := builder.Table(notifier.Table)
|
||||
columns := nq.ctx.Fields
|
||||
columns := _q.ctx.Fields
|
||||
if len(columns) == 0 {
|
||||
columns = notifier.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if nq.sql != nil {
|
||||
selector = nq.sql
|
||||
if _q.sql != nil {
|
||||
selector = _q.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
if nq.ctx.Unique != nil && *nq.ctx.Unique {
|
||||
if _q.ctx.Unique != nil && *_q.ctx.Unique {
|
||||
selector.Distinct()
|
||||
}
|
||||
for _, p := range nq.predicates {
|
||||
for _, p := range _q.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range nq.order {
|
||||
for _, p := range _q.order {
|
||||
p(selector)
|
||||
}
|
||||
if offset := nq.ctx.Offset; offset != nil {
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
// limit is mandatory for offset clause. We start
|
||||
// with default value, and override it below if needed.
|
||||
selector.Offset(*offset).Limit(math.MaxInt32)
|
||||
}
|
||||
if limit := nq.ctx.Limit; limit != nil {
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
@@ -598,41 +598,41 @@ type NotifierGroupBy struct {
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (ngb *NotifierGroupBy) Aggregate(fns ...AggregateFunc) *NotifierGroupBy {
|
||||
ngb.fns = append(ngb.fns, fns...)
|
||||
return ngb
|
||||
func (_g *NotifierGroupBy) Aggregate(fns ...AggregateFunc) *NotifierGroupBy {
|
||||
_g.fns = append(_g.fns, fns...)
|
||||
return _g
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (ngb *NotifierGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, ngb.build.ctx, ent.OpQueryGroupBy)
|
||||
if err := ngb.build.prepareQuery(ctx); err != nil {
|
||||
func (_g *NotifierGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
|
||||
if err := _g.build.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*NotifierQuery, *NotifierGroupBy](ctx, ngb.build, ngb, ngb.build.inters, v)
|
||||
return scanWithInterceptors[*NotifierQuery, *NotifierGroupBy](ctx, _g.build, _g, _g.build.inters, v)
|
||||
}
|
||||
|
||||
func (ngb *NotifierGroupBy) sqlScan(ctx context.Context, root *NotifierQuery, v any) error {
|
||||
func (_g *NotifierGroupBy) sqlScan(ctx context.Context, root *NotifierQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx).Select()
|
||||
aggregation := make([]string, 0, len(ngb.fns))
|
||||
for _, fn := range ngb.fns {
|
||||
aggregation := make([]string, 0, len(_g.fns))
|
||||
for _, fn := range _g.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(*ngb.flds)+len(ngb.fns))
|
||||
for _, f := range *ngb.flds {
|
||||
columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
|
||||
for _, f := range *_g.flds {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
columns = append(columns, aggregation...)
|
||||
selector.Select(columns...)
|
||||
}
|
||||
selector.GroupBy(selector.Columns(*ngb.flds...)...)
|
||||
selector.GroupBy(selector.Columns(*_g.flds...)...)
|
||||
if err := selector.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := ngb.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
@@ -646,27 +646,27 @@ type NotifierSelect struct {
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (ns *NotifierSelect) Aggregate(fns ...AggregateFunc) *NotifierSelect {
|
||||
ns.fns = append(ns.fns, fns...)
|
||||
return ns
|
||||
func (_s *NotifierSelect) Aggregate(fns ...AggregateFunc) *NotifierSelect {
|
||||
_s.fns = append(_s.fns, fns...)
|
||||
return _s
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (ns *NotifierSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, ns.ctx, ent.OpQuerySelect)
|
||||
if err := ns.prepareQuery(ctx); err != nil {
|
||||
func (_s *NotifierSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
|
||||
if err := _s.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*NotifierQuery, *NotifierSelect](ctx, ns.NotifierQuery, ns, ns.inters, v)
|
||||
return scanWithInterceptors[*NotifierQuery, *NotifierSelect](ctx, _s.NotifierQuery, _s, _s.inters, v)
|
||||
}
|
||||
|
||||
func (ns *NotifierSelect) sqlScan(ctx context.Context, root *NotifierQuery, v any) error {
|
||||
func (_s *NotifierSelect) sqlScan(ctx context.Context, root *NotifierQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx)
|
||||
aggregation := make([]string, 0, len(ns.fns))
|
||||
for _, fn := range ns.fns {
|
||||
aggregation := make([]string, 0, len(_s.fns))
|
||||
for _, fn := range _s.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
switch n := len(*ns.selector.flds); {
|
||||
switch n := len(*_s.selector.flds); {
|
||||
case n == 0 && len(aggregation) > 0:
|
||||
selector.Select(aggregation...)
|
||||
case n != 0 && len(aggregation) > 0:
|
||||
@@ -674,7 +674,7 @@ func (ns *NotifierSelect) sqlScan(ctx context.Context, root *NotifierQuery, v an
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := ns.driver.Query(ctx, query, args, rows); err != nil {
|
||||
if err := _s.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
@@ -26,123 +26,123 @@ type NotifierUpdate struct {
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the NotifierUpdate builder.
|
||||
func (nu *NotifierUpdate) Where(ps ...predicate.Notifier) *NotifierUpdate {
|
||||
nu.mutation.Where(ps...)
|
||||
return nu
|
||||
func (_u *NotifierUpdate) Where(ps ...predicate.Notifier) *NotifierUpdate {
|
||||
_u.mutation.Where(ps...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (nu *NotifierUpdate) SetUpdatedAt(t time.Time) *NotifierUpdate {
|
||||
nu.mutation.SetUpdatedAt(t)
|
||||
return nu
|
||||
func (_u *NotifierUpdate) SetUpdatedAt(v time.Time) *NotifierUpdate {
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetGroupID sets the "group_id" field.
|
||||
func (nu *NotifierUpdate) SetGroupID(u uuid.UUID) *NotifierUpdate {
|
||||
nu.mutation.SetGroupID(u)
|
||||
return nu
|
||||
func (_u *NotifierUpdate) SetGroupID(v uuid.UUID) *NotifierUpdate {
|
||||
_u.mutation.SetGroupID(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableGroupID sets the "group_id" field if the given value is not nil.
|
||||
func (nu *NotifierUpdate) SetNillableGroupID(u *uuid.UUID) *NotifierUpdate {
|
||||
if u != nil {
|
||||
nu.SetGroupID(*u)
|
||||
func (_u *NotifierUpdate) SetNillableGroupID(v *uuid.UUID) *NotifierUpdate {
|
||||
if v != nil {
|
||||
_u.SetGroupID(*v)
|
||||
}
|
||||
return nu
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUserID sets the "user_id" field.
|
||||
func (nu *NotifierUpdate) SetUserID(u uuid.UUID) *NotifierUpdate {
|
||||
nu.mutation.SetUserID(u)
|
||||
return nu
|
||||
func (_u *NotifierUpdate) SetUserID(v uuid.UUID) *NotifierUpdate {
|
||||
_u.mutation.SetUserID(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableUserID sets the "user_id" field if the given value is not nil.
|
||||
func (nu *NotifierUpdate) SetNillableUserID(u *uuid.UUID) *NotifierUpdate {
|
||||
if u != nil {
|
||||
nu.SetUserID(*u)
|
||||
func (_u *NotifierUpdate) SetNillableUserID(v *uuid.UUID) *NotifierUpdate {
|
||||
if v != nil {
|
||||
_u.SetUserID(*v)
|
||||
}
|
||||
return nu
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (nu *NotifierUpdate) SetName(s string) *NotifierUpdate {
|
||||
nu.mutation.SetName(s)
|
||||
return nu
|
||||
func (_u *NotifierUpdate) SetName(v string) *NotifierUpdate {
|
||||
_u.mutation.SetName(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableName sets the "name" field if the given value is not nil.
|
||||
func (nu *NotifierUpdate) SetNillableName(s *string) *NotifierUpdate {
|
||||
if s != nil {
|
||||
nu.SetName(*s)
|
||||
func (_u *NotifierUpdate) SetNillableName(v *string) *NotifierUpdate {
|
||||
if v != nil {
|
||||
_u.SetName(*v)
|
||||
}
|
||||
return nu
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetURL sets the "url" field.
|
||||
func (nu *NotifierUpdate) SetURL(s string) *NotifierUpdate {
|
||||
nu.mutation.SetURL(s)
|
||||
return nu
|
||||
func (_u *NotifierUpdate) SetURL(v string) *NotifierUpdate {
|
||||
_u.mutation.SetURL(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableURL sets the "url" field if the given value is not nil.
|
||||
func (nu *NotifierUpdate) SetNillableURL(s *string) *NotifierUpdate {
|
||||
if s != nil {
|
||||
nu.SetURL(*s)
|
||||
func (_u *NotifierUpdate) SetNillableURL(v *string) *NotifierUpdate {
|
||||
if v != nil {
|
||||
_u.SetURL(*v)
|
||||
}
|
||||
return nu
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetIsActive sets the "is_active" field.
|
||||
func (nu *NotifierUpdate) SetIsActive(b bool) *NotifierUpdate {
|
||||
nu.mutation.SetIsActive(b)
|
||||
return nu
|
||||
func (_u *NotifierUpdate) SetIsActive(v bool) *NotifierUpdate {
|
||||
_u.mutation.SetIsActive(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableIsActive sets the "is_active" field if the given value is not nil.
|
||||
func (nu *NotifierUpdate) SetNillableIsActive(b *bool) *NotifierUpdate {
|
||||
if b != nil {
|
||||
nu.SetIsActive(*b)
|
||||
func (_u *NotifierUpdate) SetNillableIsActive(v *bool) *NotifierUpdate {
|
||||
if v != nil {
|
||||
_u.SetIsActive(*v)
|
||||
}
|
||||
return nu
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetGroup sets the "group" edge to the Group entity.
|
||||
func (nu *NotifierUpdate) SetGroup(g *Group) *NotifierUpdate {
|
||||
return nu.SetGroupID(g.ID)
|
||||
func (_u *NotifierUpdate) SetGroup(v *Group) *NotifierUpdate {
|
||||
return _u.SetGroupID(v.ID)
|
||||
}
|
||||
|
||||
// SetUser sets the "user" edge to the User entity.
|
||||
func (nu *NotifierUpdate) SetUser(u *User) *NotifierUpdate {
|
||||
return nu.SetUserID(u.ID)
|
||||
func (_u *NotifierUpdate) SetUser(v *User) *NotifierUpdate {
|
||||
return _u.SetUserID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the NotifierMutation object of the builder.
|
||||
func (nu *NotifierUpdate) Mutation() *NotifierMutation {
|
||||
return nu.mutation
|
||||
func (_u *NotifierUpdate) Mutation() *NotifierMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// ClearGroup clears the "group" edge to the Group entity.
|
||||
func (nu *NotifierUpdate) ClearGroup() *NotifierUpdate {
|
||||
nu.mutation.ClearGroup()
|
||||
return nu
|
||||
func (_u *NotifierUpdate) ClearGroup() *NotifierUpdate {
|
||||
_u.mutation.ClearGroup()
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearUser clears the "user" edge to the User entity.
|
||||
func (nu *NotifierUpdate) ClearUser() *NotifierUpdate {
|
||||
nu.mutation.ClearUser()
|
||||
return nu
|
||||
func (_u *NotifierUpdate) ClearUser() *NotifierUpdate {
|
||||
_u.mutation.ClearUser()
|
||||
return _u
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (nu *NotifierUpdate) Save(ctx context.Context) (int, error) {
|
||||
nu.defaults()
|
||||
return withHooks(ctx, nu.sqlSave, nu.mutation, nu.hooks)
|
||||
func (_u *NotifierUpdate) Save(ctx context.Context) (int, error) {
|
||||
_u.defaults()
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (nu *NotifierUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := nu.Save(ctx)
|
||||
func (_u *NotifierUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -150,72 +150,72 @@ func (nu *NotifierUpdate) SaveX(ctx context.Context) int {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (nu *NotifierUpdate) Exec(ctx context.Context) error {
|
||||
_, err := nu.Save(ctx)
|
||||
func (_u *NotifierUpdate) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (nu *NotifierUpdate) ExecX(ctx context.Context) {
|
||||
if err := nu.Exec(ctx); err != nil {
|
||||
func (_u *NotifierUpdate) ExecX(ctx context.Context) {
|
||||
if err := _u.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (nu *NotifierUpdate) defaults() {
|
||||
if _, ok := nu.mutation.UpdatedAt(); !ok {
|
||||
func (_u *NotifierUpdate) defaults() {
|
||||
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
||||
v := notifier.UpdateDefaultUpdatedAt()
|
||||
nu.mutation.SetUpdatedAt(v)
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (nu *NotifierUpdate) check() error {
|
||||
if v, ok := nu.mutation.Name(); ok {
|
||||
func (_u *NotifierUpdate) check() error {
|
||||
if v, ok := _u.mutation.Name(); ok {
|
||||
if err := notifier.NameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Notifier.name": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := nu.mutation.URL(); ok {
|
||||
if v, ok := _u.mutation.URL(); ok {
|
||||
if err := notifier.URLValidator(v); err != nil {
|
||||
return &ValidationError{Name: "url", err: fmt.Errorf(`ent: validator failed for field "Notifier.url": %w`, err)}
|
||||
}
|
||||
}
|
||||
if nu.mutation.GroupCleared() && len(nu.mutation.GroupIDs()) > 0 {
|
||||
if _u.mutation.GroupCleared() && len(_u.mutation.GroupIDs()) > 0 {
|
||||
return errors.New(`ent: clearing a required unique edge "Notifier.group"`)
|
||||
}
|
||||
if nu.mutation.UserCleared() && len(nu.mutation.UserIDs()) > 0 {
|
||||
if _u.mutation.UserCleared() && len(_u.mutation.UserIDs()) > 0 {
|
||||
return errors.New(`ent: clearing a required unique edge "Notifier.user"`)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (nu *NotifierUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
if err := nu.check(); err != nil {
|
||||
return n, err
|
||||
func (_u *NotifierUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
if err := _u.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(notifier.Table, notifier.Columns, sqlgraph.NewFieldSpec(notifier.FieldID, field.TypeUUID))
|
||||
if ps := nu.mutation.predicates; len(ps) > 0 {
|
||||
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := nu.mutation.UpdatedAt(); ok {
|
||||
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(notifier.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := nu.mutation.Name(); ok {
|
||||
if value, ok := _u.mutation.Name(); ok {
|
||||
_spec.SetField(notifier.FieldName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := nu.mutation.URL(); ok {
|
||||
if value, ok := _u.mutation.URL(); ok {
|
||||
_spec.SetField(notifier.FieldURL, field.TypeString, value)
|
||||
}
|
||||
if value, ok := nu.mutation.IsActive(); ok {
|
||||
if value, ok := _u.mutation.IsActive(); ok {
|
||||
_spec.SetField(notifier.FieldIsActive, field.TypeBool, value)
|
||||
}
|
||||
if nu.mutation.GroupCleared() {
|
||||
if _u.mutation.GroupCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -228,7 +228,7 @@ func (nu *NotifierUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := nu.mutation.GroupIDs(); len(nodes) > 0 {
|
||||
if nodes := _u.mutation.GroupIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -244,7 +244,7 @@ func (nu *NotifierUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if nu.mutation.UserCleared() {
|
||||
if _u.mutation.UserCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -257,7 +257,7 @@ func (nu *NotifierUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := nu.mutation.UserIDs(); len(nodes) > 0 {
|
||||
if nodes := _u.mutation.UserIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -273,7 +273,7 @@ func (nu *NotifierUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, nu.driver, _spec); err != nil {
|
||||
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{notifier.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
@@ -281,8 +281,8 @@ func (nu *NotifierUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
nu.mutation.done = true
|
||||
return n, nil
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
// NotifierUpdateOne is the builder for updating a single Notifier entity.
|
||||
@@ -294,130 +294,130 @@ type NotifierUpdateOne struct {
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (nuo *NotifierUpdateOne) SetUpdatedAt(t time.Time) *NotifierUpdateOne {
|
||||
nuo.mutation.SetUpdatedAt(t)
|
||||
return nuo
|
||||
func (_u *NotifierUpdateOne) SetUpdatedAt(v time.Time) *NotifierUpdateOne {
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetGroupID sets the "group_id" field.
|
||||
func (nuo *NotifierUpdateOne) SetGroupID(u uuid.UUID) *NotifierUpdateOne {
|
||||
nuo.mutation.SetGroupID(u)
|
||||
return nuo
|
||||
func (_u *NotifierUpdateOne) SetGroupID(v uuid.UUID) *NotifierUpdateOne {
|
||||
_u.mutation.SetGroupID(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableGroupID sets the "group_id" field if the given value is not nil.
|
||||
func (nuo *NotifierUpdateOne) SetNillableGroupID(u *uuid.UUID) *NotifierUpdateOne {
|
||||
if u != nil {
|
||||
nuo.SetGroupID(*u)
|
||||
func (_u *NotifierUpdateOne) SetNillableGroupID(v *uuid.UUID) *NotifierUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetGroupID(*v)
|
||||
}
|
||||
return nuo
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUserID sets the "user_id" field.
|
||||
func (nuo *NotifierUpdateOne) SetUserID(u uuid.UUID) *NotifierUpdateOne {
|
||||
nuo.mutation.SetUserID(u)
|
||||
return nuo
|
||||
func (_u *NotifierUpdateOne) SetUserID(v uuid.UUID) *NotifierUpdateOne {
|
||||
_u.mutation.SetUserID(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableUserID sets the "user_id" field if the given value is not nil.
|
||||
func (nuo *NotifierUpdateOne) SetNillableUserID(u *uuid.UUID) *NotifierUpdateOne {
|
||||
if u != nil {
|
||||
nuo.SetUserID(*u)
|
||||
func (_u *NotifierUpdateOne) SetNillableUserID(v *uuid.UUID) *NotifierUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetUserID(*v)
|
||||
}
|
||||
return nuo
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (nuo *NotifierUpdateOne) SetName(s string) *NotifierUpdateOne {
|
||||
nuo.mutation.SetName(s)
|
||||
return nuo
|
||||
func (_u *NotifierUpdateOne) SetName(v string) *NotifierUpdateOne {
|
||||
_u.mutation.SetName(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableName sets the "name" field if the given value is not nil.
|
||||
func (nuo *NotifierUpdateOne) SetNillableName(s *string) *NotifierUpdateOne {
|
||||
if s != nil {
|
||||
nuo.SetName(*s)
|
||||
func (_u *NotifierUpdateOne) SetNillableName(v *string) *NotifierUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetName(*v)
|
||||
}
|
||||
return nuo
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetURL sets the "url" field.
|
||||
func (nuo *NotifierUpdateOne) SetURL(s string) *NotifierUpdateOne {
|
||||
nuo.mutation.SetURL(s)
|
||||
return nuo
|
||||
func (_u *NotifierUpdateOne) SetURL(v string) *NotifierUpdateOne {
|
||||
_u.mutation.SetURL(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableURL sets the "url" field if the given value is not nil.
|
||||
func (nuo *NotifierUpdateOne) SetNillableURL(s *string) *NotifierUpdateOne {
|
||||
if s != nil {
|
||||
nuo.SetURL(*s)
|
||||
func (_u *NotifierUpdateOne) SetNillableURL(v *string) *NotifierUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetURL(*v)
|
||||
}
|
||||
return nuo
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetIsActive sets the "is_active" field.
|
||||
func (nuo *NotifierUpdateOne) SetIsActive(b bool) *NotifierUpdateOne {
|
||||
nuo.mutation.SetIsActive(b)
|
||||
return nuo
|
||||
func (_u *NotifierUpdateOne) SetIsActive(v bool) *NotifierUpdateOne {
|
||||
_u.mutation.SetIsActive(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableIsActive sets the "is_active" field if the given value is not nil.
|
||||
func (nuo *NotifierUpdateOne) SetNillableIsActive(b *bool) *NotifierUpdateOne {
|
||||
if b != nil {
|
||||
nuo.SetIsActive(*b)
|
||||
func (_u *NotifierUpdateOne) SetNillableIsActive(v *bool) *NotifierUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetIsActive(*v)
|
||||
}
|
||||
return nuo
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetGroup sets the "group" edge to the Group entity.
|
||||
func (nuo *NotifierUpdateOne) SetGroup(g *Group) *NotifierUpdateOne {
|
||||
return nuo.SetGroupID(g.ID)
|
||||
func (_u *NotifierUpdateOne) SetGroup(v *Group) *NotifierUpdateOne {
|
||||
return _u.SetGroupID(v.ID)
|
||||
}
|
||||
|
||||
// SetUser sets the "user" edge to the User entity.
|
||||
func (nuo *NotifierUpdateOne) SetUser(u *User) *NotifierUpdateOne {
|
||||
return nuo.SetUserID(u.ID)
|
||||
func (_u *NotifierUpdateOne) SetUser(v *User) *NotifierUpdateOne {
|
||||
return _u.SetUserID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the NotifierMutation object of the builder.
|
||||
func (nuo *NotifierUpdateOne) Mutation() *NotifierMutation {
|
||||
return nuo.mutation
|
||||
func (_u *NotifierUpdateOne) Mutation() *NotifierMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// ClearGroup clears the "group" edge to the Group entity.
|
||||
func (nuo *NotifierUpdateOne) ClearGroup() *NotifierUpdateOne {
|
||||
nuo.mutation.ClearGroup()
|
||||
return nuo
|
||||
func (_u *NotifierUpdateOne) ClearGroup() *NotifierUpdateOne {
|
||||
_u.mutation.ClearGroup()
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearUser clears the "user" edge to the User entity.
|
||||
func (nuo *NotifierUpdateOne) ClearUser() *NotifierUpdateOne {
|
||||
nuo.mutation.ClearUser()
|
||||
return nuo
|
||||
func (_u *NotifierUpdateOne) ClearUser() *NotifierUpdateOne {
|
||||
_u.mutation.ClearUser()
|
||||
return _u
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the NotifierUpdate builder.
|
||||
func (nuo *NotifierUpdateOne) Where(ps ...predicate.Notifier) *NotifierUpdateOne {
|
||||
nuo.mutation.Where(ps...)
|
||||
return nuo
|
||||
func (_u *NotifierUpdateOne) Where(ps ...predicate.Notifier) *NotifierUpdateOne {
|
||||
_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 (nuo *NotifierUpdateOne) Select(field string, fields ...string) *NotifierUpdateOne {
|
||||
nuo.fields = append([]string{field}, fields...)
|
||||
return nuo
|
||||
func (_u *NotifierUpdateOne) Select(field string, fields ...string) *NotifierUpdateOne {
|
||||
_u.fields = append([]string{field}, fields...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated Notifier entity.
|
||||
func (nuo *NotifierUpdateOne) Save(ctx context.Context) (*Notifier, error) {
|
||||
nuo.defaults()
|
||||
return withHooks(ctx, nuo.sqlSave, nuo.mutation, nuo.hooks)
|
||||
func (_u *NotifierUpdateOne) Save(ctx context.Context) (*Notifier, error) {
|
||||
_u.defaults()
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (nuo *NotifierUpdateOne) SaveX(ctx context.Context) *Notifier {
|
||||
node, err := nuo.Save(ctx)
|
||||
func (_u *NotifierUpdateOne) SaveX(ctx context.Context) *Notifier {
|
||||
node, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -425,58 +425,58 @@ func (nuo *NotifierUpdateOne) SaveX(ctx context.Context) *Notifier {
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (nuo *NotifierUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := nuo.Save(ctx)
|
||||
func (_u *NotifierUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (nuo *NotifierUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := nuo.Exec(ctx); err != nil {
|
||||
func (_u *NotifierUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := _u.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (nuo *NotifierUpdateOne) defaults() {
|
||||
if _, ok := nuo.mutation.UpdatedAt(); !ok {
|
||||
func (_u *NotifierUpdateOne) defaults() {
|
||||
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
||||
v := notifier.UpdateDefaultUpdatedAt()
|
||||
nuo.mutation.SetUpdatedAt(v)
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (nuo *NotifierUpdateOne) check() error {
|
||||
if v, ok := nuo.mutation.Name(); ok {
|
||||
func (_u *NotifierUpdateOne) check() error {
|
||||
if v, ok := _u.mutation.Name(); ok {
|
||||
if err := notifier.NameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Notifier.name": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := nuo.mutation.URL(); ok {
|
||||
if v, ok := _u.mutation.URL(); ok {
|
||||
if err := notifier.URLValidator(v); err != nil {
|
||||
return &ValidationError{Name: "url", err: fmt.Errorf(`ent: validator failed for field "Notifier.url": %w`, err)}
|
||||
}
|
||||
}
|
||||
if nuo.mutation.GroupCleared() && len(nuo.mutation.GroupIDs()) > 0 {
|
||||
if _u.mutation.GroupCleared() && len(_u.mutation.GroupIDs()) > 0 {
|
||||
return errors.New(`ent: clearing a required unique edge "Notifier.group"`)
|
||||
}
|
||||
if nuo.mutation.UserCleared() && len(nuo.mutation.UserIDs()) > 0 {
|
||||
if _u.mutation.UserCleared() && len(_u.mutation.UserIDs()) > 0 {
|
||||
return errors.New(`ent: clearing a required unique edge "Notifier.user"`)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (nuo *NotifierUpdateOne) sqlSave(ctx context.Context) (_node *Notifier, err error) {
|
||||
if err := nuo.check(); err != nil {
|
||||
func (_u *NotifierUpdateOne) sqlSave(ctx context.Context) (_node *Notifier, err error) {
|
||||
if err := _u.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(notifier.Table, notifier.Columns, sqlgraph.NewFieldSpec(notifier.FieldID, field.TypeUUID))
|
||||
id, ok := nuo.mutation.ID()
|
||||
id, ok := _u.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Notifier.id" for update`)}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
if fields := nuo.fields; len(fields) > 0 {
|
||||
if fields := _u.fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, notifier.FieldID)
|
||||
for _, f := range fields {
|
||||
@@ -488,26 +488,26 @@ func (nuo *NotifierUpdateOne) sqlSave(ctx context.Context) (_node *Notifier, err
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := nuo.mutation.predicates; len(ps) > 0 {
|
||||
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := nuo.mutation.UpdatedAt(); ok {
|
||||
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(notifier.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := nuo.mutation.Name(); ok {
|
||||
if value, ok := _u.mutation.Name(); ok {
|
||||
_spec.SetField(notifier.FieldName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := nuo.mutation.URL(); ok {
|
||||
if value, ok := _u.mutation.URL(); ok {
|
||||
_spec.SetField(notifier.FieldURL, field.TypeString, value)
|
||||
}
|
||||
if value, ok := nuo.mutation.IsActive(); ok {
|
||||
if value, ok := _u.mutation.IsActive(); ok {
|
||||
_spec.SetField(notifier.FieldIsActive, field.TypeBool, value)
|
||||
}
|
||||
if nuo.mutation.GroupCleared() {
|
||||
if _u.mutation.GroupCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -520,7 +520,7 @@ func (nuo *NotifierUpdateOne) sqlSave(ctx context.Context) (_node *Notifier, err
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := nuo.mutation.GroupIDs(); len(nodes) > 0 {
|
||||
if nodes := _u.mutation.GroupIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -536,7 +536,7 @@ func (nuo *NotifierUpdateOne) sqlSave(ctx context.Context) (_node *Notifier, err
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if nuo.mutation.UserCleared() {
|
||||
if _u.mutation.UserCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -549,7 +549,7 @@ func (nuo *NotifierUpdateOne) sqlSave(ctx context.Context) (_node *Notifier, err
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := nuo.mutation.UserIDs(); len(nodes) > 0 {
|
||||
if nodes := _u.mutation.UserIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -565,10 +565,10 @@ func (nuo *NotifierUpdateOne) sqlSave(ctx context.Context) (_node *Notifier, err
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
_node = &Notifier{config: nuo.config}
|
||||
_node = &Notifier{config: _u.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
if err = sqlgraph.UpdateNode(ctx, nuo.driver, _spec); err != nil {
|
||||
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{notifier.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
@@ -576,6 +576,6 @@ func (nuo *NotifierUpdateOne) sqlSave(ctx context.Context) (_node *Notifier, err
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
nuo.mutation.done = true
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
@@ -5,6 +5,6 @@ package runtime
|
||||
// The schema-stitching logic is generated in github.com/sysadminsmedia/homebox/backend/internal/data/ent/runtime.go
|
||||
|
||||
const (
|
||||
Version = "v0.14.4" // Version of ent codegen.
|
||||
Sum = "h1:/DhDraSLXIkBhyiVoJeSshr4ZYi7femzhj6/TckzZuI=" // Sum of ent codegen.
|
||||
Version = "v0.14.5" // Version of ent codegen.
|
||||
Sum = "h1:Rj2WOYJtCkWyFo6a+5wB3EfBRP0rnx1fMk6gGA0UUe4=" // Sum of ent codegen.
|
||||
)
|
||||
|
||||
@@ -110,7 +110,7 @@ func (*User) scanValues(columns []string) ([]any, error) {
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the User fields.
|
||||
func (u *User) assignValues(columns []string, values []any) error {
|
||||
func (_m *User) assignValues(columns []string, values []any) error {
|
||||
if m, n := len(values), len(columns); m < n {
|
||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||
}
|
||||
@@ -120,71 +120,71 @@ func (u *User) assignValues(columns []string, values []any) error {
|
||||
if value, ok := values[i].(*uuid.UUID); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", values[i])
|
||||
} else if value != nil {
|
||||
u.ID = *value
|
||||
_m.ID = *value
|
||||
}
|
||||
case user.FieldCreatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
||||
} else if value.Valid {
|
||||
u.CreatedAt = value.Time
|
||||
_m.CreatedAt = value.Time
|
||||
}
|
||||
case user.FieldUpdatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
|
||||
} else if value.Valid {
|
||||
u.UpdatedAt = value.Time
|
||||
_m.UpdatedAt = value.Time
|
||||
}
|
||||
case user.FieldName:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field name", values[i])
|
||||
} else if value.Valid {
|
||||
u.Name = value.String
|
||||
_m.Name = value.String
|
||||
}
|
||||
case user.FieldEmail:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field email", values[i])
|
||||
} else if value.Valid {
|
||||
u.Email = value.String
|
||||
_m.Email = value.String
|
||||
}
|
||||
case user.FieldPassword:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field password", values[i])
|
||||
} else if value.Valid {
|
||||
u.Password = value.String
|
||||
_m.Password = value.String
|
||||
}
|
||||
case user.FieldIsSuperuser:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field is_superuser", values[i])
|
||||
} else if value.Valid {
|
||||
u.IsSuperuser = value.Bool
|
||||
_m.IsSuperuser = value.Bool
|
||||
}
|
||||
case user.FieldSuperuser:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field superuser", values[i])
|
||||
} else if value.Valid {
|
||||
u.Superuser = value.Bool
|
||||
_m.Superuser = value.Bool
|
||||
}
|
||||
case user.FieldRole:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field role", values[i])
|
||||
} else if value.Valid {
|
||||
u.Role = user.Role(value.String)
|
||||
_m.Role = user.Role(value.String)
|
||||
}
|
||||
case user.FieldActivatedOn:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field activated_on", values[i])
|
||||
} else if value.Valid {
|
||||
u.ActivatedOn = value.Time
|
||||
_m.ActivatedOn = value.Time
|
||||
}
|
||||
case user.ForeignKeys[0]:
|
||||
if value, ok := values[i].(*sql.NullScanner); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field group_users", values[i])
|
||||
} else if value.Valid {
|
||||
u.group_users = new(uuid.UUID)
|
||||
*u.group_users = *value.S.(*uuid.UUID)
|
||||
_m.group_users = new(uuid.UUID)
|
||||
*_m.group_users = *value.S.(*uuid.UUID)
|
||||
}
|
||||
default:
|
||||
u.selectValues.Set(columns[i], values[i])
|
||||
_m.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -192,73 +192,73 @@ func (u *User) assignValues(columns []string, values []any) error {
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the User.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (u *User) Value(name string) (ent.Value, error) {
|
||||
return u.selectValues.Get(name)
|
||||
func (_m *User) Value(name string) (ent.Value, error) {
|
||||
return _m.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// QueryGroup queries the "group" edge of the User entity.
|
||||
func (u *User) QueryGroup() *GroupQuery {
|
||||
return NewUserClient(u.config).QueryGroup(u)
|
||||
func (_m *User) QueryGroup() *GroupQuery {
|
||||
return NewUserClient(_m.config).QueryGroup(_m)
|
||||
}
|
||||
|
||||
// QueryAuthTokens queries the "auth_tokens" edge of the User entity.
|
||||
func (u *User) QueryAuthTokens() *AuthTokensQuery {
|
||||
return NewUserClient(u.config).QueryAuthTokens(u)
|
||||
func (_m *User) QueryAuthTokens() *AuthTokensQuery {
|
||||
return NewUserClient(_m.config).QueryAuthTokens(_m)
|
||||
}
|
||||
|
||||
// QueryNotifiers queries the "notifiers" edge of the User entity.
|
||||
func (u *User) QueryNotifiers() *NotifierQuery {
|
||||
return NewUserClient(u.config).QueryNotifiers(u)
|
||||
func (_m *User) QueryNotifiers() *NotifierQuery {
|
||||
return NewUserClient(_m.config).QueryNotifiers(_m)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this User.
|
||||
// Note that you need to call User.Unwrap() before calling this method if this User
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (u *User) Update() *UserUpdateOne {
|
||||
return NewUserClient(u.config).UpdateOne(u)
|
||||
func (_m *User) Update() *UserUpdateOne {
|
||||
return NewUserClient(_m.config).UpdateOne(_m)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the User entity that was returned from a transaction after it was closed,
|
||||
// so that all future queries will be executed through the driver which created the transaction.
|
||||
func (u *User) Unwrap() *User {
|
||||
_tx, ok := u.config.driver.(*txDriver)
|
||||
func (_m *User) Unwrap() *User {
|
||||
_tx, ok := _m.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: User is not a transactional entity")
|
||||
}
|
||||
u.config.driver = _tx.drv
|
||||
return u
|
||||
_m.config.driver = _tx.drv
|
||||
return _m
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (u *User) String() string {
|
||||
func (_m *User) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("User(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", u.ID))
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||||
builder.WriteString("created_at=")
|
||||
builder.WriteString(u.CreatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("updated_at=")
|
||||
builder.WriteString(u.UpdatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("name=")
|
||||
builder.WriteString(u.Name)
|
||||
builder.WriteString(_m.Name)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("email=")
|
||||
builder.WriteString(u.Email)
|
||||
builder.WriteString(_m.Email)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("password=<sensitive>")
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("is_superuser=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.IsSuperuser))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.IsSuperuser))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("superuser=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.Superuser))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Superuser))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("role=")
|
||||
builder.WriteString(fmt.Sprintf("%v", u.Role))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Role))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("activated_on=")
|
||||
builder.WriteString(u.ActivatedOn.Format(time.ANSIC))
|
||||
builder.WriteString(_m.ActivatedOn.Format(time.ANSIC))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
@@ -25,176 +25,176 @@ type UserCreate struct {
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (uc *UserCreate) SetCreatedAt(t time.Time) *UserCreate {
|
||||
uc.mutation.SetCreatedAt(t)
|
||||
return uc
|
||||
func (_c *UserCreate) SetCreatedAt(v time.Time) *UserCreate {
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableCreatedAt(t *time.Time) *UserCreate {
|
||||
if t != nil {
|
||||
uc.SetCreatedAt(*t)
|
||||
func (_c *UserCreate) SetNillableCreatedAt(v *time.Time) *UserCreate {
|
||||
if v != nil {
|
||||
_c.SetCreatedAt(*v)
|
||||
}
|
||||
return uc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (uc *UserCreate) SetUpdatedAt(t time.Time) *UserCreate {
|
||||
uc.mutation.SetUpdatedAt(t)
|
||||
return uc
|
||||
func (_c *UserCreate) SetUpdatedAt(v time.Time) *UserCreate {
|
||||
_c.mutation.SetUpdatedAt(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableUpdatedAt(t *time.Time) *UserCreate {
|
||||
if t != nil {
|
||||
uc.SetUpdatedAt(*t)
|
||||
func (_c *UserCreate) SetNillableUpdatedAt(v *time.Time) *UserCreate {
|
||||
if v != nil {
|
||||
_c.SetUpdatedAt(*v)
|
||||
}
|
||||
return uc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (uc *UserCreate) SetName(s string) *UserCreate {
|
||||
uc.mutation.SetName(s)
|
||||
return uc
|
||||
func (_c *UserCreate) SetName(v string) *UserCreate {
|
||||
_c.mutation.SetName(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetEmail sets the "email" field.
|
||||
func (uc *UserCreate) SetEmail(s string) *UserCreate {
|
||||
uc.mutation.SetEmail(s)
|
||||
return uc
|
||||
func (_c *UserCreate) SetEmail(v string) *UserCreate {
|
||||
_c.mutation.SetEmail(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetPassword sets the "password" field.
|
||||
func (uc *UserCreate) SetPassword(s string) *UserCreate {
|
||||
uc.mutation.SetPassword(s)
|
||||
return uc
|
||||
func (_c *UserCreate) SetPassword(v string) *UserCreate {
|
||||
_c.mutation.SetPassword(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetIsSuperuser sets the "is_superuser" field.
|
||||
func (uc *UserCreate) SetIsSuperuser(b bool) *UserCreate {
|
||||
uc.mutation.SetIsSuperuser(b)
|
||||
return uc
|
||||
func (_c *UserCreate) SetIsSuperuser(v bool) *UserCreate {
|
||||
_c.mutation.SetIsSuperuser(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableIsSuperuser sets the "is_superuser" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableIsSuperuser(b *bool) *UserCreate {
|
||||
if b != nil {
|
||||
uc.SetIsSuperuser(*b)
|
||||
func (_c *UserCreate) SetNillableIsSuperuser(v *bool) *UserCreate {
|
||||
if v != nil {
|
||||
_c.SetIsSuperuser(*v)
|
||||
}
|
||||
return uc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetSuperuser sets the "superuser" field.
|
||||
func (uc *UserCreate) SetSuperuser(b bool) *UserCreate {
|
||||
uc.mutation.SetSuperuser(b)
|
||||
return uc
|
||||
func (_c *UserCreate) SetSuperuser(v bool) *UserCreate {
|
||||
_c.mutation.SetSuperuser(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableSuperuser sets the "superuser" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableSuperuser(b *bool) *UserCreate {
|
||||
if b != nil {
|
||||
uc.SetSuperuser(*b)
|
||||
func (_c *UserCreate) SetNillableSuperuser(v *bool) *UserCreate {
|
||||
if v != nil {
|
||||
_c.SetSuperuser(*v)
|
||||
}
|
||||
return uc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetRole sets the "role" field.
|
||||
func (uc *UserCreate) SetRole(u user.Role) *UserCreate {
|
||||
uc.mutation.SetRole(u)
|
||||
return uc
|
||||
func (_c *UserCreate) SetRole(v user.Role) *UserCreate {
|
||||
_c.mutation.SetRole(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableRole sets the "role" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableRole(u *user.Role) *UserCreate {
|
||||
if u != nil {
|
||||
uc.SetRole(*u)
|
||||
func (_c *UserCreate) SetNillableRole(v *user.Role) *UserCreate {
|
||||
if v != nil {
|
||||
_c.SetRole(*v)
|
||||
}
|
||||
return uc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetActivatedOn sets the "activated_on" field.
|
||||
func (uc *UserCreate) SetActivatedOn(t time.Time) *UserCreate {
|
||||
uc.mutation.SetActivatedOn(t)
|
||||
return uc
|
||||
func (_c *UserCreate) SetActivatedOn(v time.Time) *UserCreate {
|
||||
_c.mutation.SetActivatedOn(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableActivatedOn sets the "activated_on" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableActivatedOn(t *time.Time) *UserCreate {
|
||||
if t != nil {
|
||||
uc.SetActivatedOn(*t)
|
||||
func (_c *UserCreate) SetNillableActivatedOn(v *time.Time) *UserCreate {
|
||||
if v != nil {
|
||||
_c.SetActivatedOn(*v)
|
||||
}
|
||||
return uc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetID sets the "id" field.
|
||||
func (uc *UserCreate) SetID(u uuid.UUID) *UserCreate {
|
||||
uc.mutation.SetID(u)
|
||||
return uc
|
||||
func (_c *UserCreate) SetID(v uuid.UUID) *UserCreate {
|
||||
_c.mutation.SetID(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableID sets the "id" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableID(u *uuid.UUID) *UserCreate {
|
||||
if u != nil {
|
||||
uc.SetID(*u)
|
||||
func (_c *UserCreate) SetNillableID(v *uuid.UUID) *UserCreate {
|
||||
if v != nil {
|
||||
_c.SetID(*v)
|
||||
}
|
||||
return uc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetGroupID sets the "group" edge to the Group entity by ID.
|
||||
func (uc *UserCreate) SetGroupID(id uuid.UUID) *UserCreate {
|
||||
uc.mutation.SetGroupID(id)
|
||||
return uc
|
||||
func (_c *UserCreate) SetGroupID(id uuid.UUID) *UserCreate {
|
||||
_c.mutation.SetGroupID(id)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetGroup sets the "group" edge to the Group entity.
|
||||
func (uc *UserCreate) SetGroup(g *Group) *UserCreate {
|
||||
return uc.SetGroupID(g.ID)
|
||||
func (_c *UserCreate) SetGroup(v *Group) *UserCreate {
|
||||
return _c.SetGroupID(v.ID)
|
||||
}
|
||||
|
||||
// AddAuthTokenIDs adds the "auth_tokens" edge to the AuthTokens entity by IDs.
|
||||
func (uc *UserCreate) AddAuthTokenIDs(ids ...uuid.UUID) *UserCreate {
|
||||
uc.mutation.AddAuthTokenIDs(ids...)
|
||||
return uc
|
||||
func (_c *UserCreate) AddAuthTokenIDs(ids ...uuid.UUID) *UserCreate {
|
||||
_c.mutation.AddAuthTokenIDs(ids...)
|
||||
return _c
|
||||
}
|
||||
|
||||
// AddAuthTokens adds the "auth_tokens" edges to the AuthTokens entity.
|
||||
func (uc *UserCreate) AddAuthTokens(a ...*AuthTokens) *UserCreate {
|
||||
ids := make([]uuid.UUID, len(a))
|
||||
for i := range a {
|
||||
ids[i] = a[i].ID
|
||||
func (_c *UserCreate) AddAuthTokens(v ...*AuthTokens) *UserCreate {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return uc.AddAuthTokenIDs(ids...)
|
||||
return _c.AddAuthTokenIDs(ids...)
|
||||
}
|
||||
|
||||
// AddNotifierIDs adds the "notifiers" edge to the Notifier entity by IDs.
|
||||
func (uc *UserCreate) AddNotifierIDs(ids ...uuid.UUID) *UserCreate {
|
||||
uc.mutation.AddNotifierIDs(ids...)
|
||||
return uc
|
||||
func (_c *UserCreate) AddNotifierIDs(ids ...uuid.UUID) *UserCreate {
|
||||
_c.mutation.AddNotifierIDs(ids...)
|
||||
return _c
|
||||
}
|
||||
|
||||
// AddNotifiers adds the "notifiers" edges to the Notifier entity.
|
||||
func (uc *UserCreate) AddNotifiers(n ...*Notifier) *UserCreate {
|
||||
ids := make([]uuid.UUID, len(n))
|
||||
for i := range n {
|
||||
ids[i] = n[i].ID
|
||||
func (_c *UserCreate) AddNotifiers(v ...*Notifier) *UserCreate {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return uc.AddNotifierIDs(ids...)
|
||||
return _c.AddNotifierIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the UserMutation object of the builder.
|
||||
func (uc *UserCreate) Mutation() *UserMutation {
|
||||
return uc.mutation
|
||||
func (_c *UserCreate) Mutation() *UserMutation {
|
||||
return _c.mutation
|
||||
}
|
||||
|
||||
// Save creates the User in the database.
|
||||
func (uc *UserCreate) Save(ctx context.Context) (*User, error) {
|
||||
uc.defaults()
|
||||
return withHooks(ctx, uc.sqlSave, uc.mutation, uc.hooks)
|
||||
func (_c *UserCreate) Save(ctx context.Context) (*User, error) {
|
||||
_c.defaults()
|
||||
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (uc *UserCreate) SaveX(ctx context.Context) *User {
|
||||
v, err := uc.Save(ctx)
|
||||
func (_c *UserCreate) SaveX(ctx context.Context) *User {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -202,104 +202,104 @@ func (uc *UserCreate) SaveX(ctx context.Context) *User {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (uc *UserCreate) Exec(ctx context.Context) error {
|
||||
_, err := uc.Save(ctx)
|
||||
func (_c *UserCreate) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (uc *UserCreate) ExecX(ctx context.Context) {
|
||||
if err := uc.Exec(ctx); err != nil {
|
||||
func (_c *UserCreate) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (uc *UserCreate) defaults() {
|
||||
if _, ok := uc.mutation.CreatedAt(); !ok {
|
||||
func (_c *UserCreate) defaults() {
|
||||
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||
v := user.DefaultCreatedAt()
|
||||
uc.mutation.SetCreatedAt(v)
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
}
|
||||
if _, ok := uc.mutation.UpdatedAt(); !ok {
|
||||
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
||||
v := user.DefaultUpdatedAt()
|
||||
uc.mutation.SetUpdatedAt(v)
|
||||
_c.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
if _, ok := uc.mutation.IsSuperuser(); !ok {
|
||||
if _, ok := _c.mutation.IsSuperuser(); !ok {
|
||||
v := user.DefaultIsSuperuser
|
||||
uc.mutation.SetIsSuperuser(v)
|
||||
_c.mutation.SetIsSuperuser(v)
|
||||
}
|
||||
if _, ok := uc.mutation.Superuser(); !ok {
|
||||
if _, ok := _c.mutation.Superuser(); !ok {
|
||||
v := user.DefaultSuperuser
|
||||
uc.mutation.SetSuperuser(v)
|
||||
_c.mutation.SetSuperuser(v)
|
||||
}
|
||||
if _, ok := uc.mutation.Role(); !ok {
|
||||
if _, ok := _c.mutation.Role(); !ok {
|
||||
v := user.DefaultRole
|
||||
uc.mutation.SetRole(v)
|
||||
_c.mutation.SetRole(v)
|
||||
}
|
||||
if _, ok := uc.mutation.ID(); !ok {
|
||||
if _, ok := _c.mutation.ID(); !ok {
|
||||
v := user.DefaultID()
|
||||
uc.mutation.SetID(v)
|
||||
_c.mutation.SetID(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (uc *UserCreate) check() error {
|
||||
if _, ok := uc.mutation.CreatedAt(); !ok {
|
||||
func (_c *UserCreate) check() error {
|
||||
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "User.created_at"`)}
|
||||
}
|
||||
if _, ok := uc.mutation.UpdatedAt(); !ok {
|
||||
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
||||
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "User.updated_at"`)}
|
||||
}
|
||||
if _, ok := uc.mutation.Name(); !ok {
|
||||
if _, ok := _c.mutation.Name(); !ok {
|
||||
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "User.name"`)}
|
||||
}
|
||||
if v, ok := uc.mutation.Name(); ok {
|
||||
if v, ok := _c.mutation.Name(); ok {
|
||||
if err := user.NameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "User.name": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := uc.mutation.Email(); !ok {
|
||||
if _, ok := _c.mutation.Email(); !ok {
|
||||
return &ValidationError{Name: "email", err: errors.New(`ent: missing required field "User.email"`)}
|
||||
}
|
||||
if v, ok := uc.mutation.Email(); ok {
|
||||
if v, ok := _c.mutation.Email(); ok {
|
||||
if err := user.EmailValidator(v); err != nil {
|
||||
return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "User.email": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := uc.mutation.Password(); !ok {
|
||||
if _, ok := _c.mutation.Password(); !ok {
|
||||
return &ValidationError{Name: "password", err: errors.New(`ent: missing required field "User.password"`)}
|
||||
}
|
||||
if v, ok := uc.mutation.Password(); ok {
|
||||
if v, ok := _c.mutation.Password(); ok {
|
||||
if err := user.PasswordValidator(v); err != nil {
|
||||
return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "User.password": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := uc.mutation.IsSuperuser(); !ok {
|
||||
if _, ok := _c.mutation.IsSuperuser(); !ok {
|
||||
return &ValidationError{Name: "is_superuser", err: errors.New(`ent: missing required field "User.is_superuser"`)}
|
||||
}
|
||||
if _, ok := uc.mutation.Superuser(); !ok {
|
||||
if _, ok := _c.mutation.Superuser(); !ok {
|
||||
return &ValidationError{Name: "superuser", err: errors.New(`ent: missing required field "User.superuser"`)}
|
||||
}
|
||||
if _, ok := uc.mutation.Role(); !ok {
|
||||
if _, ok := _c.mutation.Role(); !ok {
|
||||
return &ValidationError{Name: "role", err: errors.New(`ent: missing required field "User.role"`)}
|
||||
}
|
||||
if v, ok := uc.mutation.Role(); ok {
|
||||
if v, ok := _c.mutation.Role(); ok {
|
||||
if err := user.RoleValidator(v); err != nil {
|
||||
return &ValidationError{Name: "role", err: fmt.Errorf(`ent: validator failed for field "User.role": %w`, err)}
|
||||
}
|
||||
}
|
||||
if len(uc.mutation.GroupIDs()) == 0 {
|
||||
if len(_c.mutation.GroupIDs()) == 0 {
|
||||
return &ValidationError{Name: "group", err: errors.New(`ent: missing required edge "User.group"`)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (uc *UserCreate) sqlSave(ctx context.Context) (*User, error) {
|
||||
if err := uc.check(); err != nil {
|
||||
func (_c *UserCreate) sqlSave(ctx context.Context) (*User, error) {
|
||||
if err := _c.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_node, _spec := uc.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, uc.driver, _spec); err != nil {
|
||||
_node, _spec := _c.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
@@ -312,57 +312,57 @@ func (uc *UserCreate) sqlSave(ctx context.Context) (*User, error) {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
uc.mutation.id = &_node.ID
|
||||
uc.mutation.done = true
|
||||
_c.mutation.id = &_node.ID
|
||||
_c.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) {
|
||||
func (_c *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &User{config: uc.config}
|
||||
_node = &User{config: _c.config}
|
||||
_spec = sqlgraph.NewCreateSpec(user.Table, sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID))
|
||||
)
|
||||
if id, ok := uc.mutation.ID(); ok {
|
||||
if id, ok := _c.mutation.ID(); ok {
|
||||
_node.ID = id
|
||||
_spec.ID.Value = &id
|
||||
}
|
||||
if value, ok := uc.mutation.CreatedAt(); ok {
|
||||
if value, ok := _c.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(user.FieldCreatedAt, field.TypeTime, value)
|
||||
_node.CreatedAt = value
|
||||
}
|
||||
if value, ok := uc.mutation.UpdatedAt(); ok {
|
||||
if value, ok := _c.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(user.FieldUpdatedAt, field.TypeTime, value)
|
||||
_node.UpdatedAt = value
|
||||
}
|
||||
if value, ok := uc.mutation.Name(); ok {
|
||||
if value, ok := _c.mutation.Name(); ok {
|
||||
_spec.SetField(user.FieldName, field.TypeString, value)
|
||||
_node.Name = value
|
||||
}
|
||||
if value, ok := uc.mutation.Email(); ok {
|
||||
if value, ok := _c.mutation.Email(); ok {
|
||||
_spec.SetField(user.FieldEmail, field.TypeString, value)
|
||||
_node.Email = value
|
||||
}
|
||||
if value, ok := uc.mutation.Password(); ok {
|
||||
if value, ok := _c.mutation.Password(); ok {
|
||||
_spec.SetField(user.FieldPassword, field.TypeString, value)
|
||||
_node.Password = value
|
||||
}
|
||||
if value, ok := uc.mutation.IsSuperuser(); ok {
|
||||
if value, ok := _c.mutation.IsSuperuser(); ok {
|
||||
_spec.SetField(user.FieldIsSuperuser, field.TypeBool, value)
|
||||
_node.IsSuperuser = value
|
||||
}
|
||||
if value, ok := uc.mutation.Superuser(); ok {
|
||||
if value, ok := _c.mutation.Superuser(); ok {
|
||||
_spec.SetField(user.FieldSuperuser, field.TypeBool, value)
|
||||
_node.Superuser = value
|
||||
}
|
||||
if value, ok := uc.mutation.Role(); ok {
|
||||
if value, ok := _c.mutation.Role(); ok {
|
||||
_spec.SetField(user.FieldRole, field.TypeEnum, value)
|
||||
_node.Role = value
|
||||
}
|
||||
if value, ok := uc.mutation.ActivatedOn(); ok {
|
||||
if value, ok := _c.mutation.ActivatedOn(); ok {
|
||||
_spec.SetField(user.FieldActivatedOn, field.TypeTime, value)
|
||||
_node.ActivatedOn = value
|
||||
}
|
||||
if nodes := uc.mutation.GroupIDs(); len(nodes) > 0 {
|
||||
if nodes := _c.mutation.GroupIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -379,7 +379,7 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) {
|
||||
_node.group_users = &nodes[0]
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
if nodes := uc.mutation.AuthTokensIDs(); len(nodes) > 0 {
|
||||
if nodes := _c.mutation.AuthTokensIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
@@ -395,7 +395,7 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) {
|
||||
}
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
if nodes := uc.mutation.NotifiersIDs(); len(nodes) > 0 {
|
||||
if nodes := _c.mutation.NotifiersIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
@@ -422,16 +422,16 @@ type UserCreateBulk struct {
|
||||
}
|
||||
|
||||
// Save creates the User entities in the database.
|
||||
func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) {
|
||||
if ucb.err != nil {
|
||||
return nil, ucb.err
|
||||
func (_c *UserCreateBulk) Save(ctx context.Context) ([]*User, error) {
|
||||
if _c.err != nil {
|
||||
return nil, _c.err
|
||||
}
|
||||
specs := make([]*sqlgraph.CreateSpec, len(ucb.builders))
|
||||
nodes := make([]*User, len(ucb.builders))
|
||||
mutators := make([]Mutator, len(ucb.builders))
|
||||
for i := range ucb.builders {
|
||||
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
||||
nodes := make([]*User, len(_c.builders))
|
||||
mutators := make([]Mutator, len(_c.builders))
|
||||
for i := range _c.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := ucb.builders[i]
|
||||
builder := _c.builders[i]
|
||||
builder.defaults()
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*UserMutation)
|
||||
@@ -445,11 +445,11 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) {
|
||||
var err error
|
||||
nodes[i], specs[i] = builder.createSpec()
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, ucb.builders[i+1].mutation)
|
||||
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
|
||||
} else {
|
||||
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
||||
// Invoke the actual operation on the latest mutation in the chain.
|
||||
if err = sqlgraph.BatchCreate(ctx, ucb.driver, spec); err != nil {
|
||||
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
@@ -469,7 +469,7 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) {
|
||||
}(i, ctx)
|
||||
}
|
||||
if len(mutators) > 0 {
|
||||
if _, err := mutators[0].Mutate(ctx, ucb.builders[0].mutation); err != nil {
|
||||
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
@@ -477,8 +477,8 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) {
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (ucb *UserCreateBulk) SaveX(ctx context.Context) []*User {
|
||||
v, err := ucb.Save(ctx)
|
||||
func (_c *UserCreateBulk) SaveX(ctx context.Context) []*User {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -486,14 +486,14 @@ func (ucb *UserCreateBulk) SaveX(ctx context.Context) []*User {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (ucb *UserCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := ucb.Save(ctx)
|
||||
func (_c *UserCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (ucb *UserCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := ucb.Exec(ctx); err != nil {
|
||||
func (_c *UserCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,56 +20,56 @@ type UserDelete struct {
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the UserDelete builder.
|
||||
func (ud *UserDelete) Where(ps ...predicate.User) *UserDelete {
|
||||
ud.mutation.Where(ps...)
|
||||
return ud
|
||||
func (_d *UserDelete) Where(ps ...predicate.User) *UserDelete {
|
||||
_d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (ud *UserDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, ud.sqlExec, ud.mutation, ud.hooks)
|
||||
func (_d *UserDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (ud *UserDelete) ExecX(ctx context.Context) int {
|
||||
n, err := ud.Exec(ctx)
|
||||
func (_d *UserDelete) ExecX(ctx context.Context) int {
|
||||
n, err := _d.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (ud *UserDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
func (_d *UserDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := sqlgraph.NewDeleteSpec(user.Table, sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID))
|
||||
if ps := ud.mutation.predicates; len(ps) > 0 {
|
||||
if ps := _d.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, ud.driver, _spec)
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec)
|
||||
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
ud.mutation.done = true
|
||||
_d.mutation.done = true
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// UserDeleteOne is the builder for deleting a single User entity.
|
||||
type UserDeleteOne struct {
|
||||
ud *UserDelete
|
||||
_d *UserDelete
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the UserDelete builder.
|
||||
func (udo *UserDeleteOne) Where(ps ...predicate.User) *UserDeleteOne {
|
||||
udo.ud.mutation.Where(ps...)
|
||||
return udo
|
||||
func (_d *UserDeleteOne) Where(ps ...predicate.User) *UserDeleteOne {
|
||||
_d._d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (udo *UserDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := udo.ud.Exec(ctx)
|
||||
func (_d *UserDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := _d._d.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
@@ -81,8 +81,8 @@ func (udo *UserDeleteOne) Exec(ctx context.Context) error {
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (udo *UserDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := udo.Exec(ctx); err != nil {
|
||||
func (_d *UserDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := _d.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,44 +37,44 @@ type UserQuery struct {
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the UserQuery builder.
|
||||
func (uq *UserQuery) Where(ps ...predicate.User) *UserQuery {
|
||||
uq.predicates = append(uq.predicates, ps...)
|
||||
return uq
|
||||
func (_q *UserQuery) Where(ps ...predicate.User) *UserQuery {
|
||||
_q.predicates = append(_q.predicates, ps...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// Limit the number of records to be returned by this query.
|
||||
func (uq *UserQuery) Limit(limit int) *UserQuery {
|
||||
uq.ctx.Limit = &limit
|
||||
return uq
|
||||
func (_q *UserQuery) Limit(limit int) *UserQuery {
|
||||
_q.ctx.Limit = &limit
|
||||
return _q
|
||||
}
|
||||
|
||||
// Offset to start from.
|
||||
func (uq *UserQuery) Offset(offset int) *UserQuery {
|
||||
uq.ctx.Offset = &offset
|
||||
return uq
|
||||
func (_q *UserQuery) Offset(offset int) *UserQuery {
|
||||
_q.ctx.Offset = &offset
|
||||
return _q
|
||||
}
|
||||
|
||||
// Unique configures the query builder to filter duplicate records on query.
|
||||
// By default, unique is set to true, and can be disabled using this method.
|
||||
func (uq *UserQuery) Unique(unique bool) *UserQuery {
|
||||
uq.ctx.Unique = &unique
|
||||
return uq
|
||||
func (_q *UserQuery) Unique(unique bool) *UserQuery {
|
||||
_q.ctx.Unique = &unique
|
||||
return _q
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (uq *UserQuery) Order(o ...user.OrderOption) *UserQuery {
|
||||
uq.order = append(uq.order, o...)
|
||||
return uq
|
||||
func (_q *UserQuery) Order(o ...user.OrderOption) *UserQuery {
|
||||
_q.order = append(_q.order, o...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// QueryGroup chains the current query on the "group" edge.
|
||||
func (uq *UserQuery) QueryGroup() *GroupQuery {
|
||||
query := (&GroupClient{config: uq.config}).Query()
|
||||
func (_q *UserQuery) QueryGroup() *GroupQuery {
|
||||
query := (&GroupClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := uq.prepareQuery(ctx); err != nil {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := uq.sqlQuery(ctx)
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -83,20 +83,20 @@ func (uq *UserQuery) QueryGroup() *GroupQuery {
|
||||
sqlgraph.To(group.Table, group.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, user.GroupTable, user.GroupColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(uq.driver.Dialect(), step)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryAuthTokens chains the current query on the "auth_tokens" edge.
|
||||
func (uq *UserQuery) QueryAuthTokens() *AuthTokensQuery {
|
||||
query := (&AuthTokensClient{config: uq.config}).Query()
|
||||
func (_q *UserQuery) QueryAuthTokens() *AuthTokensQuery {
|
||||
query := (&AuthTokensClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := uq.prepareQuery(ctx); err != nil {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := uq.sqlQuery(ctx)
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -105,20 +105,20 @@ func (uq *UserQuery) QueryAuthTokens() *AuthTokensQuery {
|
||||
sqlgraph.To(authtokens.Table, authtokens.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, user.AuthTokensTable, user.AuthTokensColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(uq.driver.Dialect(), step)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryNotifiers chains the current query on the "notifiers" edge.
|
||||
func (uq *UserQuery) QueryNotifiers() *NotifierQuery {
|
||||
query := (&NotifierClient{config: uq.config}).Query()
|
||||
func (_q *UserQuery) QueryNotifiers() *NotifierQuery {
|
||||
query := (&NotifierClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := uq.prepareQuery(ctx); err != nil {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := uq.sqlQuery(ctx)
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -127,7 +127,7 @@ func (uq *UserQuery) QueryNotifiers() *NotifierQuery {
|
||||
sqlgraph.To(notifier.Table, notifier.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, user.NotifiersTable, user.NotifiersColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(uq.driver.Dialect(), step)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
@@ -135,8 +135,8 @@ func (uq *UserQuery) QueryNotifiers() *NotifierQuery {
|
||||
|
||||
// First returns the first User entity from the query.
|
||||
// Returns a *NotFoundError when no User was found.
|
||||
func (uq *UserQuery) First(ctx context.Context) (*User, error) {
|
||||
nodes, err := uq.Limit(1).All(setContextOp(ctx, uq.ctx, ent.OpQueryFirst))
|
||||
func (_q *UserQuery) First(ctx context.Context) (*User, error) {
|
||||
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -147,8 +147,8 @@ func (uq *UserQuery) First(ctx context.Context) (*User, error) {
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (uq *UserQuery) FirstX(ctx context.Context) *User {
|
||||
node, err := uq.First(ctx)
|
||||
func (_q *UserQuery) FirstX(ctx context.Context) *User {
|
||||
node, err := _q.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
@@ -157,9 +157,9 @@ func (uq *UserQuery) FirstX(ctx context.Context) *User {
|
||||
|
||||
// FirstID returns the first User ID from the query.
|
||||
// Returns a *NotFoundError when no User ID was found.
|
||||
func (uq *UserQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
func (_q *UserQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
var ids []uuid.UUID
|
||||
if ids, err = uq.Limit(1).IDs(setContextOp(ctx, uq.ctx, ent.OpQueryFirstID)); err != nil {
|
||||
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
@@ -170,8 +170,8 @@ func (uq *UserQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (uq *UserQuery) FirstIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := uq.FirstID(ctx)
|
||||
func (_q *UserQuery) FirstIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := _q.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
@@ -181,8 +181,8 @@ func (uq *UserQuery) FirstIDX(ctx context.Context) uuid.UUID {
|
||||
// Only returns a single User entity found by the query, ensuring it only returns one.
|
||||
// Returns a *NotSingularError when more than one User entity is found.
|
||||
// Returns a *NotFoundError when no User entities are found.
|
||||
func (uq *UserQuery) Only(ctx context.Context) (*User, error) {
|
||||
nodes, err := uq.Limit(2).All(setContextOp(ctx, uq.ctx, ent.OpQueryOnly))
|
||||
func (_q *UserQuery) Only(ctx context.Context) (*User, error) {
|
||||
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -197,8 +197,8 @@ func (uq *UserQuery) Only(ctx context.Context) (*User, error) {
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (uq *UserQuery) OnlyX(ctx context.Context) *User {
|
||||
node, err := uq.Only(ctx)
|
||||
func (_q *UserQuery) OnlyX(ctx context.Context) *User {
|
||||
node, err := _q.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -208,9 +208,9 @@ func (uq *UserQuery) OnlyX(ctx context.Context) *User {
|
||||
// OnlyID is like Only, but returns the only User ID in the query.
|
||||
// Returns a *NotSingularError when more than one User ID is found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (uq *UserQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
func (_q *UserQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
var ids []uuid.UUID
|
||||
if ids, err = uq.Limit(2).IDs(setContextOp(ctx, uq.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
@@ -225,8 +225,8 @@ func (uq *UserQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (uq *UserQuery) OnlyIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := uq.OnlyID(ctx)
|
||||
func (_q *UserQuery) OnlyIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := _q.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -234,18 +234,18 @@ func (uq *UserQuery) OnlyIDX(ctx context.Context) uuid.UUID {
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of Users.
|
||||
func (uq *UserQuery) All(ctx context.Context) ([]*User, error) {
|
||||
ctx = setContextOp(ctx, uq.ctx, ent.OpQueryAll)
|
||||
if err := uq.prepareQuery(ctx); err != nil {
|
||||
func (_q *UserQuery) All(ctx context.Context) ([]*User, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qr := querierAll[[]*User, *UserQuery]()
|
||||
return withInterceptors[[]*User](ctx, uq, qr, uq.inters)
|
||||
return withInterceptors[[]*User](ctx, _q, qr, _q.inters)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (uq *UserQuery) AllX(ctx context.Context) []*User {
|
||||
nodes, err := uq.All(ctx)
|
||||
func (_q *UserQuery) AllX(ctx context.Context) []*User {
|
||||
nodes, err := _q.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -253,20 +253,20 @@ func (uq *UserQuery) AllX(ctx context.Context) []*User {
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of User IDs.
|
||||
func (uq *UserQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
|
||||
if uq.ctx.Unique == nil && uq.path != nil {
|
||||
uq.Unique(true)
|
||||
func (_q *UserQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
|
||||
if _q.ctx.Unique == nil && _q.path != nil {
|
||||
_q.Unique(true)
|
||||
}
|
||||
ctx = setContextOp(ctx, uq.ctx, ent.OpQueryIDs)
|
||||
if err = uq.Select(user.FieldID).Scan(ctx, &ids); err != nil {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
|
||||
if err = _q.Select(user.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (uq *UserQuery) IDsX(ctx context.Context) []uuid.UUID {
|
||||
ids, err := uq.IDs(ctx)
|
||||
func (_q *UserQuery) IDsX(ctx context.Context) []uuid.UUID {
|
||||
ids, err := _q.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -274,17 +274,17 @@ func (uq *UserQuery) IDsX(ctx context.Context) []uuid.UUID {
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (uq *UserQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, uq.ctx, ent.OpQueryCount)
|
||||
if err := uq.prepareQuery(ctx); err != nil {
|
||||
func (_q *UserQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return withInterceptors[int](ctx, uq, querierCount[*UserQuery](), uq.inters)
|
||||
return withInterceptors[int](ctx, _q, querierCount[*UserQuery](), _q.inters)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (uq *UserQuery) CountX(ctx context.Context) int {
|
||||
count, err := uq.Count(ctx)
|
||||
func (_q *UserQuery) CountX(ctx context.Context) int {
|
||||
count, err := _q.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -292,9 +292,9 @@ func (uq *UserQuery) CountX(ctx context.Context) int {
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (uq *UserQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, uq.ctx, ent.OpQueryExist)
|
||||
switch _, err := uq.FirstID(ctx); {
|
||||
func (_q *UserQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
|
||||
switch _, err := _q.FirstID(ctx); {
|
||||
case IsNotFound(err):
|
||||
return false, nil
|
||||
case err != nil:
|
||||
@@ -305,8 +305,8 @@ func (uq *UserQuery) Exist(ctx context.Context) (bool, error) {
|
||||
}
|
||||
|
||||
// ExistX is like Exist, but panics if an error occurs.
|
||||
func (uq *UserQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := uq.Exist(ctx)
|
||||
func (_q *UserQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := _q.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -315,56 +315,56 @@ func (uq *UserQuery) ExistX(ctx context.Context) bool {
|
||||
|
||||
// Clone returns a duplicate of the UserQuery builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (uq *UserQuery) Clone() *UserQuery {
|
||||
if uq == nil {
|
||||
func (_q *UserQuery) Clone() *UserQuery {
|
||||
if _q == nil {
|
||||
return nil
|
||||
}
|
||||
return &UserQuery{
|
||||
config: uq.config,
|
||||
ctx: uq.ctx.Clone(),
|
||||
order: append([]user.OrderOption{}, uq.order...),
|
||||
inters: append([]Interceptor{}, uq.inters...),
|
||||
predicates: append([]predicate.User{}, uq.predicates...),
|
||||
withGroup: uq.withGroup.Clone(),
|
||||
withAuthTokens: uq.withAuthTokens.Clone(),
|
||||
withNotifiers: uq.withNotifiers.Clone(),
|
||||
config: _q.config,
|
||||
ctx: _q.ctx.Clone(),
|
||||
order: append([]user.OrderOption{}, _q.order...),
|
||||
inters: append([]Interceptor{}, _q.inters...),
|
||||
predicates: append([]predicate.User{}, _q.predicates...),
|
||||
withGroup: _q.withGroup.Clone(),
|
||||
withAuthTokens: _q.withAuthTokens.Clone(),
|
||||
withNotifiers: _q.withNotifiers.Clone(),
|
||||
// clone intermediate query.
|
||||
sql: uq.sql.Clone(),
|
||||
path: uq.path,
|
||||
sql: _q.sql.Clone(),
|
||||
path: _q.path,
|
||||
}
|
||||
}
|
||||
|
||||
// WithGroup tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "group" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (uq *UserQuery) WithGroup(opts ...func(*GroupQuery)) *UserQuery {
|
||||
query := (&GroupClient{config: uq.config}).Query()
|
||||
func (_q *UserQuery) WithGroup(opts ...func(*GroupQuery)) *UserQuery {
|
||||
query := (&GroupClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
uq.withGroup = query
|
||||
return uq
|
||||
_q.withGroup = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// WithAuthTokens tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "auth_tokens" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (uq *UserQuery) WithAuthTokens(opts ...func(*AuthTokensQuery)) *UserQuery {
|
||||
query := (&AuthTokensClient{config: uq.config}).Query()
|
||||
func (_q *UserQuery) WithAuthTokens(opts ...func(*AuthTokensQuery)) *UserQuery {
|
||||
query := (&AuthTokensClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
uq.withAuthTokens = query
|
||||
return uq
|
||||
_q.withAuthTokens = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// WithNotifiers tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "notifiers" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (uq *UserQuery) WithNotifiers(opts ...func(*NotifierQuery)) *UserQuery {
|
||||
query := (&NotifierClient{config: uq.config}).Query()
|
||||
func (_q *UserQuery) WithNotifiers(opts ...func(*NotifierQuery)) *UserQuery {
|
||||
query := (&NotifierClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
uq.withNotifiers = query
|
||||
return uq
|
||||
_q.withNotifiers = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// GroupBy is used to group vertices by one or more fields/columns.
|
||||
@@ -381,10 +381,10 @@ func (uq *UserQuery) WithNotifiers(opts ...func(*NotifierQuery)) *UserQuery {
|
||||
// GroupBy(user.FieldCreatedAt).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (uq *UserQuery) GroupBy(field string, fields ...string) *UserGroupBy {
|
||||
uq.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &UserGroupBy{build: uq}
|
||||
grbuild.flds = &uq.ctx.Fields
|
||||
func (_q *UserQuery) GroupBy(field string, fields ...string) *UserGroupBy {
|
||||
_q.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &UserGroupBy{build: _q}
|
||||
grbuild.flds = &_q.ctx.Fields
|
||||
grbuild.label = user.Label
|
||||
grbuild.scan = grbuild.Scan
|
||||
return grbuild
|
||||
@@ -402,57 +402,57 @@ func (uq *UserQuery) GroupBy(field string, fields ...string) *UserGroupBy {
|
||||
// client.User.Query().
|
||||
// Select(user.FieldCreatedAt).
|
||||
// Scan(ctx, &v)
|
||||
func (uq *UserQuery) Select(fields ...string) *UserSelect {
|
||||
uq.ctx.Fields = append(uq.ctx.Fields, fields...)
|
||||
sbuild := &UserSelect{UserQuery: uq}
|
||||
func (_q *UserQuery) Select(fields ...string) *UserSelect {
|
||||
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
||||
sbuild := &UserSelect{UserQuery: _q}
|
||||
sbuild.label = user.Label
|
||||
sbuild.flds, sbuild.scan = &uq.ctx.Fields, sbuild.Scan
|
||||
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
|
||||
return sbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a UserSelect configured with the given aggregations.
|
||||
func (uq *UserQuery) Aggregate(fns ...AggregateFunc) *UserSelect {
|
||||
return uq.Select().Aggregate(fns...)
|
||||
func (_q *UserQuery) Aggregate(fns ...AggregateFunc) *UserSelect {
|
||||
return _q.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (uq *UserQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range uq.inters {
|
||||
func (_q *UserQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range _q.inters {
|
||||
if inter == nil {
|
||||
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
|
||||
}
|
||||
if trv, ok := inter.(Traverser); ok {
|
||||
if err := trv.Traverse(ctx, uq); err != nil {
|
||||
if err := trv.Traverse(ctx, _q); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, f := range uq.ctx.Fields {
|
||||
for _, f := range _q.ctx.Fields {
|
||||
if !user.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
}
|
||||
if uq.path != nil {
|
||||
prev, err := uq.path(ctx)
|
||||
if _q.path != nil {
|
||||
prev, err := _q.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
uq.sql = prev
|
||||
_q.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (uq *UserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*User, error) {
|
||||
func (_q *UserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*User, error) {
|
||||
var (
|
||||
nodes = []*User{}
|
||||
withFKs = uq.withFKs
|
||||
_spec = uq.querySpec()
|
||||
withFKs = _q.withFKs
|
||||
_spec = _q.querySpec()
|
||||
loadedTypes = [3]bool{
|
||||
uq.withGroup != nil,
|
||||
uq.withAuthTokens != nil,
|
||||
uq.withNotifiers != nil,
|
||||
_q.withGroup != nil,
|
||||
_q.withAuthTokens != nil,
|
||||
_q.withNotifiers != nil,
|
||||
}
|
||||
)
|
||||
if uq.withGroup != nil {
|
||||
if _q.withGroup != nil {
|
||||
withFKs = true
|
||||
}
|
||||
if withFKs {
|
||||
@@ -462,7 +462,7 @@ func (uq *UserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*User, e
|
||||
return (*User).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &User{config: uq.config}
|
||||
node := &User{config: _q.config}
|
||||
nodes = append(nodes, node)
|
||||
node.Edges.loadedTypes = loadedTypes
|
||||
return node.assignValues(columns, values)
|
||||
@@ -470,27 +470,27 @@ func (uq *UserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*User, e
|
||||
for i := range hooks {
|
||||
hooks[i](ctx, _spec)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, uq.driver, _spec); err != nil {
|
||||
if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
if query := uq.withGroup; query != nil {
|
||||
if err := uq.loadGroup(ctx, query, nodes, nil,
|
||||
if query := _q.withGroup; query != nil {
|
||||
if err := _q.loadGroup(ctx, query, nodes, nil,
|
||||
func(n *User, e *Group) { n.Edges.Group = e }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if query := uq.withAuthTokens; query != nil {
|
||||
if err := uq.loadAuthTokens(ctx, query, nodes,
|
||||
if query := _q.withAuthTokens; query != nil {
|
||||
if err := _q.loadAuthTokens(ctx, query, nodes,
|
||||
func(n *User) { n.Edges.AuthTokens = []*AuthTokens{} },
|
||||
func(n *User, e *AuthTokens) { n.Edges.AuthTokens = append(n.Edges.AuthTokens, e) }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if query := uq.withNotifiers; query != nil {
|
||||
if err := uq.loadNotifiers(ctx, query, nodes,
|
||||
if query := _q.withNotifiers; query != nil {
|
||||
if err := _q.loadNotifiers(ctx, query, nodes,
|
||||
func(n *User) { n.Edges.Notifiers = []*Notifier{} },
|
||||
func(n *User, e *Notifier) { n.Edges.Notifiers = append(n.Edges.Notifiers, e) }); err != nil {
|
||||
return nil, err
|
||||
@@ -499,7 +499,7 @@ func (uq *UserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*User, e
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (uq *UserQuery) loadGroup(ctx context.Context, query *GroupQuery, nodes []*User, init func(*User), assign func(*User, *Group)) error {
|
||||
func (_q *UserQuery) loadGroup(ctx context.Context, query *GroupQuery, nodes []*User, init func(*User), assign func(*User, *Group)) error {
|
||||
ids := make([]uuid.UUID, 0, len(nodes))
|
||||
nodeids := make(map[uuid.UUID][]*User)
|
||||
for i := range nodes {
|
||||
@@ -531,7 +531,7 @@ func (uq *UserQuery) loadGroup(ctx context.Context, query *GroupQuery, nodes []*
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (uq *UserQuery) loadAuthTokens(ctx context.Context, query *AuthTokensQuery, nodes []*User, init func(*User), assign func(*User, *AuthTokens)) error {
|
||||
func (_q *UserQuery) loadAuthTokens(ctx context.Context, query *AuthTokensQuery, nodes []*User, init func(*User), assign func(*User, *AuthTokens)) error {
|
||||
fks := make([]driver.Value, 0, len(nodes))
|
||||
nodeids := make(map[uuid.UUID]*User)
|
||||
for i := range nodes {
|
||||
@@ -562,7 +562,7 @@ func (uq *UserQuery) loadAuthTokens(ctx context.Context, query *AuthTokensQuery,
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (uq *UserQuery) loadNotifiers(ctx context.Context, query *NotifierQuery, nodes []*User, init func(*User), assign func(*User, *Notifier)) error {
|
||||
func (_q *UserQuery) loadNotifiers(ctx context.Context, query *NotifierQuery, nodes []*User, init func(*User), assign func(*User, *Notifier)) error {
|
||||
fks := make([]driver.Value, 0, len(nodes))
|
||||
nodeids := make(map[uuid.UUID]*User)
|
||||
for i := range nodes {
|
||||
@@ -593,24 +593,24 @@ func (uq *UserQuery) loadNotifiers(ctx context.Context, query *NotifierQuery, no
|
||||
return nil
|
||||
}
|
||||
|
||||
func (uq *UserQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := uq.querySpec()
|
||||
_spec.Node.Columns = uq.ctx.Fields
|
||||
if len(uq.ctx.Fields) > 0 {
|
||||
_spec.Unique = uq.ctx.Unique != nil && *uq.ctx.Unique
|
||||
func (_q *UserQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := _q.querySpec()
|
||||
_spec.Node.Columns = _q.ctx.Fields
|
||||
if len(_q.ctx.Fields) > 0 {
|
||||
_spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, uq.driver, _spec)
|
||||
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
|
||||
}
|
||||
|
||||
func (uq *UserQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
func (_q *UserQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := sqlgraph.NewQuerySpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID))
|
||||
_spec.From = uq.sql
|
||||
if unique := uq.ctx.Unique; unique != nil {
|
||||
_spec.From = _q.sql
|
||||
if unique := _q.ctx.Unique; unique != nil {
|
||||
_spec.Unique = *unique
|
||||
} else if uq.path != nil {
|
||||
} else if _q.path != nil {
|
||||
_spec.Unique = true
|
||||
}
|
||||
if fields := uq.ctx.Fields; len(fields) > 0 {
|
||||
if fields := _q.ctx.Fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, user.FieldID)
|
||||
for i := range fields {
|
||||
@@ -619,20 +619,20 @@ func (uq *UserQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := uq.predicates; len(ps) > 0 {
|
||||
if ps := _q.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := uq.ctx.Limit; limit != nil {
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := uq.ctx.Offset; offset != nil {
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := uq.order; len(ps) > 0 {
|
||||
if ps := _q.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
@@ -642,33 +642,33 @@ func (uq *UserQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (uq *UserQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(uq.driver.Dialect())
|
||||
func (_q *UserQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(_q.driver.Dialect())
|
||||
t1 := builder.Table(user.Table)
|
||||
columns := uq.ctx.Fields
|
||||
columns := _q.ctx.Fields
|
||||
if len(columns) == 0 {
|
||||
columns = user.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if uq.sql != nil {
|
||||
selector = uq.sql
|
||||
if _q.sql != nil {
|
||||
selector = _q.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
if uq.ctx.Unique != nil && *uq.ctx.Unique {
|
||||
if _q.ctx.Unique != nil && *_q.ctx.Unique {
|
||||
selector.Distinct()
|
||||
}
|
||||
for _, p := range uq.predicates {
|
||||
for _, p := range _q.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range uq.order {
|
||||
for _, p := range _q.order {
|
||||
p(selector)
|
||||
}
|
||||
if offset := uq.ctx.Offset; offset != nil {
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
// limit is mandatory for offset clause. We start
|
||||
// with default value, and override it below if needed.
|
||||
selector.Offset(*offset).Limit(math.MaxInt32)
|
||||
}
|
||||
if limit := uq.ctx.Limit; limit != nil {
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
@@ -681,41 +681,41 @@ type UserGroupBy struct {
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (ugb *UserGroupBy) Aggregate(fns ...AggregateFunc) *UserGroupBy {
|
||||
ugb.fns = append(ugb.fns, fns...)
|
||||
return ugb
|
||||
func (_g *UserGroupBy) Aggregate(fns ...AggregateFunc) *UserGroupBy {
|
||||
_g.fns = append(_g.fns, fns...)
|
||||
return _g
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (ugb *UserGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, ugb.build.ctx, ent.OpQueryGroupBy)
|
||||
if err := ugb.build.prepareQuery(ctx); err != nil {
|
||||
func (_g *UserGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
|
||||
if err := _g.build.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*UserQuery, *UserGroupBy](ctx, ugb.build, ugb, ugb.build.inters, v)
|
||||
return scanWithInterceptors[*UserQuery, *UserGroupBy](ctx, _g.build, _g, _g.build.inters, v)
|
||||
}
|
||||
|
||||
func (ugb *UserGroupBy) sqlScan(ctx context.Context, root *UserQuery, v any) error {
|
||||
func (_g *UserGroupBy) sqlScan(ctx context.Context, root *UserQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx).Select()
|
||||
aggregation := make([]string, 0, len(ugb.fns))
|
||||
for _, fn := range ugb.fns {
|
||||
aggregation := make([]string, 0, len(_g.fns))
|
||||
for _, fn := range _g.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(*ugb.flds)+len(ugb.fns))
|
||||
for _, f := range *ugb.flds {
|
||||
columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
|
||||
for _, f := range *_g.flds {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
columns = append(columns, aggregation...)
|
||||
selector.Select(columns...)
|
||||
}
|
||||
selector.GroupBy(selector.Columns(*ugb.flds...)...)
|
||||
selector.GroupBy(selector.Columns(*_g.flds...)...)
|
||||
if err := selector.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := ugb.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
@@ -729,27 +729,27 @@ type UserSelect struct {
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (us *UserSelect) Aggregate(fns ...AggregateFunc) *UserSelect {
|
||||
us.fns = append(us.fns, fns...)
|
||||
return us
|
||||
func (_s *UserSelect) Aggregate(fns ...AggregateFunc) *UserSelect {
|
||||
_s.fns = append(_s.fns, fns...)
|
||||
return _s
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (us *UserSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, us.ctx, ent.OpQuerySelect)
|
||||
if err := us.prepareQuery(ctx); err != nil {
|
||||
func (_s *UserSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
|
||||
if err := _s.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*UserQuery, *UserSelect](ctx, us.UserQuery, us, us.inters, v)
|
||||
return scanWithInterceptors[*UserQuery, *UserSelect](ctx, _s.UserQuery, _s, _s.inters, v)
|
||||
}
|
||||
|
||||
func (us *UserSelect) sqlScan(ctx context.Context, root *UserQuery, v any) error {
|
||||
func (_s *UserSelect) sqlScan(ctx context.Context, root *UserQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx)
|
||||
aggregation := make([]string, 0, len(us.fns))
|
||||
for _, fn := range us.fns {
|
||||
aggregation := make([]string, 0, len(_s.fns))
|
||||
for _, fn := range _s.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
switch n := len(*us.selector.flds); {
|
||||
switch n := len(*_s.selector.flds); {
|
||||
case n == 0 && len(aggregation) > 0:
|
||||
selector.Select(aggregation...)
|
||||
case n != 0 && len(aggregation) > 0:
|
||||
@@ -757,7 +757,7 @@ func (us *UserSelect) sqlScan(ctx context.Context, root *UserQuery, v any) error
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := us.driver.Query(ctx, query, args, rows); err != nil {
|
||||
if err := _s.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -5,7 +5,9 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entitytype"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/core/services/reporting/eventbus"
|
||||
@@ -1037,7 +1039,7 @@ func (e *ItemsRepository) Duplicate(ctx context.Context, gid, id uuid.UUID, opti
|
||||
}()
|
||||
|
||||
// Get the original item with all its data
|
||||
originalItem, err := e.getOne(ctx, item.ID(id), item.HasGroupWith(group.ID(gid)))
|
||||
originalItem, err := e.getOne(ctx, entity.ID(id), entity.HasGroupWith(group.ID(gid)))
|
||||
if err != nil {
|
||||
return ItemOut{}, err
|
||||
}
|
||||
@@ -1055,7 +1057,7 @@ func (e *ItemsRepository) Duplicate(ctx context.Context, gid, id uuid.UUID, opti
|
||||
|
||||
// Create the new item directly in the transaction
|
||||
newItemID := uuid.New()
|
||||
itemBuilder := tx.Item.Create().
|
||||
itemBuilder := tx.Entity.Create().
|
||||
SetID(newItemID).
|
||||
SetName(options.CopyPrefix + originalItem.Name).
|
||||
SetDescription(originalItem.Description).
|
||||
@@ -1079,7 +1081,7 @@ func (e *ItemsRepository) Duplicate(ctx context.Context, gid, id uuid.UUID, opti
|
||||
SetNotes(originalItem.Notes).
|
||||
SetInsured(originalItem.Insured).
|
||||
SetArchived(originalItem.Archived).
|
||||
SetSyncChildItemsLocations(originalItem.SyncChildItemsLocations)
|
||||
SetSyncChildEntitiesLocations(originalItem.SyncChildItemsLocations)
|
||||
|
||||
if originalItem.Parent != nil {
|
||||
itemBuilder.SetParentID(originalItem.Parent.ID)
|
||||
@@ -1102,9 +1104,9 @@ func (e *ItemsRepository) Duplicate(ctx context.Context, gid, id uuid.UUID, opti
|
||||
// Copy custom fields if requested
|
||||
if options.CopyCustomFields {
|
||||
for _, field := range originalItem.Fields {
|
||||
_, err = tx.ItemField.Create().
|
||||
SetItemID(newItemID).
|
||||
SetType(itemfield.Type(field.Type)).
|
||||
_, err = tx.EntityField.Create().
|
||||
SetEntityID(newItemID).
|
||||
SetType(entityfield.Type(field.Type)).
|
||||
SetName(field.Name).
|
||||
SetTextValue(field.TextValue).
|
||||
SetNumberValue(field.NumberValue).
|
||||
@@ -1133,7 +1135,7 @@ func (e *ItemsRepository) Duplicate(ctx context.Context, gid, id uuid.UUID, opti
|
||||
// Create a copy of the attachment with the same file path
|
||||
// Since files are stored with hash-based paths, this is safe
|
||||
_, err = tx.Attachment.Create().
|
||||
SetItemID(newItemID).
|
||||
SetEntityID(newItemID).
|
||||
SetType(originalAttachment.Type).
|
||||
SetTitle(originalAttachment.Title).
|
||||
SetPath(originalAttachment.Path).
|
||||
@@ -1150,12 +1152,12 @@ func (e *ItemsRepository) Duplicate(ctx context.Context, gid, id uuid.UUID, opti
|
||||
// Copy maintenance entries if requested
|
||||
if options.CopyMaintenance {
|
||||
maintenanceEntries, err := tx.MaintenanceEntry.Query().
|
||||
Where(maintenanceentry.HasItemWith(item.ID(id))).
|
||||
Where(maintenanceentry.HasEntityWith(entity.ID(id))).
|
||||
All(ctx)
|
||||
if err == nil {
|
||||
for _, entry := range maintenanceEntries {
|
||||
_, err = tx.MaintenanceEntry.Create().
|
||||
SetItemID(newItemID).
|
||||
SetEntityID(newItemID).
|
||||
SetDate(entry.Date).
|
||||
SetScheduledDate(entry.ScheduledDate).
|
||||
SetName(entry.Name).
|
||||
|
||||
Reference in New Issue
Block a user