updated deps; regen ent

This commit is contained in:
2022-11-03 02:19:19 +01:00
parent 4b256dd594
commit ff3bbe0037
44 changed files with 938 additions and 2309 deletions

View File

@@ -333,6 +333,11 @@ func (mq *MessagesQuery) Select(fields ...string) *MessagesSelect {
return selbuild
}
// Aggregate returns a MessagesSelect configured with the given aggregations.
func (mq *MessagesQuery) Aggregate(fns ...AggregateFunc) *MessagesSelect {
return mq.Select().Aggregate(fns...)
}
func (mq *MessagesQuery) prepareQuery(ctx context.Context) error {
for _, f := range mq.fields {
if !messages.ValidColumn(f) {
@@ -364,10 +369,10 @@ func (mq *MessagesQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Mes
if withFKs {
_spec.Node.Columns = append(_spec.Node.Columns, messages.ForeignKeys...)
}
_spec.ScanValues = func(columns []string) ([]interface{}, error) {
_spec.ScanValues = func(columns []string) ([]any, error) {
return (*Messages).scanValues(nil, columns)
}
_spec.Assign = func(columns []string, values []interface{}) error {
_spec.Assign = func(columns []string, values []any) error {
node := &Messages{config: mq.config}
nodes = append(nodes, node)
node.Edges.loadedTypes = loadedTypes
@@ -437,11 +442,14 @@ func (mq *MessagesQuery) sqlCount(ctx context.Context) (int, error) {
}
func (mq *MessagesQuery) sqlExist(ctx context.Context) (bool, error) {
n, err := mq.sqlCount(ctx)
if err != nil {
switch _, err := mq.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 (mq *MessagesQuery) querySpec() *sqlgraph.QuerySpec {
@@ -551,7 +559,7 @@ func (mgb *MessagesGroupBy) Aggregate(fns ...AggregateFunc) *MessagesGroupBy {
}
// Scan applies the group-by query and scans the result into the given value.
func (mgb *MessagesGroupBy) Scan(ctx context.Context, v interface{}) error {
func (mgb *MessagesGroupBy) Scan(ctx context.Context, v any) error {
query, err := mgb.path(ctx)
if err != nil {
return err
@@ -560,7 +568,7 @@ func (mgb *MessagesGroupBy) Scan(ctx context.Context, v interface{}) error {
return mgb.sqlScan(ctx, v)
}
func (mgb *MessagesGroupBy) sqlScan(ctx context.Context, v interface{}) error {
func (mgb *MessagesGroupBy) sqlScan(ctx context.Context, v any) error {
for _, f := range mgb.fields {
if !messages.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)}
@@ -585,8 +593,6 @@ func (mgb *MessagesGroupBy) sqlQuery() *sql.Selector {
for _, fn := range mgb.fns {
aggregation = append(aggregation, fn(selector))
}
// If no columns were selected in a custom aggregation function, the default
// selection is the fields used for "group-by", and the aggregation functions.
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(mgb.fields)+len(mgb.fns))
for _, f := range mgb.fields {
@@ -606,8 +612,14 @@ type MessagesSelect struct {
sql *sql.Selector
}
// Aggregate adds the given aggregation functions to the selector query.
func (ms *MessagesSelect) Aggregate(fns ...AggregateFunc) *MessagesSelect {
ms.fns = append(ms.fns, fns...)
return ms
}
// Scan applies the selector query and scans the result into the given value.
func (ms *MessagesSelect) Scan(ctx context.Context, v interface{}) error {
func (ms *MessagesSelect) Scan(ctx context.Context, v any) error {
if err := ms.prepareQuery(ctx); err != nil {
return err
}
@@ -615,7 +627,17 @@ func (ms *MessagesSelect) Scan(ctx context.Context, v interface{}) error {
return ms.sqlScan(ctx, v)
}
func (ms *MessagesSelect) sqlScan(ctx context.Context, v interface{}) error {
func (ms *MessagesSelect) sqlScan(ctx context.Context, v any) error {
aggregation := make([]string, 0, len(ms.fns))
for _, fn := range ms.fns {
aggregation = append(aggregation, fn(ms.sql))
}
switch n := len(*ms.selector.flds); {
case n == 0 && len(aggregation) > 0:
ms.sql.Select(aggregation...)
case n != 0 && len(aggregation) > 0:
ms.sql.AppendSelect(aggregation...)
}
rows := &sql.Rows{}
query, args := ms.sql.Query()
if err := ms.driver.Query(ctx, query, args, rows); err != nil {