forked from ALHP/ALHP.GO
updated deps; regen ent
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"somegit.dev/ALHP/ALHP.GO/ent/dbpackage"
|
||||
)
|
||||
@@ -62,7 +63,8 @@ type DbPackage struct {
|
||||
// SrcinfoHash holds the value of the "srcinfo_hash" field.
|
||||
SrcinfoHash string `json:"srcinfo_hash,omitempty"`
|
||||
// Pkgbuild holds the value of the "pkgbuild" field.
|
||||
Pkgbuild string `json:"pkgbuild,omitempty"`
|
||||
Pkgbuild string `json:"pkgbuild,omitempty"`
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
@@ -79,7 +81,7 @@ func (*DbPackage) scanValues(columns []string) ([]any, error) {
|
||||
case dbpackage.FieldBuildTimeStart, dbpackage.FieldUpdated, dbpackage.FieldLastVerified:
|
||||
values[i] = new(sql.NullTime)
|
||||
default:
|
||||
return nil, fmt.Errorf("unexpected column %q for type DbPackage", columns[i])
|
||||
values[i] = new(sql.UnknownType)
|
||||
}
|
||||
}
|
||||
return values, nil
|
||||
@@ -245,11 +247,19 @@ func (dp *DbPackage) assignValues(columns []string, values []any) error {
|
||||
} else if value.Valid {
|
||||
dp.Pkgbuild = value.String
|
||||
}
|
||||
default:
|
||||
dp.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the DbPackage.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (dp *DbPackage) Value(name string) (ent.Value, error) {
|
||||
return dp.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this DbPackage.
|
||||
// Note that you need to call DbPackage.Unwrap() before calling this method if this DbPackage
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
|
@@ -4,6 +4,8 @@ package dbpackage
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -217,3 +219,121 @@ func DebugSymbolsValidator(ds DebugSymbols) error {
|
||||
return fmt.Errorf("dbpackage: invalid enum value for debug_symbols field: %q", ds)
|
||||
}
|
||||
}
|
||||
|
||||
// OrderOption defines the ordering options for the DbPackage queries.
|
||||
type OrderOption func(*sql.Selector)
|
||||
|
||||
// ByID orders the results by the id field.
|
||||
func ByID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByPkgbase orders the results by the pkgbase field.
|
||||
func ByPkgbase(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldPkgbase, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByStatus orders the results by the status field.
|
||||
func ByStatus(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldStatus, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// BySkipReason orders the results by the skip_reason field.
|
||||
func BySkipReason(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldSkipReason, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByRepository orders the results by the repository field.
|
||||
func ByRepository(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldRepository, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByMarch orders the results by the march field.
|
||||
func ByMarch(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldMarch, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByVersion orders the results by the version field.
|
||||
func ByVersion(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldVersion, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByRepoVersion orders the results by the repo_version field.
|
||||
func ByRepoVersion(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldRepoVersion, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByBuildTimeStart orders the results by the build_time_start field.
|
||||
func ByBuildTimeStart(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldBuildTimeStart, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByUpdated orders the results by the updated field.
|
||||
func ByUpdated(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldUpdated, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByHash orders the results by the hash field.
|
||||
func ByHash(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldHash, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByLto orders the results by the lto field.
|
||||
func ByLto(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldLto, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByLastVersionBuild orders the results by the last_version_build field.
|
||||
func ByLastVersionBuild(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldLastVersionBuild, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByLastVerified orders the results by the last_verified field.
|
||||
func ByLastVerified(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldLastVerified, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByDebugSymbols orders the results by the debug_symbols field.
|
||||
func ByDebugSymbols(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldDebugSymbols, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByMaxRss orders the results by the max_rss field.
|
||||
func ByMaxRss(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldMaxRss, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByUTime orders the results by the u_time field.
|
||||
func ByUTime(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldUTime, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// BySTime orders the results by the s_time field.
|
||||
func BySTime(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldSTime, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByIoIn orders the results by the io_in field.
|
||||
func ByIoIn(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldIoIn, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByIoOut orders the results by the io_out field.
|
||||
func ByIoOut(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldIoOut, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// BySrcinfo orders the results by the srcinfo field.
|
||||
func BySrcinfo(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldSrcinfo, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// BySrcinfoHash orders the results by the srcinfo_hash field.
|
||||
func BySrcinfoHash(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldSrcinfoHash, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByPkgbuild orders the results by the pkgbuild field.
|
||||
func ByPkgbuild(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldPkgbuild, opts...).ToFunc()
|
||||
}
|
||||
|
@@ -318,7 +318,7 @@ func (dpc *DbPackageCreate) Mutation() *DbPackageMutation {
|
||||
// Save creates the DbPackage in the database.
|
||||
func (dpc *DbPackageCreate) Save(ctx context.Context) (*DbPackage, error) {
|
||||
dpc.defaults()
|
||||
return withHooks[*DbPackage, DbPackageMutation](ctx, dpc.sqlSave, dpc.mutation, dpc.hooks)
|
||||
return withHooks(ctx, dpc.sqlSave, dpc.mutation, dpc.hooks)
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
@@ -545,8 +545,8 @@ func (dpcb *DbPackageCreateBulk) Save(ctx context.Context) ([]*DbPackage, error)
|
||||
return nil, err
|
||||
}
|
||||
builder.mutation = mutation
|
||||
nodes[i], specs[i] = builder.createSpec()
|
||||
var err error
|
||||
nodes[i], specs[i] = builder.createSpec()
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, dpcb.builders[i+1].mutation)
|
||||
} else {
|
||||
|
@@ -27,7 +27,7 @@ func (dpd *DbPackageDelete) Where(ps ...predicate.DbPackage) *DbPackageDelete {
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (dpd *DbPackageDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks[int, DbPackageMutation](ctx, dpd.sqlExec, dpd.mutation, dpd.hooks)
|
||||
return withHooks(ctx, dpd.sqlExec, dpd.mutation, dpd.hooks)
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
|
@@ -18,7 +18,7 @@ import (
|
||||
type DbPackageQuery struct {
|
||||
config
|
||||
ctx *QueryContext
|
||||
order []OrderFunc
|
||||
order []dbpackage.OrderOption
|
||||
inters []Interceptor
|
||||
predicates []predicate.DbPackage
|
||||
modifiers []func(*sql.Selector)
|
||||
@@ -53,7 +53,7 @@ func (dpq *DbPackageQuery) Unique(unique bool) *DbPackageQuery {
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (dpq *DbPackageQuery) Order(o ...OrderFunc) *DbPackageQuery {
|
||||
func (dpq *DbPackageQuery) Order(o ...dbpackage.OrderOption) *DbPackageQuery {
|
||||
dpq.order = append(dpq.order, o...)
|
||||
return dpq
|
||||
}
|
||||
@@ -247,7 +247,7 @@ func (dpq *DbPackageQuery) Clone() *DbPackageQuery {
|
||||
return &DbPackageQuery{
|
||||
config: dpq.config,
|
||||
ctx: dpq.ctx.Clone(),
|
||||
order: append([]OrderFunc{}, dpq.order...),
|
||||
order: append([]dbpackage.OrderOption{}, dpq.order...),
|
||||
inters: append([]Interceptor{}, dpq.inters...),
|
||||
predicates: append([]predicate.DbPackage{}, dpq.predicates...),
|
||||
// clone intermediate query.
|
||||
|
@@ -476,7 +476,7 @@ func (dpu *DbPackageUpdate) Mutation() *DbPackageMutation {
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (dpu *DbPackageUpdate) Save(ctx context.Context) (int, error) {
|
||||
return withHooks[int, DbPackageMutation](ctx, dpu.sqlSave, dpu.mutation, dpu.hooks)
|
||||
return withHooks(ctx, dpu.sqlSave, dpu.mutation, dpu.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
@@ -1168,7 +1168,7 @@ func (dpuo *DbPackageUpdateOne) Select(field string, fields ...string) *DbPackag
|
||||
|
||||
// Save executes the query and returns the updated DbPackage entity.
|
||||
func (dpuo *DbPackageUpdateOne) Save(ctx context.Context) (*DbPackage, error) {
|
||||
return withHooks[*DbPackage, DbPackageMutation](ctx, dpuo.sqlSave, dpuo.mutation, dpuo.hooks)
|
||||
return withHooks(ctx, dpuo.sqlSave, dpuo.mutation, dpuo.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
|
56
ent/ent.go
56
ent/ent.go
@@ -7,6 +7,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"sync"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
@@ -60,33 +61,29 @@ func NewTxContext(parent context.Context, tx *Tx) context.Context {
|
||||
}
|
||||
|
||||
// OrderFunc applies an ordering on the sql selector.
|
||||
// Deprecated: Use Asc/Desc functions or the package builders instead.
|
||||
type OrderFunc func(*sql.Selector)
|
||||
|
||||
// columnChecker returns a function indicates if the column exists in the given column.
|
||||
func columnChecker(table string) func(string) error {
|
||||
checks := map[string]func(string) bool{
|
||||
dbpackage.Table: dbpackage.ValidColumn,
|
||||
}
|
||||
check, ok := checks[table]
|
||||
if !ok {
|
||||
return func(string) error {
|
||||
return fmt.Errorf("unknown table %q", table)
|
||||
}
|
||||
}
|
||||
return func(column string) error {
|
||||
if !check(column) {
|
||||
return fmt.Errorf("unknown column %q for table %q", column, table)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
var (
|
||||
initCheck sync.Once
|
||||
columnCheck sql.ColumnCheck
|
||||
)
|
||||
|
||||
// columnChecker 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{
|
||||
dbpackage.Table: dbpackage.ValidColumn,
|
||||
})
|
||||
})
|
||||
return columnCheck(table, column)
|
||||
}
|
||||
|
||||
// Asc applies the given fields in ASC order.
|
||||
func Asc(fields ...string) OrderFunc {
|
||||
func Asc(fields ...string) func(*sql.Selector) {
|
||||
return func(s *sql.Selector) {
|
||||
check := columnChecker(s.TableName())
|
||||
for _, f := range fields {
|
||||
if err := check(f); err != nil {
|
||||
if err := checkColumn(s.TableName(), f); err != nil {
|
||||
s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)})
|
||||
}
|
||||
s.OrderBy(sql.Asc(s.C(f)))
|
||||
@@ -95,11 +92,10 @@ func Asc(fields ...string) OrderFunc {
|
||||
}
|
||||
|
||||
// Desc applies the given fields in DESC order.
|
||||
func Desc(fields ...string) OrderFunc {
|
||||
func Desc(fields ...string) func(*sql.Selector) {
|
||||
return func(s *sql.Selector) {
|
||||
check := columnChecker(s.TableName())
|
||||
for _, f := range fields {
|
||||
if err := check(f); err != nil {
|
||||
if err := checkColumn(s.TableName(), f); err != nil {
|
||||
s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)})
|
||||
}
|
||||
s.OrderBy(sql.Desc(s.C(f)))
|
||||
@@ -131,8 +127,7 @@ func Count() AggregateFunc {
|
||||
// Max applies the "max" aggregation function on the given field of each group.
|
||||
func Max(field string) AggregateFunc {
|
||||
return func(s *sql.Selector) string {
|
||||
check := columnChecker(s.TableName())
|
||||
if err := check(field); err != nil {
|
||||
if err := checkColumn(s.TableName(), field); err != nil {
|
||||
s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)})
|
||||
return ""
|
||||
}
|
||||
@@ -143,8 +138,7 @@ func Max(field string) AggregateFunc {
|
||||
// Mean applies the "mean" aggregation function on the given field of each group.
|
||||
func Mean(field string) AggregateFunc {
|
||||
return func(s *sql.Selector) string {
|
||||
check := columnChecker(s.TableName())
|
||||
if err := check(field); err != nil {
|
||||
if err := checkColumn(s.TableName(), field); err != nil {
|
||||
s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)})
|
||||
return ""
|
||||
}
|
||||
@@ -155,8 +149,7 @@ func Mean(field string) AggregateFunc {
|
||||
// Min applies the "min" aggregation function on the given field of each group.
|
||||
func Min(field string) AggregateFunc {
|
||||
return func(s *sql.Selector) string {
|
||||
check := columnChecker(s.TableName())
|
||||
if err := check(field); err != nil {
|
||||
if err := checkColumn(s.TableName(), field); err != nil {
|
||||
s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)})
|
||||
return ""
|
||||
}
|
||||
@@ -167,8 +160,7 @@ func Min(field string) AggregateFunc {
|
||||
// Sum applies the "sum" aggregation function on the given field of each group.
|
||||
func Sum(field string) AggregateFunc {
|
||||
return func(s *sql.Selector) string {
|
||||
check := columnChecker(s.TableName())
|
||||
if err := check(field); err != nil {
|
||||
if err := checkColumn(s.TableName(), field); err != nil {
|
||||
s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)})
|
||||
return ""
|
||||
}
|
||||
@@ -505,7 +497,7 @@ func withHooks[V Value, M any, PM interface {
|
||||
return exec(ctx)
|
||||
}
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutationT, ok := m.(PM)
|
||||
mutationT, ok := any(m).(PM)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
|
@@ -5,6 +5,6 @@ package runtime
|
||||
// The schema-stitching logic is generated in somegit.dev/ALHP/ALHP.GO/ent/runtime.go
|
||||
|
||||
const (
|
||||
Version = "v0.11.9" // Version of ent codegen.
|
||||
Sum = "h1:dbbCkAiPVTRBIJwoZctiSYjB7zxQIBOzVSU5H9VYIQI=" // Sum of ent codegen.
|
||||
Version = "v0.12.3" // Version of ent codegen.
|
||||
Sum = "h1:N5lO2EOrHpCH5HYfiMOCHYbo+oh5M8GjT0/cx5x6xkk=" // Sum of ent codegen.
|
||||
)
|
||||
|
Reference in New Issue
Block a user