forked from ALHP/ALHP.GO
updated dep. and regen ent
This commit is contained in:
@@ -84,7 +84,6 @@ func (dp *DbPackage) assignValues(columns []string, values []interface{}) error
|
||||
dp.Pkgbase = value.String
|
||||
}
|
||||
case dbpackage.FieldPackages:
|
||||
|
||||
if value, ok := values[i].(*[]byte); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field packages", values[i])
|
||||
} else if value != nil && len(*value) > 0 {
|
||||
|
@@ -183,11 +183,17 @@ func (dpc *DbPackageCreate) Save(ctx context.Context) (*DbPackage, error) {
|
||||
return nil, err
|
||||
}
|
||||
dpc.mutation = mutation
|
||||
node, err = dpc.sqlSave(ctx)
|
||||
if node, err = dpc.sqlSave(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mutation.id = &node.ID
|
||||
mutation.done = true
|
||||
return node, err
|
||||
})
|
||||
for i := len(dpc.hooks) - 1; i >= 0; i-- {
|
||||
if dpc.hooks[i] == nil {
|
||||
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
|
||||
}
|
||||
mut = dpc.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, dpc.mutation); err != nil {
|
||||
@@ -206,6 +212,19 @@ func (dpc *DbPackageCreate) SaveX(ctx context.Context) *DbPackage {
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (dpc *DbPackageCreate) Exec(ctx context.Context) error {
|
||||
_, err := dpc.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (dpc *DbPackageCreate) ExecX(ctx context.Context) {
|
||||
if err := dpc.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (dpc *DbPackageCreate) defaults() {
|
||||
if _, ok := dpc.mutation.Status(); !ok {
|
||||
@@ -217,40 +236,40 @@ func (dpc *DbPackageCreate) defaults() {
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (dpc *DbPackageCreate) check() error {
|
||||
if _, ok := dpc.mutation.Pkgbase(); !ok {
|
||||
return &ValidationError{Name: "pkgbase", err: errors.New("ent: missing required field \"pkgbase\"")}
|
||||
return &ValidationError{Name: "pkgbase", err: errors.New(`ent: missing required field "pkgbase"`)}
|
||||
}
|
||||
if v, ok := dpc.mutation.Pkgbase(); ok {
|
||||
if err := dbpackage.PkgbaseValidator(v); err != nil {
|
||||
return &ValidationError{Name: "pkgbase", err: fmt.Errorf("ent: validator failed for field \"pkgbase\": %w", err)}
|
||||
return &ValidationError{Name: "pkgbase", err: fmt.Errorf(`ent: validator failed for field "pkgbase": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := dpc.mutation.Status(); !ok {
|
||||
return &ValidationError{Name: "status", err: errors.New("ent: missing required field \"status\"")}
|
||||
return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "status"`)}
|
||||
}
|
||||
if v, ok := dpc.mutation.Status(); ok {
|
||||
if err := dbpackage.StatusValidator(v); err != nil {
|
||||
return &ValidationError{Name: "status", err: fmt.Errorf("ent: validator failed for field \"status\": %w", err)}
|
||||
return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "status": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := dpc.mutation.Repository(); !ok {
|
||||
return &ValidationError{Name: "repository", err: errors.New("ent: missing required field \"repository\"")}
|
||||
return &ValidationError{Name: "repository", err: errors.New(`ent: missing required field "repository"`)}
|
||||
}
|
||||
if v, ok := dpc.mutation.Repository(); ok {
|
||||
if err := dbpackage.RepositoryValidator(v); err != nil {
|
||||
return &ValidationError{Name: "repository", err: fmt.Errorf("ent: validator failed for field \"repository\": %w", err)}
|
||||
return &ValidationError{Name: "repository", err: fmt.Errorf(`ent: validator failed for field "repository": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := dpc.mutation.March(); !ok {
|
||||
return &ValidationError{Name: "march", err: errors.New("ent: missing required field \"march\"")}
|
||||
return &ValidationError{Name: "march", err: errors.New(`ent: missing required field "march"`)}
|
||||
}
|
||||
if v, ok := dpc.mutation.March(); ok {
|
||||
if err := dbpackage.MarchValidator(v); err != nil {
|
||||
return &ValidationError{Name: "march", err: fmt.Errorf("ent: validator failed for field \"march\": %w", err)}
|
||||
return &ValidationError{Name: "march", err: fmt.Errorf(`ent: validator failed for field "march": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := dpc.mutation.BuildDuration(); ok {
|
||||
if err := dbpackage.BuildDurationValidator(v); err != nil {
|
||||
return &ValidationError{Name: "build_duration", err: fmt.Errorf("ent: validator failed for field \"build_duration\": %w", err)}
|
||||
return &ValidationError{Name: "build_duration", err: fmt.Errorf(`ent: validator failed for field "build_duration": %w`, err)}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -259,8 +278,8 @@ func (dpc *DbPackageCreate) check() error {
|
||||
func (dpc *DbPackageCreate) sqlSave(ctx context.Context) (*DbPackage, error) {
|
||||
_node, _spec := dpc.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, dpc.driver, _spec); err != nil {
|
||||
if cerr, ok := isSQLConstraintError(err); ok {
|
||||
err = cerr
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{err.Error(), err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
@@ -408,19 +427,23 @@ func (dpcb *DbPackageCreateBulk) Save(ctx context.Context) ([]*DbPackage, error)
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, dpcb.builders[i+1].mutation)
|
||||
} else {
|
||||
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
||||
// Invoke the actual operation on the latest mutation in the chain.
|
||||
if err = sqlgraph.BatchCreate(ctx, dpcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil {
|
||||
if cerr, ok := isSQLConstraintError(err); ok {
|
||||
err = cerr
|
||||
if err = sqlgraph.BatchCreate(ctx, dpcb.driver, spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{err.Error(), err}
|
||||
}
|
||||
}
|
||||
}
|
||||
mutation.done = true
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
id := specs[i].ID.Value.(int64)
|
||||
nodes[i].ID = int(id)
|
||||
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)
|
||||
}
|
||||
return nodes[i], nil
|
||||
})
|
||||
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
||||
@@ -445,3 +468,16 @@ func (dpcb *DbPackageCreateBulk) SaveX(ctx context.Context) []*DbPackage {
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (dpcb *DbPackageCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := dpcb.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (dpcb *DbPackageCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := dpcb.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
@@ -20,9 +20,9 @@ type DbPackageDelete struct {
|
||||
mutation *DbPackageMutation
|
||||
}
|
||||
|
||||
// Where adds a new predicate to the DbPackageDelete builder.
|
||||
// Where appends a list predicates to the DbPackageDelete builder.
|
||||
func (dpd *DbPackageDelete) Where(ps ...predicate.DbPackage) *DbPackageDelete {
|
||||
dpd.mutation.predicates = append(dpd.mutation.predicates, ps...)
|
||||
dpd.mutation.Where(ps...)
|
||||
return dpd
|
||||
}
|
||||
|
||||
@@ -46,6 +46,9 @@ func (dpd *DbPackageDelete) Exec(ctx context.Context) (int, error) {
|
||||
return affected, err
|
||||
})
|
||||
for i := len(dpd.hooks) - 1; i >= 0; i-- {
|
||||
if dpd.hooks[i] == nil {
|
||||
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
|
||||
}
|
||||
mut = dpd.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, dpd.mutation); err != nil {
|
||||
|
@@ -287,8 +287,8 @@ func (dpq *DbPackageQuery) GroupBy(field string, fields ...string) *DbPackageGro
|
||||
// Select(dbpackage.FieldPkgbase).
|
||||
// Scan(ctx, &v)
|
||||
//
|
||||
func (dpq *DbPackageQuery) Select(field string, fields ...string) *DbPackageSelect {
|
||||
dpq.fields = append([]string{field}, fields...)
|
||||
func (dpq *DbPackageQuery) Select(fields ...string) *DbPackageSelect {
|
||||
dpq.fields = append(dpq.fields, fields...)
|
||||
return &DbPackageSelect{DbPackageQuery: dpq}
|
||||
}
|
||||
|
||||
@@ -398,10 +398,14 @@ func (dpq *DbPackageQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
func (dpq *DbPackageQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(dpq.driver.Dialect())
|
||||
t1 := builder.Table(dbpackage.Table)
|
||||
selector := builder.Select(t1.Columns(dbpackage.Columns...)...).From(t1)
|
||||
columns := dpq.fields
|
||||
if len(columns) == 0 {
|
||||
columns = dbpackage.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if dpq.sql != nil {
|
||||
selector = dpq.sql
|
||||
selector.Select(selector.Columns(dbpackage.Columns...)...)
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
for _, p := range dpq.predicates {
|
||||
p(selector)
|
||||
@@ -669,13 +673,24 @@ func (dpgb *DbPackageGroupBy) sqlScan(ctx context.Context, v interface{}) error
|
||||
}
|
||||
|
||||
func (dpgb *DbPackageGroupBy) sqlQuery() *sql.Selector {
|
||||
selector := dpgb.sql
|
||||
columns := make([]string, 0, len(dpgb.fields)+len(dpgb.fns))
|
||||
columns = append(columns, dpgb.fields...)
|
||||
selector := dpgb.sql.Select()
|
||||
aggregation := make([]string, 0, len(dpgb.fns))
|
||||
for _, fn := range dpgb.fns {
|
||||
columns = append(columns, fn(selector))
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
return selector.Select(columns...).GroupBy(dpgb.fields...)
|
||||
// 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(dpgb.fields)+len(dpgb.fns))
|
||||
for _, f := range dpgb.fields {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
for _, c := range aggregation {
|
||||
columns = append(columns, c)
|
||||
}
|
||||
selector.Select(columns...)
|
||||
}
|
||||
return selector.GroupBy(selector.Columns(dpgb.fields...)...)
|
||||
}
|
||||
|
||||
// DbPackageSelect is the builder for selecting fields of DbPackage entities.
|
||||
@@ -891,16 +906,10 @@ func (dps *DbPackageSelect) BoolX(ctx context.Context) bool {
|
||||
|
||||
func (dps *DbPackageSelect) sqlScan(ctx context.Context, v interface{}) error {
|
||||
rows := &sql.Rows{}
|
||||
query, args := dps.sqlQuery().Query()
|
||||
query, args := dps.sql.Query()
|
||||
if err := dps.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
func (dps *DbPackageSelect) sqlQuery() sql.Querier {
|
||||
selector := dps.sql
|
||||
selector.Select(selector.Columns(dps.fields...)...)
|
||||
return selector
|
||||
}
|
||||
|
@@ -21,9 +21,9 @@ type DbPackageUpdate struct {
|
||||
mutation *DbPackageMutation
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the DbPackageUpdate builder.
|
||||
// Where appends a list predicates to the DbPackageUpdate builder.
|
||||
func (dpu *DbPackageUpdate) Where(ps ...predicate.DbPackage) *DbPackageUpdate {
|
||||
dpu.mutation.predicates = append(dpu.mutation.predicates, ps...)
|
||||
dpu.mutation.Where(ps...)
|
||||
return dpu
|
||||
}
|
||||
|
||||
@@ -250,6 +250,9 @@ func (dpu *DbPackageUpdate) Save(ctx context.Context) (int, error) {
|
||||
return affected, err
|
||||
})
|
||||
for i := len(dpu.hooks) - 1; i >= 0; i-- {
|
||||
if dpu.hooks[i] == nil {
|
||||
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
|
||||
}
|
||||
mut = dpu.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, dpu.mutation); err != nil {
|
||||
@@ -466,8 +469,8 @@ func (dpu *DbPackageUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, dpu.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{dbpackage.Label}
|
||||
} else if cerr, ok := isSQLConstraintError(err); ok {
|
||||
err = cerr
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{err.Error(), err}
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
@@ -712,6 +715,9 @@ func (dpuo *DbPackageUpdateOne) Save(ctx context.Context) (*DbPackage, error) {
|
||||
return node, err
|
||||
})
|
||||
for i := len(dpuo.hooks) - 1; i >= 0; i-- {
|
||||
if dpuo.hooks[i] == nil {
|
||||
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
|
||||
}
|
||||
mut = dpuo.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, dpuo.mutation); err != nil {
|
||||
@@ -948,8 +954,8 @@ func (dpuo *DbPackageUpdateOne) sqlSave(ctx context.Context) (_node *DbPackage,
|
||||
if err = sqlgraph.UpdateNode(ctx, dpuo.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{dbpackage.Label}
|
||||
} else if cerr, ok := isSQLConstraintError(err); ok {
|
||||
err = cerr
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{err.Error(), err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
22
ent/ent.go
22
ent/ent.go
@@ -8,9 +8,7 @@ import (
|
||||
|
||||
"ALHP.go/ent/dbpackage"
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
)
|
||||
|
||||
// ent aliases to avoid import conflicts in user's code.
|
||||
@@ -159,7 +157,7 @@ func (e *ValidationError) Unwrap() error {
|
||||
return e.err
|
||||
}
|
||||
|
||||
// IsValidationError returns a boolean indicating whether the error is a validaton error.
|
||||
// IsValidationError returns a boolean indicating whether the error is a validation error.
|
||||
func IsValidationError(err error) bool {
|
||||
if err == nil {
|
||||
return false
|
||||
@@ -259,21 +257,3 @@ func IsConstraintError(err error) bool {
|
||||
var e *ConstraintError
|
||||
return errors.As(err, &e)
|
||||
}
|
||||
|
||||
func isSQLConstraintError(err error) (*ConstraintError, bool) {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
return &ConstraintError{err.Error(), err}, true
|
||||
}
|
||||
return nil, false
|
||||
}
|
||||
|
||||
// rollback calls tx.Rollback and wraps the given error with the rollback error if present.
|
||||
func rollback(tx dialect.Tx, err error) error {
|
||||
if rerr := tx.Rollback(); rerr != nil {
|
||||
err = fmt.Errorf("%w: %v", err, rerr)
|
||||
}
|
||||
if err, ok := isSQLConstraintError(err); ok {
|
||||
return err
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
@@ -1,3 +0,0 @@
|
||||
package ent
|
||||
|
||||
//go:generate go run -mod=mod entgo.io/ent/cmd/ent generate ./schema
|
@@ -26,10 +26,9 @@ var (
|
||||
}
|
||||
// DbPackagesTable holds the schema information for the "db_packages" table.
|
||||
DbPackagesTable = &schema.Table{
|
||||
Name: "db_packages",
|
||||
Columns: DbPackagesColumns,
|
||||
PrimaryKey: []*schema.Column{DbPackagesColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{},
|
||||
Name: "db_packages",
|
||||
Columns: DbPackagesColumns,
|
||||
PrimaryKey: []*schema.Column{DbPackagesColumns[0]},
|
||||
}
|
||||
// Tables holds all the tables in the schema.
|
||||
Tables = []*schema.Table{
|
||||
|
@@ -122,8 +122,8 @@ func (m DbPackageMutation) Tx() (*Tx, error) {
|
||||
return tx, nil
|
||||
}
|
||||
|
||||
// ID returns the ID value in the mutation. Note that the ID
|
||||
// is only available if it was provided to the builder.
|
||||
// ID returns the ID value in the mutation. Note that the ID is only available
|
||||
// if it was provided to the builder or after it was returned from the database.
|
||||
func (m *DbPackageMutation) ID() (id int, exists bool) {
|
||||
if m.id == nil {
|
||||
return
|
||||
@@ -708,6 +708,11 @@ func (m *DbPackageMutation) ResetHash() {
|
||||
delete(m.clearedFields, dbpackage.FieldHash)
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the DbPackageMutation builder.
|
||||
func (m *DbPackageMutation) Where(ps ...predicate.DbPackage) {
|
||||
m.predicates = append(m.predicates, ps...)
|
||||
}
|
||||
|
||||
// Op returns the operation name.
|
||||
func (m *DbPackageMutation) Op() Op {
|
||||
return m.op
|
||||
|
@@ -5,6 +5,6 @@ package runtime
|
||||
// The schema-stitching logic is generated in ALHP.go/ent/runtime.go
|
||||
|
||||
const (
|
||||
Version = "v0.8.0" // Version of ent codegen.
|
||||
Sum = "h1:xirrW//1oda7pp0bz+XssSOv4/C3nmgYQOxjIfljFt8=" // Sum of ent codegen.
|
||||
Version = "v0.9.1" // Version of ent codegen.
|
||||
Sum = "h1:IG8andyeD79GG24U8Q+1Y45hQXj6gY5evSBcva5gtBk=" // Sum of ent codegen.
|
||||
)
|
||||
|
Reference in New Issue
Block a user