forked from ALHP/ALHP.GO
regen ent with version 0.10.0
This commit is contained in:
@@ -4,6 +4,7 @@ package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -83,7 +84,7 @@ func withDbPackageID(id int) dbpackageOption {
|
||||
m.oldValue = func(ctx context.Context) (*DbPackage, error) {
|
||||
once.Do(func() {
|
||||
if m.done {
|
||||
err = fmt.Errorf("querying old values post mutation is not allowed")
|
||||
err = errors.New("querying old values post mutation is not allowed")
|
||||
} else {
|
||||
value, err = m.Client().DbPackage.Get(ctx, id)
|
||||
}
|
||||
@@ -116,7 +117,7 @@ func (m DbPackageMutation) Client() *Client {
|
||||
// it returns an error otherwise.
|
||||
func (m DbPackageMutation) Tx() (*Tx, error) {
|
||||
if _, ok := m.driver.(*txDriver); !ok {
|
||||
return nil, fmt.Errorf("ent: mutation is not running in a transaction")
|
||||
return nil, errors.New("ent: mutation is not running in a transaction")
|
||||
}
|
||||
tx := &Tx{config: m.config}
|
||||
tx.init()
|
||||
@@ -132,6 +133,25 @@ func (m *DbPackageMutation) ID() (id int, exists bool) {
|
||||
return *m.id, true
|
||||
}
|
||||
|
||||
// IDs queries the database and returns the entity ids that match the mutation's predicate.
|
||||
// That means, if the mutation is applied within a transaction with an isolation level such
|
||||
// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
|
||||
// or updated by the mutation.
|
||||
func (m *DbPackageMutation) IDs(ctx context.Context) ([]int, error) {
|
||||
switch {
|
||||
case m.op.Is(OpUpdateOne | OpDeleteOne):
|
||||
id, exists := m.ID()
|
||||
if exists {
|
||||
return []int{id}, nil
|
||||
}
|
||||
fallthrough
|
||||
case m.op.Is(OpUpdate | OpDelete):
|
||||
return m.Client().DbPackage.Query().Where(m.predicates...).IDs(ctx)
|
||||
default:
|
||||
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
|
||||
}
|
||||
}
|
||||
|
||||
// SetPkgbase sets the "pkgbase" field.
|
||||
func (m *DbPackageMutation) SetPkgbase(s string) {
|
||||
m.pkgbase = &s
|
||||
@@ -151,10 +171,10 @@ func (m *DbPackageMutation) Pkgbase() (r string, exists bool) {
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *DbPackageMutation) OldPkgbase(ctx context.Context) (v string, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, fmt.Errorf("OldPkgbase is only allowed on UpdateOne operations")
|
||||
return v, errors.New("OldPkgbase is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, fmt.Errorf("OldPkgbase requires an ID field in the mutation")
|
||||
return v, errors.New("OldPkgbase requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
@@ -187,10 +207,10 @@ func (m *DbPackageMutation) Packages() (r []string, exists bool) {
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *DbPackageMutation) OldPackages(ctx context.Context) (v []string, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, fmt.Errorf("OldPackages is only allowed on UpdateOne operations")
|
||||
return v, errors.New("OldPackages is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, fmt.Errorf("OldPackages requires an ID field in the mutation")
|
||||
return v, errors.New("OldPackages requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
@@ -236,10 +256,10 @@ func (m *DbPackageMutation) Status() (r dbpackage.Status, exists bool) {
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *DbPackageMutation) OldStatus(ctx context.Context) (v dbpackage.Status, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, fmt.Errorf("OldStatus is only allowed on UpdateOne operations")
|
||||
return v, errors.New("OldStatus is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, fmt.Errorf("OldStatus requires an ID field in the mutation")
|
||||
return v, errors.New("OldStatus requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
@@ -285,10 +305,10 @@ func (m *DbPackageMutation) SkipReason() (r string, exists bool) {
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *DbPackageMutation) OldSkipReason(ctx context.Context) (v string, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, fmt.Errorf("OldSkipReason is only allowed on UpdateOne operations")
|
||||
return v, errors.New("OldSkipReason is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, fmt.Errorf("OldSkipReason requires an ID field in the mutation")
|
||||
return v, errors.New("OldSkipReason requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
@@ -334,10 +354,10 @@ func (m *DbPackageMutation) Repository() (r dbpackage.Repository, exists bool) {
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *DbPackageMutation) OldRepository(ctx context.Context) (v dbpackage.Repository, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, fmt.Errorf("OldRepository is only allowed on UpdateOne operations")
|
||||
return v, errors.New("OldRepository is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, fmt.Errorf("OldRepository requires an ID field in the mutation")
|
||||
return v, errors.New("OldRepository requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
@@ -370,10 +390,10 @@ func (m *DbPackageMutation) March() (r string, exists bool) {
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *DbPackageMutation) OldMarch(ctx context.Context) (v string, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, fmt.Errorf("OldMarch is only allowed on UpdateOne operations")
|
||||
return v, errors.New("OldMarch is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, fmt.Errorf("OldMarch requires an ID field in the mutation")
|
||||
return v, errors.New("OldMarch requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
@@ -406,10 +426,10 @@ func (m *DbPackageMutation) Version() (r string, exists bool) {
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *DbPackageMutation) OldVersion(ctx context.Context) (v string, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, fmt.Errorf("OldVersion is only allowed on UpdateOne operations")
|
||||
return v, errors.New("OldVersion is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, fmt.Errorf("OldVersion requires an ID field in the mutation")
|
||||
return v, errors.New("OldVersion requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
@@ -455,10 +475,10 @@ func (m *DbPackageMutation) RepoVersion() (r string, exists bool) {
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *DbPackageMutation) OldRepoVersion(ctx context.Context) (v string, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, fmt.Errorf("OldRepoVersion is only allowed on UpdateOne operations")
|
||||
return v, errors.New("OldRepoVersion is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, fmt.Errorf("OldRepoVersion requires an ID field in the mutation")
|
||||
return v, errors.New("OldRepoVersion requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
@@ -504,10 +524,10 @@ func (m *DbPackageMutation) BuildTimeStart() (r time.Time, exists bool) {
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *DbPackageMutation) OldBuildTimeStart(ctx context.Context) (v time.Time, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, fmt.Errorf("OldBuildTimeStart is only allowed on UpdateOne operations")
|
||||
return v, errors.New("OldBuildTimeStart is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, fmt.Errorf("OldBuildTimeStart requires an ID field in the mutation")
|
||||
return v, errors.New("OldBuildTimeStart requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
@@ -553,10 +573,10 @@ func (m *DbPackageMutation) BuildTimeEnd() (r time.Time, exists bool) {
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *DbPackageMutation) OldBuildTimeEnd(ctx context.Context) (v time.Time, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, fmt.Errorf("OldBuildTimeEnd is only allowed on UpdateOne operations")
|
||||
return v, errors.New("OldBuildTimeEnd is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, fmt.Errorf("OldBuildTimeEnd requires an ID field in the mutation")
|
||||
return v, errors.New("OldBuildTimeEnd requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
@@ -602,10 +622,10 @@ func (m *DbPackageMutation) Updated() (r time.Time, exists bool) {
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *DbPackageMutation) OldUpdated(ctx context.Context) (v time.Time, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, fmt.Errorf("OldUpdated is only allowed on UpdateOne operations")
|
||||
return v, errors.New("OldUpdated is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, fmt.Errorf("OldUpdated requires an ID field in the mutation")
|
||||
return v, errors.New("OldUpdated requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
@@ -651,10 +671,10 @@ func (m *DbPackageMutation) Hash() (r string, exists bool) {
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *DbPackageMutation) OldHash(ctx context.Context) (v string, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, fmt.Errorf("OldHash is only allowed on UpdateOne operations")
|
||||
return v, errors.New("OldHash is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, fmt.Errorf("OldHash requires an ID field in the mutation")
|
||||
return v, errors.New("OldHash requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
@@ -700,10 +720,10 @@ func (m *DbPackageMutation) Lto() (r dbpackage.Lto, exists bool) {
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *DbPackageMutation) OldLto(ctx context.Context) (v dbpackage.Lto, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, fmt.Errorf("OldLto is only allowed on UpdateOne operations")
|
||||
return v, errors.New("OldLto is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, fmt.Errorf("OldLto requires an ID field in the mutation")
|
||||
return v, errors.New("OldLto requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
@@ -749,10 +769,10 @@ func (m *DbPackageMutation) LastVersionBuild() (r string, exists bool) {
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *DbPackageMutation) OldLastVersionBuild(ctx context.Context) (v string, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, fmt.Errorf("OldLastVersionBuild is only allowed on UpdateOne operations")
|
||||
return v, errors.New("OldLastVersionBuild is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, fmt.Errorf("OldLastVersionBuild requires an ID field in the mutation")
|
||||
return v, errors.New("OldLastVersionBuild requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
@@ -798,10 +818,10 @@ func (m *DbPackageMutation) LastVerified() (r time.Time, exists bool) {
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *DbPackageMutation) OldLastVerified(ctx context.Context) (v time.Time, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, fmt.Errorf("OldLastVerified is only allowed on UpdateOne operations")
|
||||
return v, errors.New("OldLastVerified is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, fmt.Errorf("OldLastVerified requires an ID field in the mutation")
|
||||
return v, errors.New("OldLastVerified requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user