deps: use ent 0.14.2 (#3259)

This commit is contained in:
mmetc 2025-02-18 17:08:58 +01:00 committed by GitHub
parent 7c1d038645
commit efbb42bf9e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 132 additions and 120 deletions

View file

@ -8,6 +8,7 @@ import (
"fmt"
"math"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
@ -158,7 +159,7 @@ func (aq *AlertQuery) QueryMetas() *MetaQuery {
// First returns the first Alert entity from the query.
// Returns a *NotFoundError when no Alert was found.
func (aq *AlertQuery) First(ctx context.Context) (*Alert, error) {
nodes, err := aq.Limit(1).All(setContextOp(ctx, aq.ctx, "First"))
nodes, err := aq.Limit(1).All(setContextOp(ctx, aq.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
@ -181,7 +182,7 @@ func (aq *AlertQuery) FirstX(ctx context.Context) *Alert {
// Returns a *NotFoundError when no Alert ID was found.
func (aq *AlertQuery) FirstID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = aq.Limit(1).IDs(setContextOp(ctx, aq.ctx, "FirstID")); err != nil {
if ids, err = aq.Limit(1).IDs(setContextOp(ctx, aq.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
@ -204,7 +205,7 @@ func (aq *AlertQuery) FirstIDX(ctx context.Context) int {
// Returns a *NotSingularError when more than one Alert entity is found.
// Returns a *NotFoundError when no Alert entities are found.
func (aq *AlertQuery) Only(ctx context.Context) (*Alert, error) {
nodes, err := aq.Limit(2).All(setContextOp(ctx, aq.ctx, "Only"))
nodes, err := aq.Limit(2).All(setContextOp(ctx, aq.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
@ -232,7 +233,7 @@ func (aq *AlertQuery) OnlyX(ctx context.Context) *Alert {
// Returns a *NotFoundError when no entities are found.
func (aq *AlertQuery) OnlyID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = aq.Limit(2).IDs(setContextOp(ctx, aq.ctx, "OnlyID")); err != nil {
if ids, err = aq.Limit(2).IDs(setContextOp(ctx, aq.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
@ -257,7 +258,7 @@ func (aq *AlertQuery) OnlyIDX(ctx context.Context) int {
// All executes the query and returns a list of Alerts.
func (aq *AlertQuery) All(ctx context.Context) ([]*Alert, error) {
ctx = setContextOp(ctx, aq.ctx, "All")
ctx = setContextOp(ctx, aq.ctx, ent.OpQueryAll)
if err := aq.prepareQuery(ctx); err != nil {
return nil, err
}
@ -279,7 +280,7 @@ func (aq *AlertQuery) IDs(ctx context.Context) (ids []int, err error) {
if aq.ctx.Unique == nil && aq.path != nil {
aq.Unique(true)
}
ctx = setContextOp(ctx, aq.ctx, "IDs")
ctx = setContextOp(ctx, aq.ctx, ent.OpQueryIDs)
if err = aq.Select(alert.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
@ -297,7 +298,7 @@ func (aq *AlertQuery) IDsX(ctx context.Context) []int {
// Count returns the count of the given query.
func (aq *AlertQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, aq.ctx, "Count")
ctx = setContextOp(ctx, aq.ctx, ent.OpQueryCount)
if err := aq.prepareQuery(ctx); err != nil {
return 0, err
}
@ -315,7 +316,7 @@ func (aq *AlertQuery) CountX(ctx context.Context) int {
// Exist returns true if the query has elements in the graph.
func (aq *AlertQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, aq.ctx, "Exist")
ctx = setContextOp(ctx, aq.ctx, ent.OpQueryExist)
switch _, err := aq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
@ -759,7 +760,7 @@ func (agb *AlertGroupBy) Aggregate(fns ...AggregateFunc) *AlertGroupBy {
// Scan applies the selector query and scans the result into the given value.
func (agb *AlertGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, agb.build.ctx, "GroupBy")
ctx = setContextOp(ctx, agb.build.ctx, ent.OpQueryGroupBy)
if err := agb.build.prepareQuery(ctx); err != nil {
return err
}
@ -807,7 +808,7 @@ func (as *AlertSelect) Aggregate(fns ...AggregateFunc) *AlertSelect {
// Scan applies the selector query and scans the result into the given value.
func (as *AlertSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, as.ctx, "Select")
ctx = setContextOp(ctx, as.ctx, ent.OpQuerySelect)
if err := as.prepareQuery(ctx); err != nil {
return err
}

View file

@ -7,6 +7,7 @@ import (
"fmt"
"math"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
@ -60,7 +61,7 @@ func (bq *BouncerQuery) Order(o ...bouncer.OrderOption) *BouncerQuery {
// First returns the first Bouncer entity from the query.
// Returns a *NotFoundError when no Bouncer was found.
func (bq *BouncerQuery) First(ctx context.Context) (*Bouncer, error) {
nodes, err := bq.Limit(1).All(setContextOp(ctx, bq.ctx, "First"))
nodes, err := bq.Limit(1).All(setContextOp(ctx, bq.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
@ -83,7 +84,7 @@ func (bq *BouncerQuery) FirstX(ctx context.Context) *Bouncer {
// Returns a *NotFoundError when no Bouncer ID was found.
func (bq *BouncerQuery) FirstID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = bq.Limit(1).IDs(setContextOp(ctx, bq.ctx, "FirstID")); err != nil {
if ids, err = bq.Limit(1).IDs(setContextOp(ctx, bq.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
@ -106,7 +107,7 @@ func (bq *BouncerQuery) FirstIDX(ctx context.Context) int {
// Returns a *NotSingularError when more than one Bouncer entity is found.
// Returns a *NotFoundError when no Bouncer entities are found.
func (bq *BouncerQuery) Only(ctx context.Context) (*Bouncer, error) {
nodes, err := bq.Limit(2).All(setContextOp(ctx, bq.ctx, "Only"))
nodes, err := bq.Limit(2).All(setContextOp(ctx, bq.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
@ -134,7 +135,7 @@ func (bq *BouncerQuery) OnlyX(ctx context.Context) *Bouncer {
// Returns a *NotFoundError when no entities are found.
func (bq *BouncerQuery) OnlyID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = bq.Limit(2).IDs(setContextOp(ctx, bq.ctx, "OnlyID")); err != nil {
if ids, err = bq.Limit(2).IDs(setContextOp(ctx, bq.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
@ -159,7 +160,7 @@ func (bq *BouncerQuery) OnlyIDX(ctx context.Context) int {
// All executes the query and returns a list of Bouncers.
func (bq *BouncerQuery) All(ctx context.Context) ([]*Bouncer, error) {
ctx = setContextOp(ctx, bq.ctx, "All")
ctx = setContextOp(ctx, bq.ctx, ent.OpQueryAll)
if err := bq.prepareQuery(ctx); err != nil {
return nil, err
}
@ -181,7 +182,7 @@ func (bq *BouncerQuery) IDs(ctx context.Context) (ids []int, err error) {
if bq.ctx.Unique == nil && bq.path != nil {
bq.Unique(true)
}
ctx = setContextOp(ctx, bq.ctx, "IDs")
ctx = setContextOp(ctx, bq.ctx, ent.OpQueryIDs)
if err = bq.Select(bouncer.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
@ -199,7 +200,7 @@ func (bq *BouncerQuery) IDsX(ctx context.Context) []int {
// Count returns the count of the given query.
func (bq *BouncerQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, bq.ctx, "Count")
ctx = setContextOp(ctx, bq.ctx, ent.OpQueryCount)
if err := bq.prepareQuery(ctx); err != nil {
return 0, err
}
@ -217,7 +218,7 @@ func (bq *BouncerQuery) CountX(ctx context.Context) int {
// Exist returns true if the query has elements in the graph.
func (bq *BouncerQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, bq.ctx, "Exist")
ctx = setContextOp(ctx, bq.ctx, ent.OpQueryExist)
switch _, err := bq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
@ -449,7 +450,7 @@ func (bgb *BouncerGroupBy) Aggregate(fns ...AggregateFunc) *BouncerGroupBy {
// Scan applies the selector query and scans the result into the given value.
func (bgb *BouncerGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, bgb.build.ctx, "GroupBy")
ctx = setContextOp(ctx, bgb.build.ctx, ent.OpQueryGroupBy)
if err := bgb.build.prepareQuery(ctx); err != nil {
return err
}
@ -497,7 +498,7 @@ func (bs *BouncerSelect) Aggregate(fns ...AggregateFunc) *BouncerSelect {
// Scan applies the selector query and scans the result into the given value.
func (bs *BouncerSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, bs.ctx, "Select")
ctx = setContextOp(ctx, bs.ctx, ent.OpQuerySelect)
if err := bs.prepareQuery(ctx); err != nil {
return err
}

View file

@ -7,6 +7,7 @@ import (
"fmt"
"math"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
@ -60,7 +61,7 @@ func (ciq *ConfigItemQuery) Order(o ...configitem.OrderOption) *ConfigItemQuery
// First returns the first ConfigItem entity from the query.
// Returns a *NotFoundError when no ConfigItem was found.
func (ciq *ConfigItemQuery) First(ctx context.Context) (*ConfigItem, error) {
nodes, err := ciq.Limit(1).All(setContextOp(ctx, ciq.ctx, "First"))
nodes, err := ciq.Limit(1).All(setContextOp(ctx, ciq.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
@ -83,7 +84,7 @@ func (ciq *ConfigItemQuery) FirstX(ctx context.Context) *ConfigItem {
// Returns a *NotFoundError when no ConfigItem ID was found.
func (ciq *ConfigItemQuery) FirstID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = ciq.Limit(1).IDs(setContextOp(ctx, ciq.ctx, "FirstID")); err != nil {
if ids, err = ciq.Limit(1).IDs(setContextOp(ctx, ciq.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
@ -106,7 +107,7 @@ func (ciq *ConfigItemQuery) FirstIDX(ctx context.Context) int {
// Returns a *NotSingularError when more than one ConfigItem entity is found.
// Returns a *NotFoundError when no ConfigItem entities are found.
func (ciq *ConfigItemQuery) Only(ctx context.Context) (*ConfigItem, error) {
nodes, err := ciq.Limit(2).All(setContextOp(ctx, ciq.ctx, "Only"))
nodes, err := ciq.Limit(2).All(setContextOp(ctx, ciq.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
@ -134,7 +135,7 @@ func (ciq *ConfigItemQuery) OnlyX(ctx context.Context) *ConfigItem {
// Returns a *NotFoundError when no entities are found.
func (ciq *ConfigItemQuery) OnlyID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = ciq.Limit(2).IDs(setContextOp(ctx, ciq.ctx, "OnlyID")); err != nil {
if ids, err = ciq.Limit(2).IDs(setContextOp(ctx, ciq.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
@ -159,7 +160,7 @@ func (ciq *ConfigItemQuery) OnlyIDX(ctx context.Context) int {
// All executes the query and returns a list of ConfigItems.
func (ciq *ConfigItemQuery) All(ctx context.Context) ([]*ConfigItem, error) {
ctx = setContextOp(ctx, ciq.ctx, "All")
ctx = setContextOp(ctx, ciq.ctx, ent.OpQueryAll)
if err := ciq.prepareQuery(ctx); err != nil {
return nil, err
}
@ -181,7 +182,7 @@ func (ciq *ConfigItemQuery) IDs(ctx context.Context) (ids []int, err error) {
if ciq.ctx.Unique == nil && ciq.path != nil {
ciq.Unique(true)
}
ctx = setContextOp(ctx, ciq.ctx, "IDs")
ctx = setContextOp(ctx, ciq.ctx, ent.OpQueryIDs)
if err = ciq.Select(configitem.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
@ -199,7 +200,7 @@ func (ciq *ConfigItemQuery) IDsX(ctx context.Context) []int {
// Count returns the count of the given query.
func (ciq *ConfigItemQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, ciq.ctx, "Count")
ctx = setContextOp(ctx, ciq.ctx, ent.OpQueryCount)
if err := ciq.prepareQuery(ctx); err != nil {
return 0, err
}
@ -217,7 +218,7 @@ func (ciq *ConfigItemQuery) CountX(ctx context.Context) int {
// Exist returns true if the query has elements in the graph.
func (ciq *ConfigItemQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, ciq.ctx, "Exist")
ctx = setContextOp(ctx, ciq.ctx, ent.OpQueryExist)
switch _, err := ciq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
@ -449,7 +450,7 @@ func (cigb *ConfigItemGroupBy) Aggregate(fns ...AggregateFunc) *ConfigItemGroupB
// Scan applies the selector query and scans the result into the given value.
func (cigb *ConfigItemGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, cigb.build.ctx, "GroupBy")
ctx = setContextOp(ctx, cigb.build.ctx, ent.OpQueryGroupBy)
if err := cigb.build.prepareQuery(ctx); err != nil {
return err
}
@ -497,7 +498,7 @@ func (cis *ConfigItemSelect) Aggregate(fns ...AggregateFunc) *ConfigItemSelect {
// Scan applies the selector query and scans the result into the given value.
func (cis *ConfigItemSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, cis.ctx, "Select")
ctx = setContextOp(ctx, cis.ctx, ent.OpQuerySelect)
if err := cis.prepareQuery(ctx); err != nil {
return err
}

View file

@ -7,6 +7,7 @@ import (
"fmt"
"math"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
@ -84,7 +85,7 @@ func (dq *DecisionQuery) QueryOwner() *AlertQuery {
// First returns the first Decision entity from the query.
// Returns a *NotFoundError when no Decision was found.
func (dq *DecisionQuery) First(ctx context.Context) (*Decision, error) {
nodes, err := dq.Limit(1).All(setContextOp(ctx, dq.ctx, "First"))
nodes, err := dq.Limit(1).All(setContextOp(ctx, dq.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
@ -107,7 +108,7 @@ func (dq *DecisionQuery) FirstX(ctx context.Context) *Decision {
// Returns a *NotFoundError when no Decision ID was found.
func (dq *DecisionQuery) FirstID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = dq.Limit(1).IDs(setContextOp(ctx, dq.ctx, "FirstID")); err != nil {
if ids, err = dq.Limit(1).IDs(setContextOp(ctx, dq.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
@ -130,7 +131,7 @@ func (dq *DecisionQuery) FirstIDX(ctx context.Context) int {
// Returns a *NotSingularError when more than one Decision entity is found.
// Returns a *NotFoundError when no Decision entities are found.
func (dq *DecisionQuery) Only(ctx context.Context) (*Decision, error) {
nodes, err := dq.Limit(2).All(setContextOp(ctx, dq.ctx, "Only"))
nodes, err := dq.Limit(2).All(setContextOp(ctx, dq.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
@ -158,7 +159,7 @@ func (dq *DecisionQuery) OnlyX(ctx context.Context) *Decision {
// Returns a *NotFoundError when no entities are found.
func (dq *DecisionQuery) OnlyID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = dq.Limit(2).IDs(setContextOp(ctx, dq.ctx, "OnlyID")); err != nil {
if ids, err = dq.Limit(2).IDs(setContextOp(ctx, dq.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
@ -183,7 +184,7 @@ func (dq *DecisionQuery) OnlyIDX(ctx context.Context) int {
// All executes the query and returns a list of Decisions.
func (dq *DecisionQuery) All(ctx context.Context) ([]*Decision, error) {
ctx = setContextOp(ctx, dq.ctx, "All")
ctx = setContextOp(ctx, dq.ctx, ent.OpQueryAll)
if err := dq.prepareQuery(ctx); err != nil {
return nil, err
}
@ -205,7 +206,7 @@ func (dq *DecisionQuery) IDs(ctx context.Context) (ids []int, err error) {
if dq.ctx.Unique == nil && dq.path != nil {
dq.Unique(true)
}
ctx = setContextOp(ctx, dq.ctx, "IDs")
ctx = setContextOp(ctx, dq.ctx, ent.OpQueryIDs)
if err = dq.Select(decision.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
@ -223,7 +224,7 @@ func (dq *DecisionQuery) IDsX(ctx context.Context) []int {
// Count returns the count of the given query.
func (dq *DecisionQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, dq.ctx, "Count")
ctx = setContextOp(ctx, dq.ctx, ent.OpQueryCount)
if err := dq.prepareQuery(ctx); err != nil {
return 0, err
}
@ -241,7 +242,7 @@ func (dq *DecisionQuery) CountX(ctx context.Context) int {
// Exist returns true if the query has elements in the graph.
func (dq *DecisionQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, dq.ctx, "Exist")
ctx = setContextOp(ctx, dq.ctx, ent.OpQueryExist)
switch _, err := dq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
@ -528,7 +529,7 @@ func (dgb *DecisionGroupBy) Aggregate(fns ...AggregateFunc) *DecisionGroupBy {
// Scan applies the selector query and scans the result into the given value.
func (dgb *DecisionGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, dgb.build.ctx, "GroupBy")
ctx = setContextOp(ctx, dgb.build.ctx, ent.OpQueryGroupBy)
if err := dgb.build.prepareQuery(ctx); err != nil {
return err
}
@ -576,7 +577,7 @@ func (ds *DecisionSelect) Aggregate(fns ...AggregateFunc) *DecisionSelect {
// Scan applies the selector query and scans the result into the given value.
func (ds *DecisionSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, ds.ctx, "Select")
ctx = setContextOp(ctx, ds.ctx, ent.OpQuerySelect)
if err := ds.prepareQuery(ctx); err != nil {
return err
}

View file

@ -77,7 +77,7 @@ var (
columnCheck sql.ColumnCheck
)
// columnChecker checks if the column exists in the given table.
// checkColumn checks if the column exists in the given table.
func checkColumn(table, column string) error {
initCheck.Do(func() {
columnCheck = sql.NewColumnCheck(map[string]func(string) bool{

View file

@ -7,6 +7,7 @@ import (
"fmt"
"math"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
@ -84,7 +85,7 @@ func (eq *EventQuery) QueryOwner() *AlertQuery {
// First returns the first Event entity from the query.
// Returns a *NotFoundError when no Event was found.
func (eq *EventQuery) First(ctx context.Context) (*Event, error) {
nodes, err := eq.Limit(1).All(setContextOp(ctx, eq.ctx, "First"))
nodes, err := eq.Limit(1).All(setContextOp(ctx, eq.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
@ -107,7 +108,7 @@ func (eq *EventQuery) FirstX(ctx context.Context) *Event {
// Returns a *NotFoundError when no Event ID was found.
func (eq *EventQuery) FirstID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = eq.Limit(1).IDs(setContextOp(ctx, eq.ctx, "FirstID")); err != nil {
if ids, err = eq.Limit(1).IDs(setContextOp(ctx, eq.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
@ -130,7 +131,7 @@ func (eq *EventQuery) FirstIDX(ctx context.Context) int {
// Returns a *NotSingularError when more than one Event entity is found.
// Returns a *NotFoundError when no Event entities are found.
func (eq *EventQuery) Only(ctx context.Context) (*Event, error) {
nodes, err := eq.Limit(2).All(setContextOp(ctx, eq.ctx, "Only"))
nodes, err := eq.Limit(2).All(setContextOp(ctx, eq.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
@ -158,7 +159,7 @@ func (eq *EventQuery) OnlyX(ctx context.Context) *Event {
// Returns a *NotFoundError when no entities are found.
func (eq *EventQuery) OnlyID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = eq.Limit(2).IDs(setContextOp(ctx, eq.ctx, "OnlyID")); err != nil {
if ids, err = eq.Limit(2).IDs(setContextOp(ctx, eq.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
@ -183,7 +184,7 @@ func (eq *EventQuery) OnlyIDX(ctx context.Context) int {
// All executes the query and returns a list of Events.
func (eq *EventQuery) All(ctx context.Context) ([]*Event, error) {
ctx = setContextOp(ctx, eq.ctx, "All")
ctx = setContextOp(ctx, eq.ctx, ent.OpQueryAll)
if err := eq.prepareQuery(ctx); err != nil {
return nil, err
}
@ -205,7 +206,7 @@ func (eq *EventQuery) IDs(ctx context.Context) (ids []int, err error) {
if eq.ctx.Unique == nil && eq.path != nil {
eq.Unique(true)
}
ctx = setContextOp(ctx, eq.ctx, "IDs")
ctx = setContextOp(ctx, eq.ctx, ent.OpQueryIDs)
if err = eq.Select(event.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
@ -223,7 +224,7 @@ func (eq *EventQuery) IDsX(ctx context.Context) []int {
// Count returns the count of the given query.
func (eq *EventQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, eq.ctx, "Count")
ctx = setContextOp(ctx, eq.ctx, ent.OpQueryCount)
if err := eq.prepareQuery(ctx); err != nil {
return 0, err
}
@ -241,7 +242,7 @@ func (eq *EventQuery) CountX(ctx context.Context) int {
// Exist returns true if the query has elements in the graph.
func (eq *EventQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, eq.ctx, "Exist")
ctx = setContextOp(ctx, eq.ctx, ent.OpQueryExist)
switch _, err := eq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
@ -528,7 +529,7 @@ func (egb *EventGroupBy) Aggregate(fns ...AggregateFunc) *EventGroupBy {
// Scan applies the selector query and scans the result into the given value.
func (egb *EventGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, egb.build.ctx, "GroupBy")
ctx = setContextOp(ctx, egb.build.ctx, ent.OpQueryGroupBy)
if err := egb.build.prepareQuery(ctx); err != nil {
return err
}
@ -576,7 +577,7 @@ func (es *EventSelect) Aggregate(fns ...AggregateFunc) *EventSelect {
// Scan applies the selector query and scans the result into the given value.
func (es *EventSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, es.ctx, "Select")
ctx = setContextOp(ctx, es.ctx, ent.OpQuerySelect)
if err := es.prepareQuery(ctx); err != nil {
return err
}

View file

@ -1,4 +1,4 @@
package ent
//go:generate go run -mod=mod entgo.io/ent/cmd/ent@v0.13.1 generate ./schema
//go:generate go run -mod=mod entgo.io/ent/cmd/ent@v0.14.2 generate ./schema

View file

@ -7,6 +7,7 @@ import (
"fmt"
"math"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
@ -60,7 +61,7 @@ func (lq *LockQuery) Order(o ...lock.OrderOption) *LockQuery {
// First returns the first Lock entity from the query.
// Returns a *NotFoundError when no Lock was found.
func (lq *LockQuery) First(ctx context.Context) (*Lock, error) {
nodes, err := lq.Limit(1).All(setContextOp(ctx, lq.ctx, "First"))
nodes, err := lq.Limit(1).All(setContextOp(ctx, lq.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
@ -83,7 +84,7 @@ func (lq *LockQuery) FirstX(ctx context.Context) *Lock {
// Returns a *NotFoundError when no Lock ID was found.
func (lq *LockQuery) FirstID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = lq.Limit(1).IDs(setContextOp(ctx, lq.ctx, "FirstID")); err != nil {
if ids, err = lq.Limit(1).IDs(setContextOp(ctx, lq.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
@ -106,7 +107,7 @@ func (lq *LockQuery) FirstIDX(ctx context.Context) int {
// Returns a *NotSingularError when more than one Lock entity is found.
// Returns a *NotFoundError when no Lock entities are found.
func (lq *LockQuery) Only(ctx context.Context) (*Lock, error) {
nodes, err := lq.Limit(2).All(setContextOp(ctx, lq.ctx, "Only"))
nodes, err := lq.Limit(2).All(setContextOp(ctx, lq.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
@ -134,7 +135,7 @@ func (lq *LockQuery) OnlyX(ctx context.Context) *Lock {
// Returns a *NotFoundError when no entities are found.
func (lq *LockQuery) OnlyID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = lq.Limit(2).IDs(setContextOp(ctx, lq.ctx, "OnlyID")); err != nil {
if ids, err = lq.Limit(2).IDs(setContextOp(ctx, lq.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
@ -159,7 +160,7 @@ func (lq *LockQuery) OnlyIDX(ctx context.Context) int {
// All executes the query and returns a list of Locks.
func (lq *LockQuery) All(ctx context.Context) ([]*Lock, error) {
ctx = setContextOp(ctx, lq.ctx, "All")
ctx = setContextOp(ctx, lq.ctx, ent.OpQueryAll)
if err := lq.prepareQuery(ctx); err != nil {
return nil, err
}
@ -181,7 +182,7 @@ func (lq *LockQuery) IDs(ctx context.Context) (ids []int, err error) {
if lq.ctx.Unique == nil && lq.path != nil {
lq.Unique(true)
}
ctx = setContextOp(ctx, lq.ctx, "IDs")
ctx = setContextOp(ctx, lq.ctx, ent.OpQueryIDs)
if err = lq.Select(lock.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
@ -199,7 +200,7 @@ func (lq *LockQuery) IDsX(ctx context.Context) []int {
// Count returns the count of the given query.
func (lq *LockQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, lq.ctx, "Count")
ctx = setContextOp(ctx, lq.ctx, ent.OpQueryCount)
if err := lq.prepareQuery(ctx); err != nil {
return 0, err
}
@ -217,7 +218,7 @@ func (lq *LockQuery) CountX(ctx context.Context) int {
// Exist returns true if the query has elements in the graph.
func (lq *LockQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, lq.ctx, "Exist")
ctx = setContextOp(ctx, lq.ctx, ent.OpQueryExist)
switch _, err := lq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
@ -449,7 +450,7 @@ func (lgb *LockGroupBy) Aggregate(fns ...AggregateFunc) *LockGroupBy {
// Scan applies the selector query and scans the result into the given value.
func (lgb *LockGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, lgb.build.ctx, "GroupBy")
ctx = setContextOp(ctx, lgb.build.ctx, ent.OpQueryGroupBy)
if err := lgb.build.prepareQuery(ctx); err != nil {
return err
}
@ -497,7 +498,7 @@ func (ls *LockSelect) Aggregate(fns ...AggregateFunc) *LockSelect {
// Scan applies the selector query and scans the result into the given value.
func (ls *LockSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, ls.ctx, "Select")
ctx = setContextOp(ctx, ls.ctx, ent.OpQuerySelect)
if err := ls.prepareQuery(ctx); err != nil {
return err
}

View file

@ -8,6 +8,7 @@ import (
"fmt"
"math"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
@ -85,7 +86,7 @@ func (mq *MachineQuery) QueryAlerts() *AlertQuery {
// First returns the first Machine entity from the query.
// Returns a *NotFoundError when no Machine was found.
func (mq *MachineQuery) First(ctx context.Context) (*Machine, error) {
nodes, err := mq.Limit(1).All(setContextOp(ctx, mq.ctx, "First"))
nodes, err := mq.Limit(1).All(setContextOp(ctx, mq.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
@ -108,7 +109,7 @@ func (mq *MachineQuery) FirstX(ctx context.Context) *Machine {
// Returns a *NotFoundError when no Machine ID was found.
func (mq *MachineQuery) FirstID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = mq.Limit(1).IDs(setContextOp(ctx, mq.ctx, "FirstID")); err != nil {
if ids, err = mq.Limit(1).IDs(setContextOp(ctx, mq.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
@ -131,7 +132,7 @@ func (mq *MachineQuery) FirstIDX(ctx context.Context) int {
// Returns a *NotSingularError when more than one Machine entity is found.
// Returns a *NotFoundError when no Machine entities are found.
func (mq *MachineQuery) Only(ctx context.Context) (*Machine, error) {
nodes, err := mq.Limit(2).All(setContextOp(ctx, mq.ctx, "Only"))
nodes, err := mq.Limit(2).All(setContextOp(ctx, mq.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
@ -159,7 +160,7 @@ func (mq *MachineQuery) OnlyX(ctx context.Context) *Machine {
// Returns a *NotFoundError when no entities are found.
func (mq *MachineQuery) OnlyID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = mq.Limit(2).IDs(setContextOp(ctx, mq.ctx, "OnlyID")); err != nil {
if ids, err = mq.Limit(2).IDs(setContextOp(ctx, mq.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
@ -184,7 +185,7 @@ func (mq *MachineQuery) OnlyIDX(ctx context.Context) int {
// All executes the query and returns a list of Machines.
func (mq *MachineQuery) All(ctx context.Context) ([]*Machine, error) {
ctx = setContextOp(ctx, mq.ctx, "All")
ctx = setContextOp(ctx, mq.ctx, ent.OpQueryAll)
if err := mq.prepareQuery(ctx); err != nil {
return nil, err
}
@ -206,7 +207,7 @@ func (mq *MachineQuery) IDs(ctx context.Context) (ids []int, err error) {
if mq.ctx.Unique == nil && mq.path != nil {
mq.Unique(true)
}
ctx = setContextOp(ctx, mq.ctx, "IDs")
ctx = setContextOp(ctx, mq.ctx, ent.OpQueryIDs)
if err = mq.Select(machine.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
@ -224,7 +225,7 @@ func (mq *MachineQuery) IDsX(ctx context.Context) []int {
// Count returns the count of the given query.
func (mq *MachineQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, mq.ctx, "Count")
ctx = setContextOp(ctx, mq.ctx, ent.OpQueryCount)
if err := mq.prepareQuery(ctx); err != nil {
return 0, err
}
@ -242,7 +243,7 @@ func (mq *MachineQuery) CountX(ctx context.Context) int {
// Exist returns true if the query has elements in the graph.
func (mq *MachineQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, mq.ctx, "Exist")
ctx = setContextOp(ctx, mq.ctx, ent.OpQueryExist)
switch _, err := mq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
@ -529,7 +530,7 @@ func (mgb *MachineGroupBy) Aggregate(fns ...AggregateFunc) *MachineGroupBy {
// Scan applies the selector query and scans the result into the given value.
func (mgb *MachineGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, mgb.build.ctx, "GroupBy")
ctx = setContextOp(ctx, mgb.build.ctx, ent.OpQueryGroupBy)
if err := mgb.build.prepareQuery(ctx); err != nil {
return err
}
@ -577,7 +578,7 @@ func (ms *MachineSelect) Aggregate(fns ...AggregateFunc) *MachineSelect {
// Scan applies the selector query and scans the result into the given value.
func (ms *MachineSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, ms.ctx, "Select")
ctx = setContextOp(ctx, ms.ctx, ent.OpQuerySelect)
if err := ms.prepareQuery(ctx); err != nil {
return err
}

View file

@ -7,6 +7,7 @@ import (
"fmt"
"math"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
@ -84,7 +85,7 @@ func (mq *MetaQuery) QueryOwner() *AlertQuery {
// First returns the first Meta entity from the query.
// Returns a *NotFoundError when no Meta was found.
func (mq *MetaQuery) First(ctx context.Context) (*Meta, error) {
nodes, err := mq.Limit(1).All(setContextOp(ctx, mq.ctx, "First"))
nodes, err := mq.Limit(1).All(setContextOp(ctx, mq.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
@ -107,7 +108,7 @@ func (mq *MetaQuery) FirstX(ctx context.Context) *Meta {
// Returns a *NotFoundError when no Meta ID was found.
func (mq *MetaQuery) FirstID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = mq.Limit(1).IDs(setContextOp(ctx, mq.ctx, "FirstID")); err != nil {
if ids, err = mq.Limit(1).IDs(setContextOp(ctx, mq.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
@ -130,7 +131,7 @@ func (mq *MetaQuery) FirstIDX(ctx context.Context) int {
// Returns a *NotSingularError when more than one Meta entity is found.
// Returns a *NotFoundError when no Meta entities are found.
func (mq *MetaQuery) Only(ctx context.Context) (*Meta, error) {
nodes, err := mq.Limit(2).All(setContextOp(ctx, mq.ctx, "Only"))
nodes, err := mq.Limit(2).All(setContextOp(ctx, mq.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
@ -158,7 +159,7 @@ func (mq *MetaQuery) OnlyX(ctx context.Context) *Meta {
// Returns a *NotFoundError when no entities are found.
func (mq *MetaQuery) OnlyID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = mq.Limit(2).IDs(setContextOp(ctx, mq.ctx, "OnlyID")); err != nil {
if ids, err = mq.Limit(2).IDs(setContextOp(ctx, mq.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
@ -183,7 +184,7 @@ func (mq *MetaQuery) OnlyIDX(ctx context.Context) int {
// All executes the query and returns a list of MetaSlice.
func (mq *MetaQuery) All(ctx context.Context) ([]*Meta, error) {
ctx = setContextOp(ctx, mq.ctx, "All")
ctx = setContextOp(ctx, mq.ctx, ent.OpQueryAll)
if err := mq.prepareQuery(ctx); err != nil {
return nil, err
}
@ -205,7 +206,7 @@ func (mq *MetaQuery) IDs(ctx context.Context) (ids []int, err error) {
if mq.ctx.Unique == nil && mq.path != nil {
mq.Unique(true)
}
ctx = setContextOp(ctx, mq.ctx, "IDs")
ctx = setContextOp(ctx, mq.ctx, ent.OpQueryIDs)
if err = mq.Select(meta.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
@ -223,7 +224,7 @@ func (mq *MetaQuery) IDsX(ctx context.Context) []int {
// Count returns the count of the given query.
func (mq *MetaQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, mq.ctx, "Count")
ctx = setContextOp(ctx, mq.ctx, ent.OpQueryCount)
if err := mq.prepareQuery(ctx); err != nil {
return 0, err
}
@ -241,7 +242,7 @@ func (mq *MetaQuery) CountX(ctx context.Context) int {
// Exist returns true if the query has elements in the graph.
func (mq *MetaQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, mq.ctx, "Exist")
ctx = setContextOp(ctx, mq.ctx, ent.OpQueryExist)
switch _, err := mq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
@ -528,7 +529,7 @@ func (mgb *MetaGroupBy) Aggregate(fns ...AggregateFunc) *MetaGroupBy {
// Scan applies the selector query and scans the result into the given value.
func (mgb *MetaGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, mgb.build.ctx, "GroupBy")
ctx = setContextOp(ctx, mgb.build.ctx, ent.OpQueryGroupBy)
if err := mgb.build.prepareQuery(ctx); err != nil {
return err
}
@ -576,7 +577,7 @@ func (ms *MetaSelect) Aggregate(fns ...AggregateFunc) *MetaSelect {
// Scan applies the selector query and scans the result into the given value.
func (ms *MetaSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, ms.ctx, "Select")
ctx = setContextOp(ctx, ms.ctx, ent.OpQuerySelect)
if err := ms.prepareQuery(ctx); err != nil {
return err
}

View file

@ -7,6 +7,7 @@ import (
"fmt"
"math"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
@ -60,7 +61,7 @@ func (mq *MetricQuery) Order(o ...metric.OrderOption) *MetricQuery {
// First returns the first Metric entity from the query.
// Returns a *NotFoundError when no Metric was found.
func (mq *MetricQuery) First(ctx context.Context) (*Metric, error) {
nodes, err := mq.Limit(1).All(setContextOp(ctx, mq.ctx, "First"))
nodes, err := mq.Limit(1).All(setContextOp(ctx, mq.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
@ -83,7 +84,7 @@ func (mq *MetricQuery) FirstX(ctx context.Context) *Metric {
// Returns a *NotFoundError when no Metric ID was found.
func (mq *MetricQuery) FirstID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = mq.Limit(1).IDs(setContextOp(ctx, mq.ctx, "FirstID")); err != nil {
if ids, err = mq.Limit(1).IDs(setContextOp(ctx, mq.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
@ -106,7 +107,7 @@ func (mq *MetricQuery) FirstIDX(ctx context.Context) int {
// Returns a *NotSingularError when more than one Metric entity is found.
// Returns a *NotFoundError when no Metric entities are found.
func (mq *MetricQuery) Only(ctx context.Context) (*Metric, error) {
nodes, err := mq.Limit(2).All(setContextOp(ctx, mq.ctx, "Only"))
nodes, err := mq.Limit(2).All(setContextOp(ctx, mq.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
@ -134,7 +135,7 @@ func (mq *MetricQuery) OnlyX(ctx context.Context) *Metric {
// Returns a *NotFoundError when no entities are found.
func (mq *MetricQuery) OnlyID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = mq.Limit(2).IDs(setContextOp(ctx, mq.ctx, "OnlyID")); err != nil {
if ids, err = mq.Limit(2).IDs(setContextOp(ctx, mq.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
@ -159,7 +160,7 @@ func (mq *MetricQuery) OnlyIDX(ctx context.Context) int {
// All executes the query and returns a list of Metrics.
func (mq *MetricQuery) All(ctx context.Context) ([]*Metric, error) {
ctx = setContextOp(ctx, mq.ctx, "All")
ctx = setContextOp(ctx, mq.ctx, ent.OpQueryAll)
if err := mq.prepareQuery(ctx); err != nil {
return nil, err
}
@ -181,7 +182,7 @@ func (mq *MetricQuery) IDs(ctx context.Context) (ids []int, err error) {
if mq.ctx.Unique == nil && mq.path != nil {
mq.Unique(true)
}
ctx = setContextOp(ctx, mq.ctx, "IDs")
ctx = setContextOp(ctx, mq.ctx, ent.OpQueryIDs)
if err = mq.Select(metric.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
@ -199,7 +200,7 @@ func (mq *MetricQuery) IDsX(ctx context.Context) []int {
// Count returns the count of the given query.
func (mq *MetricQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, mq.ctx, "Count")
ctx = setContextOp(ctx, mq.ctx, ent.OpQueryCount)
if err := mq.prepareQuery(ctx); err != nil {
return 0, err
}
@ -217,7 +218,7 @@ func (mq *MetricQuery) CountX(ctx context.Context) int {
// Exist returns true if the query has elements in the graph.
func (mq *MetricQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, mq.ctx, "Exist")
ctx = setContextOp(ctx, mq.ctx, ent.OpQueryExist)
switch _, err := mq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
@ -449,7 +450,7 @@ func (mgb *MetricGroupBy) Aggregate(fns ...AggregateFunc) *MetricGroupBy {
// Scan applies the selector query and scans the result into the given value.
func (mgb *MetricGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, mgb.build.ctx, "GroupBy")
ctx = setContextOp(ctx, mgb.build.ctx, ent.OpQueryGroupBy)
if err := mgb.build.prepareQuery(ctx); err != nil {
return err
}
@ -497,7 +498,7 @@ func (ms *MetricSelect) Aggregate(fns ...AggregateFunc) *MetricSelect {
// Scan applies the selector query and scans the result into the given value.
func (ms *MetricSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, ms.ctx, "Select")
ctx = setContextOp(ctx, ms.ctx, ent.OpQuerySelect)
if err := ms.prepareQuery(ctx); err != nil {
return err
}

View file

@ -5,6 +5,6 @@ package runtime
// The schema-stitching logic is generated in github.com/crowdsecurity/crowdsec/pkg/database/ent/runtime.go
const (
Version = "v0.13.1" // Version of ent codegen.
Sum = "h1:uD8QwN1h6SNphdCCzmkMN3feSUzNnVvV/WIkHKMbzOE=" // Sum of ent codegen.
Version = "v0.14.2" // Version of ent codegen.
Sum = "h1:ywld/j2Rx4EmnIKs8eZ29cbFA1zpB+DA9TLL5l3rlq0=" // Sum of ent codegen.
)