mirror of
https://github.com/netbirdio/dex.git
synced 2026-05-22 18:43:53 -07:00
@@ -86,29 +86,36 @@ jobs:
|
||||
DEX_MYSQL_PASSWORD: root
|
||||
DEX_MYSQL_HOST: 127.0.0.1
|
||||
DEX_MYSQL_PORT: ${{ job.services.mysql.ports[3306] }}
|
||||
|
||||
DEX_MYSQL_ENT_DATABASE: dex
|
||||
DEX_MYSQL_ENT_USER: root
|
||||
DEX_MYSQL_ENT_PASSWORD: root
|
||||
DEX_MYSQL_ENT_HOST: 127.0.0.1
|
||||
DEX_MYSQL_ENT_PORT: ${{ job.services.mysql-ent.ports[3306] }}
|
||||
|
||||
DEX_POSTGRES_DATABASE: postgres
|
||||
DEX_POSTGRES_USER: postgres
|
||||
DEX_POSTGRES_PASSWORD: postgres
|
||||
DEX_POSTGRES_HOST: localhost
|
||||
DEX_POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }}
|
||||
|
||||
DEX_POSTGRES_ENT_DATABASE: postgres
|
||||
DEX_POSTGRES_ENT_USER: postgres
|
||||
DEX_POSTGRES_ENT_PASSWORD: postgres
|
||||
DEX_POSTGRES_ENT_HOST: localhost
|
||||
DEX_POSTGRES_ENT_PORT: ${{ job.services.postgres-ent.ports[5432] }}
|
||||
|
||||
DEX_ETCD_ENDPOINTS: http://localhost:${{ job.services.etcd.ports[2379] }}
|
||||
|
||||
DEX_LDAP_HOST: localhost
|
||||
DEX_LDAP_PORT: 389
|
||||
DEX_LDAP_TLS_PORT: 636
|
||||
|
||||
DEX_KEYSTONE_URL: http://localhost:${{ job.services.keystone.ports[5000] }}
|
||||
DEX_KEYSTONE_ADMIN_URL: http://localhost:${{ job.services.keystone.ports[35357] }}
|
||||
DEX_KEYSTONE_ADMIN_USER: demo
|
||||
DEX_KEYSTONE_ADMIN_PASS: DEMO_PASS
|
||||
|
||||
DEX_KUBERNETES_CONFIG_PATH: ~/.kube/config
|
||||
|
||||
- name: Lint
|
||||
|
||||
@@ -90,7 +90,6 @@ func (ac *AuthCode) assignValues(columns []string, values []interface{}) error {
|
||||
ac.ClientID = value.String
|
||||
}
|
||||
case authcode.FieldScopes:
|
||||
|
||||
if value, ok := values[i].(*[]byte); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field scopes", values[i])
|
||||
} else if value != nil && len(*value) > 0 {
|
||||
@@ -135,7 +134,6 @@ func (ac *AuthCode) assignValues(columns []string, values []interface{}) error {
|
||||
ac.ClaimsEmailVerified = value.Bool
|
||||
}
|
||||
case authcode.FieldClaimsGroups:
|
||||
|
||||
if value, ok := values[i].(*[]byte); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field claims_groups", values[i])
|
||||
} else if value != nil && len(*value) > 0 {
|
||||
|
||||
@@ -167,11 +167,17 @@ func (acc *AuthCodeCreate) Save(ctx context.Context) (*AuthCode, error) {
|
||||
return nil, err
|
||||
}
|
||||
acc.mutation = mutation
|
||||
node, err = acc.sqlSave(ctx)
|
||||
if node, err = acc.sqlSave(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mutation.id = &node.ID
|
||||
mutation.done = true
|
||||
return node, err
|
||||
})
|
||||
for i := len(acc.hooks) - 1; i >= 0; i-- {
|
||||
if acc.hooks[i] == nil {
|
||||
return nil, fmt.Errorf("db: uninitialized hook (forgotten import db/runtime?)")
|
||||
}
|
||||
mut = acc.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, acc.mutation); err != nil {
|
||||
@@ -190,6 +196,19 @@ func (acc *AuthCodeCreate) SaveX(ctx context.Context) *AuthCode {
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (acc *AuthCodeCreate) Exec(ctx context.Context) error {
|
||||
_, err := acc.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (acc *AuthCodeCreate) ExecX(ctx context.Context) {
|
||||
if err := acc.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (acc *AuthCodeCreate) defaults() {
|
||||
if _, ok := acc.mutation.ClaimsPreferredUsername(); !ok {
|
||||
@@ -209,79 +228,79 @@ func (acc *AuthCodeCreate) defaults() {
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (acc *AuthCodeCreate) check() error {
|
||||
if _, ok := acc.mutation.ClientID(); !ok {
|
||||
return &ValidationError{Name: "client_id", err: errors.New("db: missing required field \"client_id\"")}
|
||||
return &ValidationError{Name: "client_id", err: errors.New(`db: missing required field "client_id"`)}
|
||||
}
|
||||
if v, ok := acc.mutation.ClientID(); ok {
|
||||
if err := authcode.ClientIDValidator(v); err != nil {
|
||||
return &ValidationError{Name: "client_id", err: fmt.Errorf("db: validator failed for field \"client_id\": %w", err)}
|
||||
return &ValidationError{Name: "client_id", err: fmt.Errorf(`db: validator failed for field "client_id": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := acc.mutation.Nonce(); !ok {
|
||||
return &ValidationError{Name: "nonce", err: errors.New("db: missing required field \"nonce\"")}
|
||||
return &ValidationError{Name: "nonce", err: errors.New(`db: missing required field "nonce"`)}
|
||||
}
|
||||
if v, ok := acc.mutation.Nonce(); ok {
|
||||
if err := authcode.NonceValidator(v); err != nil {
|
||||
return &ValidationError{Name: "nonce", err: fmt.Errorf("db: validator failed for field \"nonce\": %w", err)}
|
||||
return &ValidationError{Name: "nonce", err: fmt.Errorf(`db: validator failed for field "nonce": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := acc.mutation.RedirectURI(); !ok {
|
||||
return &ValidationError{Name: "redirect_uri", err: errors.New("db: missing required field \"redirect_uri\"")}
|
||||
return &ValidationError{Name: "redirect_uri", err: errors.New(`db: missing required field "redirect_uri"`)}
|
||||
}
|
||||
if v, ok := acc.mutation.RedirectURI(); ok {
|
||||
if err := authcode.RedirectURIValidator(v); err != nil {
|
||||
return &ValidationError{Name: "redirect_uri", err: fmt.Errorf("db: validator failed for field \"redirect_uri\": %w", err)}
|
||||
return &ValidationError{Name: "redirect_uri", err: fmt.Errorf(`db: validator failed for field "redirect_uri": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := acc.mutation.ClaimsUserID(); !ok {
|
||||
return &ValidationError{Name: "claims_user_id", err: errors.New("db: missing required field \"claims_user_id\"")}
|
||||
return &ValidationError{Name: "claims_user_id", err: errors.New(`db: missing required field "claims_user_id"`)}
|
||||
}
|
||||
if v, ok := acc.mutation.ClaimsUserID(); ok {
|
||||
if err := authcode.ClaimsUserIDValidator(v); err != nil {
|
||||
return &ValidationError{Name: "claims_user_id", err: fmt.Errorf("db: validator failed for field \"claims_user_id\": %w", err)}
|
||||
return &ValidationError{Name: "claims_user_id", err: fmt.Errorf(`db: validator failed for field "claims_user_id": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := acc.mutation.ClaimsUsername(); !ok {
|
||||
return &ValidationError{Name: "claims_username", err: errors.New("db: missing required field \"claims_username\"")}
|
||||
return &ValidationError{Name: "claims_username", err: errors.New(`db: missing required field "claims_username"`)}
|
||||
}
|
||||
if v, ok := acc.mutation.ClaimsUsername(); ok {
|
||||
if err := authcode.ClaimsUsernameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "claims_username", err: fmt.Errorf("db: validator failed for field \"claims_username\": %w", err)}
|
||||
return &ValidationError{Name: "claims_username", err: fmt.Errorf(`db: validator failed for field "claims_username": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := acc.mutation.ClaimsEmail(); !ok {
|
||||
return &ValidationError{Name: "claims_email", err: errors.New("db: missing required field \"claims_email\"")}
|
||||
return &ValidationError{Name: "claims_email", err: errors.New(`db: missing required field "claims_email"`)}
|
||||
}
|
||||
if v, ok := acc.mutation.ClaimsEmail(); ok {
|
||||
if err := authcode.ClaimsEmailValidator(v); err != nil {
|
||||
return &ValidationError{Name: "claims_email", err: fmt.Errorf("db: validator failed for field \"claims_email\": %w", err)}
|
||||
return &ValidationError{Name: "claims_email", err: fmt.Errorf(`db: validator failed for field "claims_email": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := acc.mutation.ClaimsEmailVerified(); !ok {
|
||||
return &ValidationError{Name: "claims_email_verified", err: errors.New("db: missing required field \"claims_email_verified\"")}
|
||||
return &ValidationError{Name: "claims_email_verified", err: errors.New(`db: missing required field "claims_email_verified"`)}
|
||||
}
|
||||
if _, ok := acc.mutation.ClaimsPreferredUsername(); !ok {
|
||||
return &ValidationError{Name: "claims_preferred_username", err: errors.New("db: missing required field \"claims_preferred_username\"")}
|
||||
return &ValidationError{Name: "claims_preferred_username", err: errors.New(`db: missing required field "claims_preferred_username"`)}
|
||||
}
|
||||
if _, ok := acc.mutation.ConnectorID(); !ok {
|
||||
return &ValidationError{Name: "connector_id", err: errors.New("db: missing required field \"connector_id\"")}
|
||||
return &ValidationError{Name: "connector_id", err: errors.New(`db: missing required field "connector_id"`)}
|
||||
}
|
||||
if v, ok := acc.mutation.ConnectorID(); ok {
|
||||
if err := authcode.ConnectorIDValidator(v); err != nil {
|
||||
return &ValidationError{Name: "connector_id", err: fmt.Errorf("db: validator failed for field \"connector_id\": %w", err)}
|
||||
return &ValidationError{Name: "connector_id", err: fmt.Errorf(`db: validator failed for field "connector_id": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := acc.mutation.Expiry(); !ok {
|
||||
return &ValidationError{Name: "expiry", err: errors.New("db: missing required field \"expiry\"")}
|
||||
return &ValidationError{Name: "expiry", err: errors.New(`db: missing required field "expiry"`)}
|
||||
}
|
||||
if _, ok := acc.mutation.CodeChallenge(); !ok {
|
||||
return &ValidationError{Name: "code_challenge", err: errors.New("db: missing required field \"code_challenge\"")}
|
||||
return &ValidationError{Name: "code_challenge", err: errors.New(`db: missing required field "code_challenge"`)}
|
||||
}
|
||||
if _, ok := acc.mutation.CodeChallengeMethod(); !ok {
|
||||
return &ValidationError{Name: "code_challenge_method", err: errors.New("db: missing required field \"code_challenge_method\"")}
|
||||
return &ValidationError{Name: "code_challenge_method", err: errors.New(`db: missing required field "code_challenge_method"`)}
|
||||
}
|
||||
if v, ok := acc.mutation.ID(); ok {
|
||||
if err := authcode.IDValidator(v); err != nil {
|
||||
return &ValidationError{Name: "id", err: fmt.Errorf("db: validator failed for field \"id\": %w", err)}
|
||||
return &ValidationError{Name: "id", err: fmt.Errorf(`db: validator failed for field "id": %w`, err)}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -290,8 +309,8 @@ func (acc *AuthCodeCreate) check() error {
|
||||
func (acc *AuthCodeCreate) sqlSave(ctx context.Context) (*AuthCode, error) {
|
||||
_node, _spec := acc.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, acc.driver, _spec); err != nil {
|
||||
if cerr, ok := isSQLConstraintError(err); ok {
|
||||
err = cerr
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{err.Error(), err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
@@ -465,17 +484,19 @@ func (accb *AuthCodeCreateBulk) Save(ctx context.Context) ([]*AuthCode, error) {
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, accb.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, accb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil {
|
||||
if cerr, ok := isSQLConstraintError(err); ok {
|
||||
err = cerr
|
||||
if err = sqlgraph.BatchCreate(ctx, accb.driver, spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{err.Error(), err}
|
||||
}
|
||||
}
|
||||
}
|
||||
mutation.done = true
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mutation.id = &nodes[i].ID
|
||||
mutation.done = true
|
||||
return nodes[i], nil
|
||||
})
|
||||
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
||||
@@ -500,3 +521,16 @@ func (accb *AuthCodeCreateBulk) SaveX(ctx context.Context) []*AuthCode {
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (accb *AuthCodeCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := accb.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (accb *AuthCodeCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := accb.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,9 +20,9 @@ type AuthCodeDelete struct {
|
||||
mutation *AuthCodeMutation
|
||||
}
|
||||
|
||||
// Where adds a new predicate to the AuthCodeDelete builder.
|
||||
// Where appends a list predicates to the AuthCodeDelete builder.
|
||||
func (acd *AuthCodeDelete) Where(ps ...predicate.AuthCode) *AuthCodeDelete {
|
||||
acd.mutation.predicates = append(acd.mutation.predicates, ps...)
|
||||
acd.mutation.Where(ps...)
|
||||
return acd
|
||||
}
|
||||
|
||||
@@ -46,6 +46,9 @@ func (acd *AuthCodeDelete) Exec(ctx context.Context) (int, error) {
|
||||
return affected, err
|
||||
})
|
||||
for i := len(acd.hooks) - 1; i >= 0; i-- {
|
||||
if acd.hooks[i] == nil {
|
||||
return 0, fmt.Errorf("db: uninitialized hook (forgotten import db/runtime?)")
|
||||
}
|
||||
mut = acd.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, acd.mutation); err != nil {
|
||||
|
||||
@@ -287,8 +287,8 @@ func (acq *AuthCodeQuery) GroupBy(field string, fields ...string) *AuthCodeGroup
|
||||
// Select(authcode.FieldClientID).
|
||||
// Scan(ctx, &v)
|
||||
//
|
||||
func (acq *AuthCodeQuery) Select(field string, fields ...string) *AuthCodeSelect {
|
||||
acq.fields = append([]string{field}, fields...)
|
||||
func (acq *AuthCodeQuery) Select(fields ...string) *AuthCodeSelect {
|
||||
acq.fields = append(acq.fields, fields...)
|
||||
return &AuthCodeSelect{AuthCodeQuery: acq}
|
||||
}
|
||||
|
||||
@@ -398,10 +398,14 @@ func (acq *AuthCodeQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
func (acq *AuthCodeQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(acq.driver.Dialect())
|
||||
t1 := builder.Table(authcode.Table)
|
||||
selector := builder.Select(t1.Columns(authcode.Columns...)...).From(t1)
|
||||
columns := acq.fields
|
||||
if len(columns) == 0 {
|
||||
columns = authcode.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if acq.sql != nil {
|
||||
selector = acq.sql
|
||||
selector.Select(selector.Columns(authcode.Columns...)...)
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
for _, p := range acq.predicates {
|
||||
p(selector)
|
||||
@@ -669,13 +673,24 @@ func (acgb *AuthCodeGroupBy) sqlScan(ctx context.Context, v interface{}) error {
|
||||
}
|
||||
|
||||
func (acgb *AuthCodeGroupBy) sqlQuery() *sql.Selector {
|
||||
selector := acgb.sql
|
||||
columns := make([]string, 0, len(acgb.fields)+len(acgb.fns))
|
||||
columns = append(columns, acgb.fields...)
|
||||
selector := acgb.sql.Select()
|
||||
aggregation := make([]string, 0, len(acgb.fns))
|
||||
for _, fn := range acgb.fns {
|
||||
columns = append(columns, fn(selector))
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
return selector.Select(columns...).GroupBy(acgb.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(acgb.fields)+len(acgb.fns))
|
||||
for _, f := range acgb.fields {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
for _, c := range aggregation {
|
||||
columns = append(columns, c)
|
||||
}
|
||||
selector.Select(columns...)
|
||||
}
|
||||
return selector.GroupBy(selector.Columns(acgb.fields...)...)
|
||||
}
|
||||
|
||||
// AuthCodeSelect is the builder for selecting fields of AuthCode entities.
|
||||
@@ -891,16 +906,10 @@ func (acs *AuthCodeSelect) BoolX(ctx context.Context) bool {
|
||||
|
||||
func (acs *AuthCodeSelect) sqlScan(ctx context.Context, v interface{}) error {
|
||||
rows := &sql.Rows{}
|
||||
query, args := acs.sqlQuery().Query()
|
||||
query, args := acs.sql.Query()
|
||||
if err := acs.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
func (acs *AuthCodeSelect) sqlQuery() sql.Querier {
|
||||
selector := acs.sql
|
||||
selector.Select(selector.Columns(acs.fields...)...)
|
||||
return selector
|
||||
}
|
||||
|
||||
@@ -21,9 +21,9 @@ type AuthCodeUpdate struct {
|
||||
mutation *AuthCodeMutation
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the AuthCodeUpdate builder.
|
||||
// Where appends a list predicates to the AuthCodeUpdate builder.
|
||||
func (acu *AuthCodeUpdate) Where(ps ...predicate.AuthCode) *AuthCodeUpdate {
|
||||
acu.mutation.predicates = append(acu.mutation.predicates, ps...)
|
||||
acu.mutation.Where(ps...)
|
||||
return acu
|
||||
}
|
||||
|
||||
@@ -190,6 +190,9 @@ func (acu *AuthCodeUpdate) Save(ctx context.Context) (int, error) {
|
||||
return affected, err
|
||||
})
|
||||
for i := len(acu.hooks) - 1; i >= 0; i-- {
|
||||
if acu.hooks[i] == nil {
|
||||
return 0, fmt.Errorf("db: uninitialized hook (forgotten import db/runtime?)")
|
||||
}
|
||||
mut = acu.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, acu.mutation); err != nil {
|
||||
@@ -405,8 +408,8 @@ func (acu *AuthCodeUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, acu.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{authcode.Label}
|
||||
} else if cerr, ok := isSQLConstraintError(err); ok {
|
||||
err = cerr
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{err.Error(), err}
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
@@ -591,6 +594,9 @@ func (acuo *AuthCodeUpdateOne) Save(ctx context.Context) (*AuthCode, error) {
|
||||
return node, err
|
||||
})
|
||||
for i := len(acuo.hooks) - 1; i >= 0; i-- {
|
||||
if acuo.hooks[i] == nil {
|
||||
return nil, fmt.Errorf("db: uninitialized hook (forgotten import db/runtime?)")
|
||||
}
|
||||
mut = acuo.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, acuo.mutation); err != nil {
|
||||
@@ -826,8 +832,8 @@ func (acuo *AuthCodeUpdateOne) sqlSave(ctx context.Context) (_node *AuthCode, er
|
||||
if err = sqlgraph.UpdateNode(ctx, acuo.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{authcode.Label}
|
||||
} else if cerr, ok := isSQLConstraintError(err); ok {
|
||||
err = cerr
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{err.Error(), err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -98,7 +98,6 @@ func (ar *AuthRequest) assignValues(columns []string, values []interface{}) erro
|
||||
ar.ClientID = value.String
|
||||
}
|
||||
case authrequest.FieldScopes:
|
||||
|
||||
if value, ok := values[i].(*[]byte); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field scopes", values[i])
|
||||
} else if value != nil && len(*value) > 0 {
|
||||
@@ -107,7 +106,6 @@ func (ar *AuthRequest) assignValues(columns []string, values []interface{}) erro
|
||||
}
|
||||
}
|
||||
case authrequest.FieldResponseTypes:
|
||||
|
||||
if value, ok := values[i].(*[]byte); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field response_types", values[i])
|
||||
} else if value != nil && len(*value) > 0 {
|
||||
@@ -170,7 +168,6 @@ func (ar *AuthRequest) assignValues(columns []string, values []interface{}) erro
|
||||
ar.ClaimsEmailVerified = value.Bool
|
||||
}
|
||||
case authrequest.FieldClaimsGroups:
|
||||
|
||||
if value, ok := values[i].(*[]byte); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field claims_groups", values[i])
|
||||
} else if value != nil && len(*value) > 0 {
|
||||
|
||||
@@ -191,11 +191,17 @@ func (arc *AuthRequestCreate) Save(ctx context.Context) (*AuthRequest, error) {
|
||||
return nil, err
|
||||
}
|
||||
arc.mutation = mutation
|
||||
node, err = arc.sqlSave(ctx)
|
||||
if node, err = arc.sqlSave(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mutation.id = &node.ID
|
||||
mutation.done = true
|
||||
return node, err
|
||||
})
|
||||
for i := len(arc.hooks) - 1; i >= 0; i-- {
|
||||
if arc.hooks[i] == nil {
|
||||
return nil, fmt.Errorf("db: uninitialized hook (forgotten import db/runtime?)")
|
||||
}
|
||||
mut = arc.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, arc.mutation); err != nil {
|
||||
@@ -214,6 +220,19 @@ func (arc *AuthRequestCreate) SaveX(ctx context.Context) *AuthRequest {
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (arc *AuthRequestCreate) Exec(ctx context.Context) error {
|
||||
_, err := arc.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (arc *AuthRequestCreate) ExecX(ctx context.Context) {
|
||||
if err := arc.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (arc *AuthRequestCreate) defaults() {
|
||||
if _, ok := arc.mutation.ClaimsPreferredUsername(); !ok {
|
||||
@@ -233,53 +252,53 @@ func (arc *AuthRequestCreate) defaults() {
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (arc *AuthRequestCreate) check() error {
|
||||
if _, ok := arc.mutation.ClientID(); !ok {
|
||||
return &ValidationError{Name: "client_id", err: errors.New("db: missing required field \"client_id\"")}
|
||||
return &ValidationError{Name: "client_id", err: errors.New(`db: missing required field "client_id"`)}
|
||||
}
|
||||
if _, ok := arc.mutation.RedirectURI(); !ok {
|
||||
return &ValidationError{Name: "redirect_uri", err: errors.New("db: missing required field \"redirect_uri\"")}
|
||||
return &ValidationError{Name: "redirect_uri", err: errors.New(`db: missing required field "redirect_uri"`)}
|
||||
}
|
||||
if _, ok := arc.mutation.Nonce(); !ok {
|
||||
return &ValidationError{Name: "nonce", err: errors.New("db: missing required field \"nonce\"")}
|
||||
return &ValidationError{Name: "nonce", err: errors.New(`db: missing required field "nonce"`)}
|
||||
}
|
||||
if _, ok := arc.mutation.State(); !ok {
|
||||
return &ValidationError{Name: "state", err: errors.New("db: missing required field \"state\"")}
|
||||
return &ValidationError{Name: "state", err: errors.New(`db: missing required field "state"`)}
|
||||
}
|
||||
if _, ok := arc.mutation.ForceApprovalPrompt(); !ok {
|
||||
return &ValidationError{Name: "force_approval_prompt", err: errors.New("db: missing required field \"force_approval_prompt\"")}
|
||||
return &ValidationError{Name: "force_approval_prompt", err: errors.New(`db: missing required field "force_approval_prompt"`)}
|
||||
}
|
||||
if _, ok := arc.mutation.LoggedIn(); !ok {
|
||||
return &ValidationError{Name: "logged_in", err: errors.New("db: missing required field \"logged_in\"")}
|
||||
return &ValidationError{Name: "logged_in", err: errors.New(`db: missing required field "logged_in"`)}
|
||||
}
|
||||
if _, ok := arc.mutation.ClaimsUserID(); !ok {
|
||||
return &ValidationError{Name: "claims_user_id", err: errors.New("db: missing required field \"claims_user_id\"")}
|
||||
return &ValidationError{Name: "claims_user_id", err: errors.New(`db: missing required field "claims_user_id"`)}
|
||||
}
|
||||
if _, ok := arc.mutation.ClaimsUsername(); !ok {
|
||||
return &ValidationError{Name: "claims_username", err: errors.New("db: missing required field \"claims_username\"")}
|
||||
return &ValidationError{Name: "claims_username", err: errors.New(`db: missing required field "claims_username"`)}
|
||||
}
|
||||
if _, ok := arc.mutation.ClaimsEmail(); !ok {
|
||||
return &ValidationError{Name: "claims_email", err: errors.New("db: missing required field \"claims_email\"")}
|
||||
return &ValidationError{Name: "claims_email", err: errors.New(`db: missing required field "claims_email"`)}
|
||||
}
|
||||
if _, ok := arc.mutation.ClaimsEmailVerified(); !ok {
|
||||
return &ValidationError{Name: "claims_email_verified", err: errors.New("db: missing required field \"claims_email_verified\"")}
|
||||
return &ValidationError{Name: "claims_email_verified", err: errors.New(`db: missing required field "claims_email_verified"`)}
|
||||
}
|
||||
if _, ok := arc.mutation.ClaimsPreferredUsername(); !ok {
|
||||
return &ValidationError{Name: "claims_preferred_username", err: errors.New("db: missing required field \"claims_preferred_username\"")}
|
||||
return &ValidationError{Name: "claims_preferred_username", err: errors.New(`db: missing required field "claims_preferred_username"`)}
|
||||
}
|
||||
if _, ok := arc.mutation.ConnectorID(); !ok {
|
||||
return &ValidationError{Name: "connector_id", err: errors.New("db: missing required field \"connector_id\"")}
|
||||
return &ValidationError{Name: "connector_id", err: errors.New(`db: missing required field "connector_id"`)}
|
||||
}
|
||||
if _, ok := arc.mutation.Expiry(); !ok {
|
||||
return &ValidationError{Name: "expiry", err: errors.New("db: missing required field \"expiry\"")}
|
||||
return &ValidationError{Name: "expiry", err: errors.New(`db: missing required field "expiry"`)}
|
||||
}
|
||||
if _, ok := arc.mutation.CodeChallenge(); !ok {
|
||||
return &ValidationError{Name: "code_challenge", err: errors.New("db: missing required field \"code_challenge\"")}
|
||||
return &ValidationError{Name: "code_challenge", err: errors.New(`db: missing required field "code_challenge"`)}
|
||||
}
|
||||
if _, ok := arc.mutation.CodeChallengeMethod(); !ok {
|
||||
return &ValidationError{Name: "code_challenge_method", err: errors.New("db: missing required field \"code_challenge_method\"")}
|
||||
return &ValidationError{Name: "code_challenge_method", err: errors.New(`db: missing required field "code_challenge_method"`)}
|
||||
}
|
||||
if v, ok := arc.mutation.ID(); ok {
|
||||
if err := authrequest.IDValidator(v); err != nil {
|
||||
return &ValidationError{Name: "id", err: fmt.Errorf("db: validator failed for field \"id\": %w", err)}
|
||||
return &ValidationError{Name: "id", err: fmt.Errorf(`db: validator failed for field "id": %w`, err)}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -288,8 +307,8 @@ func (arc *AuthRequestCreate) check() error {
|
||||
func (arc *AuthRequestCreate) sqlSave(ctx context.Context) (*AuthRequest, error) {
|
||||
_node, _spec := arc.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, arc.driver, _spec); err != nil {
|
||||
if cerr, ok := isSQLConstraintError(err); ok {
|
||||
err = cerr
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{err.Error(), err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
@@ -495,17 +514,19 @@ func (arcb *AuthRequestCreateBulk) Save(ctx context.Context) ([]*AuthRequest, er
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, arcb.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, arcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil {
|
||||
if cerr, ok := isSQLConstraintError(err); ok {
|
||||
err = cerr
|
||||
if err = sqlgraph.BatchCreate(ctx, arcb.driver, spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{err.Error(), err}
|
||||
}
|
||||
}
|
||||
}
|
||||
mutation.done = true
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mutation.id = &nodes[i].ID
|
||||
mutation.done = true
|
||||
return nodes[i], nil
|
||||
})
|
||||
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
||||
@@ -530,3 +551,16 @@ func (arcb *AuthRequestCreateBulk) SaveX(ctx context.Context) []*AuthRequest {
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (arcb *AuthRequestCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := arcb.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (arcb *AuthRequestCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := arcb.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,9 +20,9 @@ type AuthRequestDelete struct {
|
||||
mutation *AuthRequestMutation
|
||||
}
|
||||
|
||||
// Where adds a new predicate to the AuthRequestDelete builder.
|
||||
// Where appends a list predicates to the AuthRequestDelete builder.
|
||||
func (ard *AuthRequestDelete) Where(ps ...predicate.AuthRequest) *AuthRequestDelete {
|
||||
ard.mutation.predicates = append(ard.mutation.predicates, ps...)
|
||||
ard.mutation.Where(ps...)
|
||||
return ard
|
||||
}
|
||||
|
||||
@@ -46,6 +46,9 @@ func (ard *AuthRequestDelete) Exec(ctx context.Context) (int, error) {
|
||||
return affected, err
|
||||
})
|
||||
for i := len(ard.hooks) - 1; i >= 0; i-- {
|
||||
if ard.hooks[i] == nil {
|
||||
return 0, fmt.Errorf("db: uninitialized hook (forgotten import db/runtime?)")
|
||||
}
|
||||
mut = ard.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, ard.mutation); err != nil {
|
||||
|
||||
@@ -287,8 +287,8 @@ func (arq *AuthRequestQuery) GroupBy(field string, fields ...string) *AuthReques
|
||||
// Select(authrequest.FieldClientID).
|
||||
// Scan(ctx, &v)
|
||||
//
|
||||
func (arq *AuthRequestQuery) Select(field string, fields ...string) *AuthRequestSelect {
|
||||
arq.fields = append([]string{field}, fields...)
|
||||
func (arq *AuthRequestQuery) Select(fields ...string) *AuthRequestSelect {
|
||||
arq.fields = append(arq.fields, fields...)
|
||||
return &AuthRequestSelect{AuthRequestQuery: arq}
|
||||
}
|
||||
|
||||
@@ -398,10 +398,14 @@ func (arq *AuthRequestQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
func (arq *AuthRequestQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(arq.driver.Dialect())
|
||||
t1 := builder.Table(authrequest.Table)
|
||||
selector := builder.Select(t1.Columns(authrequest.Columns...)...).From(t1)
|
||||
columns := arq.fields
|
||||
if len(columns) == 0 {
|
||||
columns = authrequest.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if arq.sql != nil {
|
||||
selector = arq.sql
|
||||
selector.Select(selector.Columns(authrequest.Columns...)...)
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
for _, p := range arq.predicates {
|
||||
p(selector)
|
||||
@@ -669,13 +673,24 @@ func (argb *AuthRequestGroupBy) sqlScan(ctx context.Context, v interface{}) erro
|
||||
}
|
||||
|
||||
func (argb *AuthRequestGroupBy) sqlQuery() *sql.Selector {
|
||||
selector := argb.sql
|
||||
columns := make([]string, 0, len(argb.fields)+len(argb.fns))
|
||||
columns = append(columns, argb.fields...)
|
||||
selector := argb.sql.Select()
|
||||
aggregation := make([]string, 0, len(argb.fns))
|
||||
for _, fn := range argb.fns {
|
||||
columns = append(columns, fn(selector))
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
return selector.Select(columns...).GroupBy(argb.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(argb.fields)+len(argb.fns))
|
||||
for _, f := range argb.fields {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
for _, c := range aggregation {
|
||||
columns = append(columns, c)
|
||||
}
|
||||
selector.Select(columns...)
|
||||
}
|
||||
return selector.GroupBy(selector.Columns(argb.fields...)...)
|
||||
}
|
||||
|
||||
// AuthRequestSelect is the builder for selecting fields of AuthRequest entities.
|
||||
@@ -891,16 +906,10 @@ func (ars *AuthRequestSelect) BoolX(ctx context.Context) bool {
|
||||
|
||||
func (ars *AuthRequestSelect) sqlScan(ctx context.Context, v interface{}) error {
|
||||
rows := &sql.Rows{}
|
||||
query, args := ars.sqlQuery().Query()
|
||||
query, args := ars.sql.Query()
|
||||
if err := ars.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
func (ars *AuthRequestSelect) sqlQuery() sql.Querier {
|
||||
selector := ars.sql
|
||||
selector.Select(selector.Columns(ars.fields...)...)
|
||||
return selector
|
||||
}
|
||||
|
||||
@@ -21,9 +21,9 @@ type AuthRequestUpdate struct {
|
||||
mutation *AuthRequestMutation
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the AuthRequestUpdate builder.
|
||||
// Where appends a list predicates to the AuthRequestUpdate builder.
|
||||
func (aru *AuthRequestUpdate) Where(ps ...predicate.AuthRequest) *AuthRequestUpdate {
|
||||
aru.mutation.predicates = append(aru.mutation.predicates, ps...)
|
||||
aru.mutation.Where(ps...)
|
||||
return aru
|
||||
}
|
||||
|
||||
@@ -214,6 +214,9 @@ func (aru *AuthRequestUpdate) Save(ctx context.Context) (int, error) {
|
||||
return affected, err
|
||||
})
|
||||
for i := len(aru.hooks) - 1; i >= 0; i-- {
|
||||
if aru.hooks[i] == nil {
|
||||
return 0, fmt.Errorf("db: uninitialized hook (forgotten import db/runtime?)")
|
||||
}
|
||||
mut = aru.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, aru.mutation); err != nil {
|
||||
@@ -423,8 +426,8 @@ func (aru *AuthRequestUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, aru.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{authrequest.Label}
|
||||
} else if cerr, ok := isSQLConstraintError(err); ok {
|
||||
err = cerr
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{err.Error(), err}
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
@@ -633,6 +636,9 @@ func (aruo *AuthRequestUpdateOne) Save(ctx context.Context) (*AuthRequest, error
|
||||
return node, err
|
||||
})
|
||||
for i := len(aruo.hooks) - 1; i >= 0; i-- {
|
||||
if aruo.hooks[i] == nil {
|
||||
return nil, fmt.Errorf("db: uninitialized hook (forgotten import db/runtime?)")
|
||||
}
|
||||
mut = aruo.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, aruo.mutation); err != nil {
|
||||
@@ -862,8 +868,8 @@ func (aruo *AuthRequestUpdateOne) sqlSave(ctx context.Context) (_node *AuthReque
|
||||
if err = sqlgraph.UpdateNode(ctx, aruo.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{authrequest.Label}
|
||||
} else if cerr, ok := isSQLConstraintError(err); ok {
|
||||
err = cerr
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{err.Error(), err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -75,11 +75,17 @@ func (cc *ConnectorCreate) Save(ctx context.Context) (*Connector, error) {
|
||||
return nil, err
|
||||
}
|
||||
cc.mutation = mutation
|
||||
node, err = cc.sqlSave(ctx)
|
||||
if node, err = cc.sqlSave(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mutation.id = &node.ID
|
||||
mutation.done = true
|
||||
return node, err
|
||||
})
|
||||
for i := len(cc.hooks) - 1; i >= 0; i-- {
|
||||
if cc.hooks[i] == nil {
|
||||
return nil, fmt.Errorf("db: uninitialized hook (forgotten import db/runtime?)")
|
||||
}
|
||||
mut = cc.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, cc.mutation); err != nil {
|
||||
@@ -98,33 +104,46 @@ func (cc *ConnectorCreate) SaveX(ctx context.Context) *Connector {
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (cc *ConnectorCreate) Exec(ctx context.Context) error {
|
||||
_, err := cc.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (cc *ConnectorCreate) ExecX(ctx context.Context) {
|
||||
if err := cc.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (cc *ConnectorCreate) check() error {
|
||||
if _, ok := cc.mutation.GetType(); !ok {
|
||||
return &ValidationError{Name: "type", err: errors.New("db: missing required field \"type\"")}
|
||||
return &ValidationError{Name: "type", err: errors.New(`db: missing required field "type"`)}
|
||||
}
|
||||
if v, ok := cc.mutation.GetType(); ok {
|
||||
if err := connector.TypeValidator(v); err != nil {
|
||||
return &ValidationError{Name: "type", err: fmt.Errorf("db: validator failed for field \"type\": %w", err)}
|
||||
return &ValidationError{Name: "type", err: fmt.Errorf(`db: validator failed for field "type": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := cc.mutation.Name(); !ok {
|
||||
return &ValidationError{Name: "name", err: errors.New("db: missing required field \"name\"")}
|
||||
return &ValidationError{Name: "name", err: errors.New(`db: missing required field "name"`)}
|
||||
}
|
||||
if v, ok := cc.mutation.Name(); ok {
|
||||
if err := connector.NameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "name", err: fmt.Errorf("db: validator failed for field \"name\": %w", err)}
|
||||
return &ValidationError{Name: "name", err: fmt.Errorf(`db: validator failed for field "name": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := cc.mutation.ResourceVersion(); !ok {
|
||||
return &ValidationError{Name: "resource_version", err: errors.New("db: missing required field \"resource_version\"")}
|
||||
return &ValidationError{Name: "resource_version", err: errors.New(`db: missing required field "resource_version"`)}
|
||||
}
|
||||
if _, ok := cc.mutation.Config(); !ok {
|
||||
return &ValidationError{Name: "config", err: errors.New("db: missing required field \"config\"")}
|
||||
return &ValidationError{Name: "config", err: errors.New(`db: missing required field "config"`)}
|
||||
}
|
||||
if v, ok := cc.mutation.ID(); ok {
|
||||
if err := connector.IDValidator(v); err != nil {
|
||||
return &ValidationError{Name: "id", err: fmt.Errorf("db: validator failed for field \"id\": %w", err)}
|
||||
return &ValidationError{Name: "id", err: fmt.Errorf(`db: validator failed for field "id": %w`, err)}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -133,8 +152,8 @@ func (cc *ConnectorCreate) check() error {
|
||||
func (cc *ConnectorCreate) sqlSave(ctx context.Context) (*Connector, error) {
|
||||
_node, _spec := cc.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, cc.driver, _spec); err != nil {
|
||||
if cerr, ok := isSQLConstraintError(err); ok {
|
||||
err = cerr
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{err.Error(), err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
@@ -219,17 +238,19 @@ func (ccb *ConnectorCreateBulk) Save(ctx context.Context) ([]*Connector, error)
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, ccb.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, ccb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil {
|
||||
if cerr, ok := isSQLConstraintError(err); ok {
|
||||
err = cerr
|
||||
if err = sqlgraph.BatchCreate(ctx, ccb.driver, spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{err.Error(), err}
|
||||
}
|
||||
}
|
||||
}
|
||||
mutation.done = true
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mutation.id = &nodes[i].ID
|
||||
mutation.done = true
|
||||
return nodes[i], nil
|
||||
})
|
||||
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
||||
@@ -254,3 +275,16 @@ func (ccb *ConnectorCreateBulk) SaveX(ctx context.Context) []*Connector {
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (ccb *ConnectorCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := ccb.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (ccb *ConnectorCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := ccb.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,9 +20,9 @@ type ConnectorDelete struct {
|
||||
mutation *ConnectorMutation
|
||||
}
|
||||
|
||||
// Where adds a new predicate to the ConnectorDelete builder.
|
||||
// Where appends a list predicates to the ConnectorDelete builder.
|
||||
func (cd *ConnectorDelete) Where(ps ...predicate.Connector) *ConnectorDelete {
|
||||
cd.mutation.predicates = append(cd.mutation.predicates, ps...)
|
||||
cd.mutation.Where(ps...)
|
||||
return cd
|
||||
}
|
||||
|
||||
@@ -46,6 +46,9 @@ func (cd *ConnectorDelete) Exec(ctx context.Context) (int, error) {
|
||||
return affected, err
|
||||
})
|
||||
for i := len(cd.hooks) - 1; i >= 0; i-- {
|
||||
if cd.hooks[i] == nil {
|
||||
return 0, fmt.Errorf("db: uninitialized hook (forgotten import db/runtime?)")
|
||||
}
|
||||
mut = cd.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, cd.mutation); err != nil {
|
||||
|
||||
@@ -287,8 +287,8 @@ func (cq *ConnectorQuery) GroupBy(field string, fields ...string) *ConnectorGrou
|
||||
// Select(connector.FieldType).
|
||||
// Scan(ctx, &v)
|
||||
//
|
||||
func (cq *ConnectorQuery) Select(field string, fields ...string) *ConnectorSelect {
|
||||
cq.fields = append([]string{field}, fields...)
|
||||
func (cq *ConnectorQuery) Select(fields ...string) *ConnectorSelect {
|
||||
cq.fields = append(cq.fields, fields...)
|
||||
return &ConnectorSelect{ConnectorQuery: cq}
|
||||
}
|
||||
|
||||
@@ -398,10 +398,14 @@ func (cq *ConnectorQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
func (cq *ConnectorQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(cq.driver.Dialect())
|
||||
t1 := builder.Table(connector.Table)
|
||||
selector := builder.Select(t1.Columns(connector.Columns...)...).From(t1)
|
||||
columns := cq.fields
|
||||
if len(columns) == 0 {
|
||||
columns = connector.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if cq.sql != nil {
|
||||
selector = cq.sql
|
||||
selector.Select(selector.Columns(connector.Columns...)...)
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
for _, p := range cq.predicates {
|
||||
p(selector)
|
||||
@@ -669,13 +673,24 @@ func (cgb *ConnectorGroupBy) sqlScan(ctx context.Context, v interface{}) error {
|
||||
}
|
||||
|
||||
func (cgb *ConnectorGroupBy) sqlQuery() *sql.Selector {
|
||||
selector := cgb.sql
|
||||
columns := make([]string, 0, len(cgb.fields)+len(cgb.fns))
|
||||
columns = append(columns, cgb.fields...)
|
||||
selector := cgb.sql.Select()
|
||||
aggregation := make([]string, 0, len(cgb.fns))
|
||||
for _, fn := range cgb.fns {
|
||||
columns = append(columns, fn(selector))
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
return selector.Select(columns...).GroupBy(cgb.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(cgb.fields)+len(cgb.fns))
|
||||
for _, f := range cgb.fields {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
for _, c := range aggregation {
|
||||
columns = append(columns, c)
|
||||
}
|
||||
selector.Select(columns...)
|
||||
}
|
||||
return selector.GroupBy(selector.Columns(cgb.fields...)...)
|
||||
}
|
||||
|
||||
// ConnectorSelect is the builder for selecting fields of Connector entities.
|
||||
@@ -891,16 +906,10 @@ func (cs *ConnectorSelect) BoolX(ctx context.Context) bool {
|
||||
|
||||
func (cs *ConnectorSelect) sqlScan(ctx context.Context, v interface{}) error {
|
||||
rows := &sql.Rows{}
|
||||
query, args := cs.sqlQuery().Query()
|
||||
query, args := cs.sql.Query()
|
||||
if err := cs.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
func (cs *ConnectorSelect) sqlQuery() sql.Querier {
|
||||
selector := cs.sql
|
||||
selector.Select(selector.Columns(cs.fields...)...)
|
||||
return selector
|
||||
}
|
||||
|
||||
@@ -20,9 +20,9 @@ type ConnectorUpdate struct {
|
||||
mutation *ConnectorMutation
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the ConnectorUpdate builder.
|
||||
// Where appends a list predicates to the ConnectorUpdate builder.
|
||||
func (cu *ConnectorUpdate) Where(ps ...predicate.Connector) *ConnectorUpdate {
|
||||
cu.mutation.predicates = append(cu.mutation.predicates, ps...)
|
||||
cu.mutation.Where(ps...)
|
||||
return cu
|
||||
}
|
||||
|
||||
@@ -81,6 +81,9 @@ func (cu *ConnectorUpdate) Save(ctx context.Context) (int, error) {
|
||||
return affected, err
|
||||
})
|
||||
for i := len(cu.hooks) - 1; i >= 0; i-- {
|
||||
if cu.hooks[i] == nil {
|
||||
return 0, fmt.Errorf("db: uninitialized hook (forgotten import db/runtime?)")
|
||||
}
|
||||
mut = cu.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, cu.mutation); err != nil {
|
||||
@@ -176,8 +179,8 @@ func (cu *ConnectorUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, cu.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{connector.Label}
|
||||
} else if cerr, ok := isSQLConstraintError(err); ok {
|
||||
err = cerr
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{err.Error(), err}
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
@@ -254,6 +257,9 @@ func (cuo *ConnectorUpdateOne) Save(ctx context.Context) (*Connector, error) {
|
||||
return node, err
|
||||
})
|
||||
for i := len(cuo.hooks) - 1; i >= 0; i-- {
|
||||
if cuo.hooks[i] == nil {
|
||||
return nil, fmt.Errorf("db: uninitialized hook (forgotten import db/runtime?)")
|
||||
}
|
||||
mut = cuo.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, cuo.mutation); err != nil {
|
||||
@@ -369,8 +375,8 @@ func (cuo *ConnectorUpdateOne) sqlSave(ctx context.Context) (_node *Connector, e
|
||||
if err = sqlgraph.UpdateNode(ctx, cuo.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{connector.Label}
|
||||
} else if cerr, ok := isSQLConstraintError(err); ok {
|
||||
err = cerr
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{err.Error(), err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -90,7 +90,6 @@ func (dr *DeviceRequest) assignValues(columns []string, values []interface{}) er
|
||||
dr.ClientSecret = value.String
|
||||
}
|
||||
case devicerequest.FieldScopes:
|
||||
|
||||
if value, ok := values[i].(*[]byte); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field scopes", values[i])
|
||||
} else if value != nil && len(*value) > 0 {
|
||||
|
||||
@@ -82,11 +82,17 @@ func (drc *DeviceRequestCreate) Save(ctx context.Context) (*DeviceRequest, error
|
||||
return nil, err
|
||||
}
|
||||
drc.mutation = mutation
|
||||
node, err = drc.sqlSave(ctx)
|
||||
if node, err = drc.sqlSave(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mutation.id = &node.ID
|
||||
mutation.done = true
|
||||
return node, err
|
||||
})
|
||||
for i := len(drc.hooks) - 1; i >= 0; i-- {
|
||||
if drc.hooks[i] == nil {
|
||||
return nil, fmt.Errorf("db: uninitialized hook (forgotten import db/runtime?)")
|
||||
}
|
||||
mut = drc.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, drc.mutation); err != nil {
|
||||
@@ -105,42 +111,55 @@ func (drc *DeviceRequestCreate) SaveX(ctx context.Context) *DeviceRequest {
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (drc *DeviceRequestCreate) Exec(ctx context.Context) error {
|
||||
_, err := drc.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (drc *DeviceRequestCreate) ExecX(ctx context.Context) {
|
||||
if err := drc.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (drc *DeviceRequestCreate) check() error {
|
||||
if _, ok := drc.mutation.UserCode(); !ok {
|
||||
return &ValidationError{Name: "user_code", err: errors.New("db: missing required field \"user_code\"")}
|
||||
return &ValidationError{Name: "user_code", err: errors.New(`db: missing required field "user_code"`)}
|
||||
}
|
||||
if v, ok := drc.mutation.UserCode(); ok {
|
||||
if err := devicerequest.UserCodeValidator(v); err != nil {
|
||||
return &ValidationError{Name: "user_code", err: fmt.Errorf("db: validator failed for field \"user_code\": %w", err)}
|
||||
return &ValidationError{Name: "user_code", err: fmt.Errorf(`db: validator failed for field "user_code": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := drc.mutation.DeviceCode(); !ok {
|
||||
return &ValidationError{Name: "device_code", err: errors.New("db: missing required field \"device_code\"")}
|
||||
return &ValidationError{Name: "device_code", err: errors.New(`db: missing required field "device_code"`)}
|
||||
}
|
||||
if v, ok := drc.mutation.DeviceCode(); ok {
|
||||
if err := devicerequest.DeviceCodeValidator(v); err != nil {
|
||||
return &ValidationError{Name: "device_code", err: fmt.Errorf("db: validator failed for field \"device_code\": %w", err)}
|
||||
return &ValidationError{Name: "device_code", err: fmt.Errorf(`db: validator failed for field "device_code": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := drc.mutation.ClientID(); !ok {
|
||||
return &ValidationError{Name: "client_id", err: errors.New("db: missing required field \"client_id\"")}
|
||||
return &ValidationError{Name: "client_id", err: errors.New(`db: missing required field "client_id"`)}
|
||||
}
|
||||
if v, ok := drc.mutation.ClientID(); ok {
|
||||
if err := devicerequest.ClientIDValidator(v); err != nil {
|
||||
return &ValidationError{Name: "client_id", err: fmt.Errorf("db: validator failed for field \"client_id\": %w", err)}
|
||||
return &ValidationError{Name: "client_id", err: fmt.Errorf(`db: validator failed for field "client_id": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := drc.mutation.ClientSecret(); !ok {
|
||||
return &ValidationError{Name: "client_secret", err: errors.New("db: missing required field \"client_secret\"")}
|
||||
return &ValidationError{Name: "client_secret", err: errors.New(`db: missing required field "client_secret"`)}
|
||||
}
|
||||
if v, ok := drc.mutation.ClientSecret(); ok {
|
||||
if err := devicerequest.ClientSecretValidator(v); err != nil {
|
||||
return &ValidationError{Name: "client_secret", err: fmt.Errorf("db: validator failed for field \"client_secret\": %w", err)}
|
||||
return &ValidationError{Name: "client_secret", err: fmt.Errorf(`db: validator failed for field "client_secret": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := drc.mutation.Expiry(); !ok {
|
||||
return &ValidationError{Name: "expiry", err: errors.New("db: missing required field \"expiry\"")}
|
||||
return &ValidationError{Name: "expiry", err: errors.New(`db: missing required field "expiry"`)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -148,8 +167,8 @@ func (drc *DeviceRequestCreate) check() error {
|
||||
func (drc *DeviceRequestCreate) sqlSave(ctx context.Context) (*DeviceRequest, error) {
|
||||
_node, _spec := drc.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, drc.driver, _spec); err != nil {
|
||||
if cerr, ok := isSQLConstraintError(err); ok {
|
||||
err = cerr
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{err.Error(), err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
@@ -248,19 +267,23 @@ func (drcb *DeviceRequestCreateBulk) Save(ctx context.Context) ([]*DeviceRequest
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, drcb.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, drcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil {
|
||||
if cerr, ok := isSQLConstraintError(err); ok {
|
||||
err = cerr
|
||||
if err = sqlgraph.BatchCreate(ctx, drcb.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-- {
|
||||
@@ -285,3 +308,16 @@ func (drcb *DeviceRequestCreateBulk) SaveX(ctx context.Context) []*DeviceRequest
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (drcb *DeviceRequestCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := drcb.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (drcb *DeviceRequestCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := drcb.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,9 +20,9 @@ type DeviceRequestDelete struct {
|
||||
mutation *DeviceRequestMutation
|
||||
}
|
||||
|
||||
// Where adds a new predicate to the DeviceRequestDelete builder.
|
||||
// Where appends a list predicates to the DeviceRequestDelete builder.
|
||||
func (drd *DeviceRequestDelete) Where(ps ...predicate.DeviceRequest) *DeviceRequestDelete {
|
||||
drd.mutation.predicates = append(drd.mutation.predicates, ps...)
|
||||
drd.mutation.Where(ps...)
|
||||
return drd
|
||||
}
|
||||
|
||||
@@ -46,6 +46,9 @@ func (drd *DeviceRequestDelete) Exec(ctx context.Context) (int, error) {
|
||||
return affected, err
|
||||
})
|
||||
for i := len(drd.hooks) - 1; i >= 0; i-- {
|
||||
if drd.hooks[i] == nil {
|
||||
return 0, fmt.Errorf("db: uninitialized hook (forgotten import db/runtime?)")
|
||||
}
|
||||
mut = drd.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, drd.mutation); err != nil {
|
||||
|
||||
@@ -287,8 +287,8 @@ func (drq *DeviceRequestQuery) GroupBy(field string, fields ...string) *DeviceRe
|
||||
// Select(devicerequest.FieldUserCode).
|
||||
// Scan(ctx, &v)
|
||||
//
|
||||
func (drq *DeviceRequestQuery) Select(field string, fields ...string) *DeviceRequestSelect {
|
||||
drq.fields = append([]string{field}, fields...)
|
||||
func (drq *DeviceRequestQuery) Select(fields ...string) *DeviceRequestSelect {
|
||||
drq.fields = append(drq.fields, fields...)
|
||||
return &DeviceRequestSelect{DeviceRequestQuery: drq}
|
||||
}
|
||||
|
||||
@@ -398,10 +398,14 @@ func (drq *DeviceRequestQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
func (drq *DeviceRequestQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(drq.driver.Dialect())
|
||||
t1 := builder.Table(devicerequest.Table)
|
||||
selector := builder.Select(t1.Columns(devicerequest.Columns...)...).From(t1)
|
||||
columns := drq.fields
|
||||
if len(columns) == 0 {
|
||||
columns = devicerequest.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if drq.sql != nil {
|
||||
selector = drq.sql
|
||||
selector.Select(selector.Columns(devicerequest.Columns...)...)
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
for _, p := range drq.predicates {
|
||||
p(selector)
|
||||
@@ -669,13 +673,24 @@ func (drgb *DeviceRequestGroupBy) sqlScan(ctx context.Context, v interface{}) er
|
||||
}
|
||||
|
||||
func (drgb *DeviceRequestGroupBy) sqlQuery() *sql.Selector {
|
||||
selector := drgb.sql
|
||||
columns := make([]string, 0, len(drgb.fields)+len(drgb.fns))
|
||||
columns = append(columns, drgb.fields...)
|
||||
selector := drgb.sql.Select()
|
||||
aggregation := make([]string, 0, len(drgb.fns))
|
||||
for _, fn := range drgb.fns {
|
||||
columns = append(columns, fn(selector))
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
return selector.Select(columns...).GroupBy(drgb.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(drgb.fields)+len(drgb.fns))
|
||||
for _, f := range drgb.fields {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
for _, c := range aggregation {
|
||||
columns = append(columns, c)
|
||||
}
|
||||
selector.Select(columns...)
|
||||
}
|
||||
return selector.GroupBy(selector.Columns(drgb.fields...)...)
|
||||
}
|
||||
|
||||
// DeviceRequestSelect is the builder for selecting fields of DeviceRequest entities.
|
||||
@@ -891,16 +906,10 @@ func (drs *DeviceRequestSelect) BoolX(ctx context.Context) bool {
|
||||
|
||||
func (drs *DeviceRequestSelect) sqlScan(ctx context.Context, v interface{}) error {
|
||||
rows := &sql.Rows{}
|
||||
query, args := drs.sqlQuery().Query()
|
||||
query, args := drs.sql.Query()
|
||||
if err := drs.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
func (drs *DeviceRequestSelect) sqlQuery() sql.Querier {
|
||||
selector := drs.sql
|
||||
selector.Select(selector.Columns(drs.fields...)...)
|
||||
return selector
|
||||
}
|
||||
|
||||
@@ -21,9 +21,9 @@ type DeviceRequestUpdate struct {
|
||||
mutation *DeviceRequestMutation
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the DeviceRequestUpdate builder.
|
||||
// Where appends a list predicates to the DeviceRequestUpdate builder.
|
||||
func (dru *DeviceRequestUpdate) Where(ps ...predicate.DeviceRequest) *DeviceRequestUpdate {
|
||||
dru.mutation.predicates = append(dru.mutation.predicates, ps...)
|
||||
dru.mutation.Where(ps...)
|
||||
return dru
|
||||
}
|
||||
|
||||
@@ -100,6 +100,9 @@ func (dru *DeviceRequestUpdate) Save(ctx context.Context) (int, error) {
|
||||
return affected, err
|
||||
})
|
||||
for i := len(dru.hooks) - 1; i >= 0; i-- {
|
||||
if dru.hooks[i] == nil {
|
||||
return 0, fmt.Errorf("db: uninitialized hook (forgotten import db/runtime?)")
|
||||
}
|
||||
mut = dru.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, dru.mutation); err != nil {
|
||||
@@ -225,8 +228,8 @@ func (dru *DeviceRequestUpdate) sqlSave(ctx context.Context) (n int, err error)
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, dru.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{devicerequest.Label}
|
||||
} else if cerr, ok := isSQLConstraintError(err); ok {
|
||||
err = cerr
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{err.Error(), err}
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
@@ -321,6 +324,9 @@ func (druo *DeviceRequestUpdateOne) Save(ctx context.Context) (*DeviceRequest, e
|
||||
return node, err
|
||||
})
|
||||
for i := len(druo.hooks) - 1; i >= 0; i-- {
|
||||
if druo.hooks[i] == nil {
|
||||
return nil, fmt.Errorf("db: uninitialized hook (forgotten import db/runtime?)")
|
||||
}
|
||||
mut = druo.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, druo.mutation); err != nil {
|
||||
@@ -466,8 +472,8 @@ func (druo *DeviceRequestUpdateOne) sqlSave(ctx context.Context) (_node *DeviceR
|
||||
if err = sqlgraph.UpdateNode(ctx, druo.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{devicerequest.Label}
|
||||
} else if cerr, ok := isSQLConstraintError(err); ok {
|
||||
err = cerr
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{err.Error(), err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user