From 66dfded0cf319630125230192932ce5d4323163b Mon Sep 17 00:00:00 2001 From: "Thibault \"bui\" Koechlin" Date: Fri, 14 Apr 2023 11:39:07 +0200 Subject: [PATCH] significantly increase the max number of scenarios to be sent (#2170) --- pkg/database/ent/alert.go | 3 +- pkg/database/ent/alert/where.go | 16 +- pkg/database/ent/client.go | 6 +- pkg/database/ent/configitem.go | 25 +- pkg/database/ent/configitem/configitem.go | 2 +- pkg/database/ent/configitem/where.go | 82 +--- pkg/database/ent/configitem_create.go | 16 +- pkg/database/ent/configitem_delete.go | 8 +- pkg/database/ent/configitem_query.go | 454 ++-------------------- pkg/database/ent/configitem_update.go | 14 +- pkg/database/ent/decision.go | 3 +- pkg/database/ent/decision/where.go | 16 +- pkg/database/ent/migrate/schema.go | 2 +- pkg/database/ent/schema/machine.go | 2 +- 14 files changed, 97 insertions(+), 552 deletions(-) diff --git a/pkg/database/ent/alert.go b/pkg/database/ent/alert.go index b1bbfb5dd..2649923bf 100644 --- a/pkg/database/ent/alert.go +++ b/pkg/database/ent/alert.go @@ -426,7 +426,8 @@ func (a *Alert) String() string { builder.WriteString(", ") builder.WriteString("simulated=") builder.WriteString(fmt.Sprintf("%v", a.Simulated)) - builder.WriteString(", uuid=") + builder.WriteString(", ") + builder.WriteString("uuid=") builder.WriteString(a.UUID) builder.WriteByte(')') return builder.String() diff --git a/pkg/database/ent/alert/where.go b/pkg/database/ent/alert/where.go index dbec4c177..ef5b89b61 100644 --- a/pkg/database/ent/alert/where.go +++ b/pkg/database/ent/alert/where.go @@ -2351,34 +2351,22 @@ func UUIDNEQ(v string) predicate.Alert { // UUIDIn applies the In predicate on the "uuid" field. func UUIDIn(vs ...string) predicate.Alert { - v := make([]interface{}, len(vs)) + v := make([]any, len(vs)) for i := range v { v[i] = vs[i] } return predicate.Alert(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } s.Where(sql.In(s.C(FieldUUID), v...)) }) } // UUIDNotIn applies the NotIn predicate on the "uuid" field. func UUIDNotIn(vs ...string) predicate.Alert { - v := make([]interface{}, len(vs)) + v := make([]any, len(vs)) for i := range v { v[i] = vs[i] } return predicate.Alert(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } s.Where(sql.NotIn(s.C(FieldUUID), v...)) }) } diff --git a/pkg/database/ent/client.go b/pkg/database/ent/client.go index 031f6b049..815b1df6d 100644 --- a/pkg/database/ent/client.go +++ b/pkg/database/ent/client.go @@ -425,7 +425,7 @@ func (c *ConfigItemClient) Use(hooks ...Hook) { c.hooks.ConfigItem = append(c.hooks.ConfigItem, hooks...) } -// Create returns a create builder for ConfigItem. +// Create returns a builder for creating a ConfigItem entity. func (c *ConfigItemClient) Create() *ConfigItemCreate { mutation := newConfigItemMutation(c.config, OpCreate) return &ConfigItemCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} @@ -460,12 +460,12 @@ func (c *ConfigItemClient) Delete() *ConfigItemDelete { return &ConfigItemDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} } -// DeleteOne returns a delete builder for the given entity. +// DeleteOne returns a builder for deleting the given entity. func (c *ConfigItemClient) DeleteOne(ci *ConfigItem) *ConfigItemDeleteOne { return c.DeleteOneID(ci.ID) } -// DeleteOneID returns a delete builder for the given id. +// DeleteOne returns a builder for deleting the given entity by its id. func (c *ConfigItemClient) DeleteOneID(id int) *ConfigItemDeleteOne { builder := c.Delete().Where(configitem.ID(id)) builder.mutation.id = &id diff --git a/pkg/database/ent/configitem.go b/pkg/database/ent/configitem.go index 45ac5301c..615780dba 100644 --- a/pkg/database/ent/configitem.go +++ b/pkg/database/ent/configitem.go @@ -1,4 +1,4 @@ -// Code generated by entc, DO NOT EDIT. +// Code generated by ent, DO NOT EDIT. package ent @@ -27,8 +27,8 @@ type ConfigItem struct { } // scanValues returns the types for scanning values from sql.Rows. -func (*ConfigItem) scanValues(columns []string) ([]interface{}, error) { - values := make([]interface{}, len(columns)) +func (*ConfigItem) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) for i := range columns { switch columns[i] { case configitem.FieldID: @@ -46,7 +46,7 @@ func (*ConfigItem) scanValues(columns []string) ([]interface{}, error) { // assignValues assigns the values that were returned from sql.Rows (after scanning) // to the ConfigItem fields. -func (ci *ConfigItem) assignValues(columns []string, values []interface{}) error { +func (ci *ConfigItem) 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,11 +99,11 @@ func (ci *ConfigItem) Update() *ConfigItemUpdateOne { // Unwrap unwraps the ConfigItem 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 (ci *ConfigItem) Unwrap() *ConfigItem { - tx, ok := ci.config.driver.(*txDriver) + _tx, ok := ci.config.driver.(*txDriver) if !ok { panic("ent: ConfigItem is not a transactional entity") } - ci.config.driver = tx.drv + ci.config.driver = _tx.drv return ci } @@ -111,18 +111,21 @@ func (ci *ConfigItem) Unwrap() *ConfigItem { func (ci *ConfigItem) String() string { var builder strings.Builder builder.WriteString("ConfigItem(") - builder.WriteString(fmt.Sprintf("id=%v", ci.ID)) + builder.WriteString(fmt.Sprintf("id=%v, ", ci.ID)) if v := ci.CreatedAt; v != nil { - builder.WriteString(", created_at=") + builder.WriteString("created_at=") builder.WriteString(v.Format(time.ANSIC)) } + builder.WriteString(", ") if v := ci.UpdatedAt; v != nil { - builder.WriteString(", updated_at=") + builder.WriteString("updated_at=") builder.WriteString(v.Format(time.ANSIC)) } - builder.WriteString(", name=") + builder.WriteString(", ") + builder.WriteString("name=") builder.WriteString(ci.Name) - builder.WriteString(", value=") + builder.WriteString(", ") + builder.WriteString("value=") builder.WriteString(ci.Value) builder.WriteByte(')') return builder.String() diff --git a/pkg/database/ent/configitem/configitem.go b/pkg/database/ent/configitem/configitem.go index 6e8e9dc28..80e93e4cc 100644 --- a/pkg/database/ent/configitem/configitem.go +++ b/pkg/database/ent/configitem/configitem.go @@ -1,4 +1,4 @@ -// Code generated by entc, DO NOT EDIT. +// Code generated by ent, DO NOT EDIT. package configitem diff --git a/pkg/database/ent/configitem/where.go b/pkg/database/ent/configitem/where.go index d179326e8..6d06938a8 100644 --- a/pkg/database/ent/configitem/where.go +++ b/pkg/database/ent/configitem/where.go @@ -1,4 +1,4 @@ -// Code generated by entc, DO NOT EDIT. +// Code generated by ent, DO NOT EDIT. package configitem @@ -33,13 +33,7 @@ func IDNEQ(id int) predicate.ConfigItem { // IDIn applies the In predicate on the ID field. func IDIn(ids ...int) predicate.ConfigItem { return predicate.ConfigItem(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(ids) == 0 { - s.Where(sql.False()) - return - } - v := make([]interface{}, len(ids)) + v := make([]any, len(ids)) for i := range v { v[i] = ids[i] } @@ -50,13 +44,7 @@ func IDIn(ids ...int) predicate.ConfigItem { // IDNotIn applies the NotIn predicate on the ID field. func IDNotIn(ids ...int) predicate.ConfigItem { return predicate.ConfigItem(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(ids) == 0 { - s.Where(sql.False()) - return - } - v := make([]interface{}, len(ids)) + v := make([]any, len(ids)) for i := range v { v[i] = ids[i] } @@ -136,34 +124,22 @@ func CreatedAtNEQ(v time.Time) predicate.ConfigItem { // CreatedAtIn applies the In predicate on the "created_at" field. func CreatedAtIn(vs ...time.Time) predicate.ConfigItem { - v := make([]interface{}, len(vs)) + v := make([]any, len(vs)) for i := range v { v[i] = vs[i] } return predicate.ConfigItem(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } s.Where(sql.In(s.C(FieldCreatedAt), v...)) }) } // CreatedAtNotIn applies the NotIn predicate on the "created_at" field. func CreatedAtNotIn(vs ...time.Time) predicate.ConfigItem { - v := make([]interface{}, len(vs)) + v := make([]any, len(vs)) for i := range v { v[i] = vs[i] } return predicate.ConfigItem(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } s.Where(sql.NotIn(s.C(FieldCreatedAt), v...)) }) } @@ -226,34 +202,22 @@ func UpdatedAtNEQ(v time.Time) predicate.ConfigItem { // UpdatedAtIn applies the In predicate on the "updated_at" field. func UpdatedAtIn(vs ...time.Time) predicate.ConfigItem { - v := make([]interface{}, len(vs)) + v := make([]any, len(vs)) for i := range v { v[i] = vs[i] } return predicate.ConfigItem(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } s.Where(sql.In(s.C(FieldUpdatedAt), v...)) }) } // UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. func UpdatedAtNotIn(vs ...time.Time) predicate.ConfigItem { - v := make([]interface{}, len(vs)) + v := make([]any, len(vs)) for i := range v { v[i] = vs[i] } return predicate.ConfigItem(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } s.Where(sql.NotIn(s.C(FieldUpdatedAt), v...)) }) } @@ -316,34 +280,22 @@ func NameNEQ(v string) predicate.ConfigItem { // NameIn applies the In predicate on the "name" field. func NameIn(vs ...string) predicate.ConfigItem { - v := make([]interface{}, len(vs)) + v := make([]any, len(vs)) for i := range v { v[i] = vs[i] } return predicate.ConfigItem(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } s.Where(sql.In(s.C(FieldName), v...)) }) } // NameNotIn applies the NotIn predicate on the "name" field. func NameNotIn(vs ...string) predicate.ConfigItem { - v := make([]interface{}, len(vs)) + v := make([]any, len(vs)) for i := range v { v[i] = vs[i] } return predicate.ConfigItem(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } s.Where(sql.NotIn(s.C(FieldName), v...)) }) } @@ -427,34 +379,22 @@ func ValueNEQ(v string) predicate.ConfigItem { // ValueIn applies the In predicate on the "value" field. func ValueIn(vs ...string) predicate.ConfigItem { - v := make([]interface{}, len(vs)) + v := make([]any, len(vs)) for i := range v { v[i] = vs[i] } return predicate.ConfigItem(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } s.Where(sql.In(s.C(FieldValue), v...)) }) } // ValueNotIn applies the NotIn predicate on the "value" field. func ValueNotIn(vs ...string) predicate.ConfigItem { - v := make([]interface{}, len(vs)) + v := make([]any, len(vs)) for i := range v { v[i] = vs[i] } return predicate.ConfigItem(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } s.Where(sql.NotIn(s.C(FieldValue), v...)) }) } diff --git a/pkg/database/ent/configitem_create.go b/pkg/database/ent/configitem_create.go index 4800d7c20..736e6a505 100644 --- a/pkg/database/ent/configitem_create.go +++ b/pkg/database/ent/configitem_create.go @@ -1,4 +1,4 @@ -// Code generated by entc, DO NOT EDIT. +// Code generated by ent, DO NOT EDIT. package ent @@ -100,9 +100,15 @@ func (cic *ConfigItemCreate) Save(ctx context.Context) (*ConfigItem, error) { } mut = cic.hooks[i](mut) } - if _, err := mut.Mutate(ctx, cic.mutation); err != nil { + v, err := mut.Mutate(ctx, cic.mutation) + if err != nil { return nil, err } + nv, ok := v.(*ConfigItem) + if !ok { + return nil, fmt.Errorf("unexpected node type %T returned from ConfigItemMutation", v) + } + node = nv } return node, err } @@ -156,7 +162,7 @@ func (cic *ConfigItemCreate) sqlSave(ctx context.Context) (*ConfigItem, error) { _node, _spec := cic.createSpec() if err := sqlgraph.CreateNode(ctx, cic.driver, _spec); err != nil { if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{err.Error(), err} + err = &ConstraintError{msg: err.Error(), wrap: err} } return nil, err } @@ -244,7 +250,7 @@ func (cicb *ConfigItemCreateBulk) Save(ctx context.Context) ([]*ConfigItem, erro // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, cicb.driver, spec); err != nil { if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{err.Error(), err} + err = &ConstraintError{msg: err.Error(), wrap: err} } } } @@ -252,11 +258,11 @@ func (cicb *ConfigItemCreateBulk) Save(ctx context.Context) ([]*ConfigItem, erro return nil, err } mutation.id = &nodes[i].ID - mutation.done = true if specs[i].ID.Value != nil { id := specs[i].ID.Value.(int64) nodes[i].ID = int(id) } + mutation.done = true return nodes[i], nil }) for i := len(builder.hooks) - 1; i >= 0; i-- { diff --git a/pkg/database/ent/configitem_delete.go b/pkg/database/ent/configitem_delete.go index 16b337048..223fa9eef 100644 --- a/pkg/database/ent/configitem_delete.go +++ b/pkg/database/ent/configitem_delete.go @@ -1,4 +1,4 @@ -// Code generated by entc, DO NOT EDIT. +// Code generated by ent, DO NOT EDIT. package ent @@ -84,7 +84,11 @@ func (cid *ConfigItemDelete) sqlExec(ctx context.Context) (int, error) { } } } - return sqlgraph.DeleteNodes(ctx, cid.driver, _spec) + affected, err := sqlgraph.DeleteNodes(ctx, cid.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return affected, err } // ConfigItemDeleteOne is the builder for deleting a single ConfigItem entity. diff --git a/pkg/database/ent/configitem_query.go b/pkg/database/ent/configitem_query.go index c9680becf..6c9e6732a 100644 --- a/pkg/database/ent/configitem_query.go +++ b/pkg/database/ent/configitem_query.go @@ -1,10 +1,9 @@ -// Code generated by entc, DO NOT EDIT. +// Code generated by ent, DO NOT EDIT. package ent import ( "context" - "errors" "fmt" "math" @@ -262,17 +261,18 @@ func (ciq *ConfigItemQuery) Clone() *ConfigItemQuery { // GroupBy(configitem.FieldCreatedAt). // Aggregate(ent.Count()). // Scan(ctx, &v) -// func (ciq *ConfigItemQuery) GroupBy(field string, fields ...string) *ConfigItemGroupBy { - group := &ConfigItemGroupBy{config: ciq.config} - group.fields = append([]string{field}, fields...) - group.path = func(ctx context.Context) (prev *sql.Selector, err error) { + grbuild := &ConfigItemGroupBy{config: ciq.config} + grbuild.fields = append([]string{field}, fields...) + grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) { if err := ciq.prepareQuery(ctx); err != nil { return nil, err } return ciq.sqlQuery(ctx), nil } - return group + grbuild.label = configitem.Label + grbuild.flds, grbuild.scan = &grbuild.fields, grbuild.Scan + return grbuild } // Select allows the selection one or more fields/columns for the given query, @@ -287,10 +287,12 @@ func (ciq *ConfigItemQuery) GroupBy(field string, fields ...string) *ConfigItemG // client.ConfigItem.Query(). // Select(configitem.FieldCreatedAt). // Scan(ctx, &v) -// func (ciq *ConfigItemQuery) Select(fields ...string) *ConfigItemSelect { ciq.fields = append(ciq.fields, fields...) - return &ConfigItemSelect{ConfigItemQuery: ciq} + selbuild := &ConfigItemSelect{ConfigItemQuery: ciq} + selbuild.label = configitem.Label + selbuild.flds, selbuild.scan = &ciq.fields, selbuild.Scan + return selbuild } func (ciq *ConfigItemQuery) prepareQuery(ctx context.Context) error { @@ -309,23 +311,22 @@ func (ciq *ConfigItemQuery) prepareQuery(ctx context.Context) error { return nil } -func (ciq *ConfigItemQuery) sqlAll(ctx context.Context) ([]*ConfigItem, error) { +func (ciq *ConfigItemQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ConfigItem, error) { var ( nodes = []*ConfigItem{} _spec = ciq.querySpec() ) - _spec.ScanValues = func(columns []string) ([]interface{}, error) { + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*ConfigItem).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { node := &ConfigItem{config: ciq.config} nodes = append(nodes, node) - return node.scanValues(columns) - } - _spec.Assign = func(columns []string, values []interface{}) error { - if len(nodes) == 0 { - return fmt.Errorf("ent: Assign called without calling ScanValues") - } - node := nodes[len(nodes)-1] return node.assignValues(columns, values) } + for i := range hooks { + hooks[i](ctx, _spec) + } if err := sqlgraph.QueryNodes(ctx, ciq.driver, _spec); err != nil { return nil, err } @@ -345,11 +346,14 @@ func (ciq *ConfigItemQuery) sqlCount(ctx context.Context) (int, error) { } func (ciq *ConfigItemQuery) sqlExist(ctx context.Context) (bool, error) { - n, err := ciq.sqlCount(ctx) - if err != nil { + switch _, err := ciq.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil } - return n > 0, nil } func (ciq *ConfigItemQuery) querySpec() *sqlgraph.QuerySpec { @@ -435,6 +439,7 @@ func (ciq *ConfigItemQuery) sqlQuery(ctx context.Context) *sql.Selector { // ConfigItemGroupBy is the group-by builder for ConfigItem entities. type ConfigItemGroupBy struct { config + selector fields []string fns []AggregateFunc // intermediate query (i.e. traversal path). @@ -449,7 +454,7 @@ func (cigb *ConfigItemGroupBy) Aggregate(fns ...AggregateFunc) *ConfigItemGroupB } // Scan applies the group-by query and scans the result into the given value. -func (cigb *ConfigItemGroupBy) Scan(ctx context.Context, v interface{}) error { +func (cigb *ConfigItemGroupBy) Scan(ctx context.Context, v any) error { query, err := cigb.path(ctx) if err != nil { return err @@ -458,210 +463,7 @@ func (cigb *ConfigItemGroupBy) Scan(ctx context.Context, v interface{}) error { return cigb.sqlScan(ctx, v) } -// ScanX is like Scan, but panics if an error occurs. -func (cigb *ConfigItemGroupBy) ScanX(ctx context.Context, v interface{}) { - if err := cigb.Scan(ctx, v); err != nil { - panic(err) - } -} - -// Strings returns list of strings from group-by. -// It is only allowed when executing a group-by query with one field. -func (cigb *ConfigItemGroupBy) Strings(ctx context.Context) ([]string, error) { - if len(cigb.fields) > 1 { - return nil, errors.New("ent: ConfigItemGroupBy.Strings is not achievable when grouping more than 1 field") - } - var v []string - if err := cigb.Scan(ctx, &v); err != nil { - return nil, err - } - return v, nil -} - -// StringsX is like Strings, but panics if an error occurs. -func (cigb *ConfigItemGroupBy) StringsX(ctx context.Context) []string { - v, err := cigb.Strings(ctx) - if err != nil { - panic(err) - } - return v -} - -// String returns a single string from a group-by query. -// It is only allowed when executing a group-by query with one field. -func (cigb *ConfigItemGroupBy) String(ctx context.Context) (_ string, err error) { - var v []string - if v, err = cigb.Strings(ctx); err != nil { - return - } - switch len(v) { - case 1: - return v[0], nil - case 0: - err = &NotFoundError{configitem.Label} - default: - err = fmt.Errorf("ent: ConfigItemGroupBy.Strings returned %d results when one was expected", len(v)) - } - return -} - -// StringX is like String, but panics if an error occurs. -func (cigb *ConfigItemGroupBy) StringX(ctx context.Context) string { - v, err := cigb.String(ctx) - if err != nil { - panic(err) - } - return v -} - -// Ints returns list of ints from group-by. -// It is only allowed when executing a group-by query with one field. -func (cigb *ConfigItemGroupBy) Ints(ctx context.Context) ([]int, error) { - if len(cigb.fields) > 1 { - return nil, errors.New("ent: ConfigItemGroupBy.Ints is not achievable when grouping more than 1 field") - } - var v []int - if err := cigb.Scan(ctx, &v); err != nil { - return nil, err - } - return v, nil -} - -// IntsX is like Ints, but panics if an error occurs. -func (cigb *ConfigItemGroupBy) IntsX(ctx context.Context) []int { - v, err := cigb.Ints(ctx) - if err != nil { - panic(err) - } - return v -} - -// Int returns a single int from a group-by query. -// It is only allowed when executing a group-by query with one field. -func (cigb *ConfigItemGroupBy) Int(ctx context.Context) (_ int, err error) { - var v []int - if v, err = cigb.Ints(ctx); err != nil { - return - } - switch len(v) { - case 1: - return v[0], nil - case 0: - err = &NotFoundError{configitem.Label} - default: - err = fmt.Errorf("ent: ConfigItemGroupBy.Ints returned %d results when one was expected", len(v)) - } - return -} - -// IntX is like Int, but panics if an error occurs. -func (cigb *ConfigItemGroupBy) IntX(ctx context.Context) int { - v, err := cigb.Int(ctx) - if err != nil { - panic(err) - } - return v -} - -// Float64s returns list of float64s from group-by. -// It is only allowed when executing a group-by query with one field. -func (cigb *ConfigItemGroupBy) Float64s(ctx context.Context) ([]float64, error) { - if len(cigb.fields) > 1 { - return nil, errors.New("ent: ConfigItemGroupBy.Float64s is not achievable when grouping more than 1 field") - } - var v []float64 - if err := cigb.Scan(ctx, &v); err != nil { - return nil, err - } - return v, nil -} - -// Float64sX is like Float64s, but panics if an error occurs. -func (cigb *ConfigItemGroupBy) Float64sX(ctx context.Context) []float64 { - v, err := cigb.Float64s(ctx) - if err != nil { - panic(err) - } - return v -} - -// Float64 returns a single float64 from a group-by query. -// It is only allowed when executing a group-by query with one field. -func (cigb *ConfigItemGroupBy) Float64(ctx context.Context) (_ float64, err error) { - var v []float64 - if v, err = cigb.Float64s(ctx); err != nil { - return - } - switch len(v) { - case 1: - return v[0], nil - case 0: - err = &NotFoundError{configitem.Label} - default: - err = fmt.Errorf("ent: ConfigItemGroupBy.Float64s returned %d results when one was expected", len(v)) - } - return -} - -// Float64X is like Float64, but panics if an error occurs. -func (cigb *ConfigItemGroupBy) Float64X(ctx context.Context) float64 { - v, err := cigb.Float64(ctx) - if err != nil { - panic(err) - } - return v -} - -// Bools returns list of bools from group-by. -// It is only allowed when executing a group-by query with one field. -func (cigb *ConfigItemGroupBy) Bools(ctx context.Context) ([]bool, error) { - if len(cigb.fields) > 1 { - return nil, errors.New("ent: ConfigItemGroupBy.Bools is not achievable when grouping more than 1 field") - } - var v []bool - if err := cigb.Scan(ctx, &v); err != nil { - return nil, err - } - return v, nil -} - -// BoolsX is like Bools, but panics if an error occurs. -func (cigb *ConfigItemGroupBy) BoolsX(ctx context.Context) []bool { - v, err := cigb.Bools(ctx) - if err != nil { - panic(err) - } - return v -} - -// Bool returns a single bool from a group-by query. -// It is only allowed when executing a group-by query with one field. -func (cigb *ConfigItemGroupBy) Bool(ctx context.Context) (_ bool, err error) { - var v []bool - if v, err = cigb.Bools(ctx); err != nil { - return - } - switch len(v) { - case 1: - return v[0], nil - case 0: - err = &NotFoundError{configitem.Label} - default: - err = fmt.Errorf("ent: ConfigItemGroupBy.Bools returned %d results when one was expected", len(v)) - } - return -} - -// BoolX is like Bool, but panics if an error occurs. -func (cigb *ConfigItemGroupBy) BoolX(ctx context.Context) bool { - v, err := cigb.Bool(ctx) - if err != nil { - panic(err) - } - return v -} - -func (cigb *ConfigItemGroupBy) sqlScan(ctx context.Context, v interface{}) error { +func (cigb *ConfigItemGroupBy) sqlScan(ctx context.Context, v any) error { for _, f := range cigb.fields { if !configitem.ValidColumn(f) { return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)} @@ -702,12 +504,13 @@ func (cigb *ConfigItemGroupBy) sqlQuery() *sql.Selector { // ConfigItemSelect is the builder for selecting fields of ConfigItem entities. type ConfigItemSelect struct { *ConfigItemQuery + selector // intermediate query (i.e. traversal path). sql *sql.Selector } // Scan applies the selector query and scans the result into the given value. -func (cis *ConfigItemSelect) Scan(ctx context.Context, v interface{}) error { +func (cis *ConfigItemSelect) Scan(ctx context.Context, v any) error { if err := cis.prepareQuery(ctx); err != nil { return err } @@ -715,202 +518,7 @@ func (cis *ConfigItemSelect) Scan(ctx context.Context, v interface{}) error { return cis.sqlScan(ctx, v) } -// ScanX is like Scan, but panics if an error occurs. -func (cis *ConfigItemSelect) ScanX(ctx context.Context, v interface{}) { - if err := cis.Scan(ctx, v); err != nil { - panic(err) - } -} - -// Strings returns list of strings from a selector. It is only allowed when selecting one field. -func (cis *ConfigItemSelect) Strings(ctx context.Context) ([]string, error) { - if len(cis.fields) > 1 { - return nil, errors.New("ent: ConfigItemSelect.Strings is not achievable when selecting more than 1 field") - } - var v []string - if err := cis.Scan(ctx, &v); err != nil { - return nil, err - } - return v, nil -} - -// StringsX is like Strings, but panics if an error occurs. -func (cis *ConfigItemSelect) StringsX(ctx context.Context) []string { - v, err := cis.Strings(ctx) - if err != nil { - panic(err) - } - return v -} - -// String returns a single string from a selector. It is only allowed when selecting one field. -func (cis *ConfigItemSelect) String(ctx context.Context) (_ string, err error) { - var v []string - if v, err = cis.Strings(ctx); err != nil { - return - } - switch len(v) { - case 1: - return v[0], nil - case 0: - err = &NotFoundError{configitem.Label} - default: - err = fmt.Errorf("ent: ConfigItemSelect.Strings returned %d results when one was expected", len(v)) - } - return -} - -// StringX is like String, but panics if an error occurs. -func (cis *ConfigItemSelect) StringX(ctx context.Context) string { - v, err := cis.String(ctx) - if err != nil { - panic(err) - } - return v -} - -// Ints returns list of ints from a selector. It is only allowed when selecting one field. -func (cis *ConfigItemSelect) Ints(ctx context.Context) ([]int, error) { - if len(cis.fields) > 1 { - return nil, errors.New("ent: ConfigItemSelect.Ints is not achievable when selecting more than 1 field") - } - var v []int - if err := cis.Scan(ctx, &v); err != nil { - return nil, err - } - return v, nil -} - -// IntsX is like Ints, but panics if an error occurs. -func (cis *ConfigItemSelect) IntsX(ctx context.Context) []int { - v, err := cis.Ints(ctx) - if err != nil { - panic(err) - } - return v -} - -// Int returns a single int from a selector. It is only allowed when selecting one field. -func (cis *ConfigItemSelect) Int(ctx context.Context) (_ int, err error) { - var v []int - if v, err = cis.Ints(ctx); err != nil { - return - } - switch len(v) { - case 1: - return v[0], nil - case 0: - err = &NotFoundError{configitem.Label} - default: - err = fmt.Errorf("ent: ConfigItemSelect.Ints returned %d results when one was expected", len(v)) - } - return -} - -// IntX is like Int, but panics if an error occurs. -func (cis *ConfigItemSelect) IntX(ctx context.Context) int { - v, err := cis.Int(ctx) - if err != nil { - panic(err) - } - return v -} - -// Float64s returns list of float64s from a selector. It is only allowed when selecting one field. -func (cis *ConfigItemSelect) Float64s(ctx context.Context) ([]float64, error) { - if len(cis.fields) > 1 { - return nil, errors.New("ent: ConfigItemSelect.Float64s is not achievable when selecting more than 1 field") - } - var v []float64 - if err := cis.Scan(ctx, &v); err != nil { - return nil, err - } - return v, nil -} - -// Float64sX is like Float64s, but panics if an error occurs. -func (cis *ConfigItemSelect) Float64sX(ctx context.Context) []float64 { - v, err := cis.Float64s(ctx) - if err != nil { - panic(err) - } - return v -} - -// Float64 returns a single float64 from a selector. It is only allowed when selecting one field. -func (cis *ConfigItemSelect) Float64(ctx context.Context) (_ float64, err error) { - var v []float64 - if v, err = cis.Float64s(ctx); err != nil { - return - } - switch len(v) { - case 1: - return v[0], nil - case 0: - err = &NotFoundError{configitem.Label} - default: - err = fmt.Errorf("ent: ConfigItemSelect.Float64s returned %d results when one was expected", len(v)) - } - return -} - -// Float64X is like Float64, but panics if an error occurs. -func (cis *ConfigItemSelect) Float64X(ctx context.Context) float64 { - v, err := cis.Float64(ctx) - if err != nil { - panic(err) - } - return v -} - -// Bools returns list of bools from a selector. It is only allowed when selecting one field. -func (cis *ConfigItemSelect) Bools(ctx context.Context) ([]bool, error) { - if len(cis.fields) > 1 { - return nil, errors.New("ent: ConfigItemSelect.Bools is not achievable when selecting more than 1 field") - } - var v []bool - if err := cis.Scan(ctx, &v); err != nil { - return nil, err - } - return v, nil -} - -// BoolsX is like Bools, but panics if an error occurs. -func (cis *ConfigItemSelect) BoolsX(ctx context.Context) []bool { - v, err := cis.Bools(ctx) - if err != nil { - panic(err) - } - return v -} - -// Bool returns a single bool from a selector. It is only allowed when selecting one field. -func (cis *ConfigItemSelect) Bool(ctx context.Context) (_ bool, err error) { - var v []bool - if v, err = cis.Bools(ctx); err != nil { - return - } - switch len(v) { - case 1: - return v[0], nil - case 0: - err = &NotFoundError{configitem.Label} - default: - err = fmt.Errorf("ent: ConfigItemSelect.Bools returned %d results when one was expected", len(v)) - } - return -} - -// BoolX is like Bool, but panics if an error occurs. -func (cis *ConfigItemSelect) BoolX(ctx context.Context) bool { - v, err := cis.Bool(ctx) - if err != nil { - panic(err) - } - return v -} - -func (cis *ConfigItemSelect) sqlScan(ctx context.Context, v interface{}) error { +func (cis *ConfigItemSelect) sqlScan(ctx context.Context, v any) error { rows := &sql.Rows{} query, args := cis.sql.Query() if err := cis.driver.Query(ctx, query, args, rows); err != nil { diff --git a/pkg/database/ent/configitem_update.go b/pkg/database/ent/configitem_update.go index d68323270..e591347a0 100644 --- a/pkg/database/ent/configitem_update.go +++ b/pkg/database/ent/configitem_update.go @@ -1,4 +1,4 @@ -// Code generated by entc, DO NOT EDIT. +// Code generated by ent, DO NOT EDIT. package ent @@ -198,7 +198,7 @@ func (ciu *ConfigItemUpdate) sqlSave(ctx context.Context) (n int, err error) { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{configitem.Label} } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{err.Error(), err} + err = &ConstraintError{msg: err.Error(), wrap: err} } return 0, err } @@ -287,9 +287,15 @@ func (ciuo *ConfigItemUpdateOne) Save(ctx context.Context) (*ConfigItem, error) } mut = ciuo.hooks[i](mut) } - if _, err := mut.Mutate(ctx, ciuo.mutation); err != nil { + v, err := mut.Mutate(ctx, ciuo.mutation) + if err != nil { return nil, err } + nv, ok := v.(*ConfigItem) + if !ok { + return nil, fmt.Errorf("unexpected node type %T returned from ConfigItemMutation", v) + } + node = nv } return node, err } @@ -410,7 +416,7 @@ func (ciuo *ConfigItemUpdateOne) sqlSave(ctx context.Context) (_node *ConfigItem if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{configitem.Label} } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{err.Error(), err} + err = &ConstraintError{msg: err.Error(), wrap: err} } return nil, err } diff --git a/pkg/database/ent/decision.go b/pkg/database/ent/decision.go index f25ad2568..ef16b39ca 100644 --- a/pkg/database/ent/decision.go +++ b/pkg/database/ent/decision.go @@ -291,7 +291,8 @@ func (d *Decision) String() string { builder.WriteString(", ") builder.WriteString("simulated=") builder.WriteString(fmt.Sprintf("%v", d.Simulated)) - builder.WriteString(", uuid=") + builder.WriteString(", ") + builder.WriteString("uuid=") builder.WriteString(d.UUID) builder.WriteByte(')') return builder.String() diff --git a/pkg/database/ent/decision/where.go b/pkg/database/ent/decision/where.go index 5d050c316..378f687b7 100644 --- a/pkg/database/ent/decision/where.go +++ b/pkg/database/ent/decision/where.go @@ -1335,34 +1335,22 @@ func UUIDNEQ(v string) predicate.Decision { // UUIDIn applies the In predicate on the "uuid" field. func UUIDIn(vs ...string) predicate.Decision { - v := make([]interface{}, len(vs)) + v := make([]any, len(vs)) for i := range v { v[i] = vs[i] } return predicate.Decision(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } s.Where(sql.In(s.C(FieldUUID), v...)) }) } // UUIDNotIn applies the NotIn predicate on the "uuid" field. func UUIDNotIn(vs ...string) predicate.Decision { - v := make([]interface{}, len(vs)) + v := make([]any, len(vs)) for i := range v { v[i] = vs[i] } return predicate.Decision(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } s.Where(sql.NotIn(s.C(FieldUUID), v...)) }) } diff --git a/pkg/database/ent/migrate/schema.go b/pkg/database/ent/migrate/schema.go index b928fa90b..89a660a10 100644 --- a/pkg/database/ent/migrate/schema.go +++ b/pkg/database/ent/migrate/schema.go @@ -176,7 +176,7 @@ var ( {Name: "machine_id", Type: field.TypeString, Unique: true}, {Name: "password", Type: field.TypeString}, {Name: "ip_address", Type: field.TypeString}, - {Name: "scenarios", Type: field.TypeString, Nullable: true, Size: 4095}, + {Name: "scenarios", Type: field.TypeString, Nullable: true, Size: 100000}, {Name: "version", Type: field.TypeString, Nullable: true}, {Name: "is_validated", Type: field.TypeBool, Default: false}, {Name: "status", Type: field.TypeString, Nullable: true}, diff --git a/pkg/database/ent/schema/machine.go b/pkg/database/ent/schema/machine.go index f711bc612..e155c9360 100644 --- a/pkg/database/ent/schema/machine.go +++ b/pkg/database/ent/schema/machine.go @@ -30,7 +30,7 @@ func (Machine) Fields() []ent.Field { field.String("machineId").Unique(), field.String("password").Sensitive(), field.String("ipAddress"), - field.String("scenarios").MaxLen(4095).Optional(), + field.String("scenarios").MaxLen(100000).Optional(), field.String("version").Optional(), field.Bool("isValidated"). Default(false),