feat: update generated storage files
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
This commit is contained in:
parent
07a43f2d66
commit
20b03b3f6d
@ -228,79 +228,79 @@ func (acc *AuthCodeCreate) defaults() {
|
|||||||
// check runs all checks and user-defined validators on the builder.
|
// check runs all checks and user-defined validators on the builder.
|
||||||
func (acc *AuthCodeCreate) check() error {
|
func (acc *AuthCodeCreate) check() error {
|
||||||
if _, ok := acc.mutation.ClientID(); !ok {
|
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 "AuthCode.client_id"`)}
|
||||||
}
|
}
|
||||||
if v, ok := acc.mutation.ClientID(); ok {
|
if v, ok := acc.mutation.ClientID(); ok {
|
||||||
if err := authcode.ClientIDValidator(v); err != nil {
|
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 "AuthCode.client_id": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if _, ok := acc.mutation.Nonce(); !ok {
|
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 "AuthCode.nonce"`)}
|
||||||
}
|
}
|
||||||
if v, ok := acc.mutation.Nonce(); ok {
|
if v, ok := acc.mutation.Nonce(); ok {
|
||||||
if err := authcode.NonceValidator(v); err != nil {
|
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 "AuthCode.nonce": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if _, ok := acc.mutation.RedirectURI(); !ok {
|
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 "AuthCode.redirect_uri"`)}
|
||||||
}
|
}
|
||||||
if v, ok := acc.mutation.RedirectURI(); ok {
|
if v, ok := acc.mutation.RedirectURI(); ok {
|
||||||
if err := authcode.RedirectURIValidator(v); err != nil {
|
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 "AuthCode.redirect_uri": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if _, ok := acc.mutation.ClaimsUserID(); !ok {
|
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 "AuthCode.claims_user_id"`)}
|
||||||
}
|
}
|
||||||
if v, ok := acc.mutation.ClaimsUserID(); ok {
|
if v, ok := acc.mutation.ClaimsUserID(); ok {
|
||||||
if err := authcode.ClaimsUserIDValidator(v); err != nil {
|
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 "AuthCode.claims_user_id": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if _, ok := acc.mutation.ClaimsUsername(); !ok {
|
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 "AuthCode.claims_username"`)}
|
||||||
}
|
}
|
||||||
if v, ok := acc.mutation.ClaimsUsername(); ok {
|
if v, ok := acc.mutation.ClaimsUsername(); ok {
|
||||||
if err := authcode.ClaimsUsernameValidator(v); err != nil {
|
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 "AuthCode.claims_username": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if _, ok := acc.mutation.ClaimsEmail(); !ok {
|
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 "AuthCode.claims_email"`)}
|
||||||
}
|
}
|
||||||
if v, ok := acc.mutation.ClaimsEmail(); ok {
|
if v, ok := acc.mutation.ClaimsEmail(); ok {
|
||||||
if err := authcode.ClaimsEmailValidator(v); err != nil {
|
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 "AuthCode.claims_email": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if _, ok := acc.mutation.ClaimsEmailVerified(); !ok {
|
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 "AuthCode.claims_email_verified"`)}
|
||||||
}
|
}
|
||||||
if _, ok := acc.mutation.ClaimsPreferredUsername(); !ok {
|
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 "AuthCode.claims_preferred_username"`)}
|
||||||
}
|
}
|
||||||
if _, ok := acc.mutation.ConnectorID(); !ok {
|
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 "AuthCode.connector_id"`)}
|
||||||
}
|
}
|
||||||
if v, ok := acc.mutation.ConnectorID(); ok {
|
if v, ok := acc.mutation.ConnectorID(); ok {
|
||||||
if err := authcode.ConnectorIDValidator(v); err != nil {
|
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 "AuthCode.connector_id": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if _, ok := acc.mutation.Expiry(); !ok {
|
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 "AuthCode.expiry"`)}
|
||||||
}
|
}
|
||||||
if _, ok := acc.mutation.CodeChallenge(); !ok {
|
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 "AuthCode.code_challenge"`)}
|
||||||
}
|
}
|
||||||
if _, ok := acc.mutation.CodeChallengeMethod(); !ok {
|
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 "AuthCode.code_challenge_method"`)}
|
||||||
}
|
}
|
||||||
if v, ok := acc.mutation.ID(); ok {
|
if v, ok := acc.mutation.ID(); ok {
|
||||||
if err := authcode.IDValidator(v); err != nil {
|
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 "AuthCode.id": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -314,6 +314,13 @@ func (acc *AuthCodeCreate) sqlSave(ctx context.Context) (*AuthCode, error) {
|
|||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if _spec.ID.Value != nil {
|
||||||
|
if id, ok := _spec.ID.Value.(string); ok {
|
||||||
|
_node.ID = id
|
||||||
|
} else {
|
||||||
|
return nil, fmt.Errorf("unexpected AuthCode.ID type: %T", _spec.ID.Value)
|
||||||
|
}
|
||||||
|
}
|
||||||
return _node, nil
|
return _node, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ func (acq *AuthCodeQuery) FirstIDX(ctx context.Context) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Only returns a single AuthCode entity found by the query, ensuring it only returns one.
|
// Only returns a single AuthCode entity found by the query, ensuring it only returns one.
|
||||||
// Returns a *NotSingularError when exactly one AuthCode entity is not found.
|
// Returns a *NotSingularError when more than one AuthCode entity is found.
|
||||||
// Returns a *NotFoundError when no AuthCode entities are found.
|
// Returns a *NotFoundError when no AuthCode entities are found.
|
||||||
func (acq *AuthCodeQuery) Only(ctx context.Context) (*AuthCode, error) {
|
func (acq *AuthCodeQuery) Only(ctx context.Context) (*AuthCode, error) {
|
||||||
nodes, err := acq.Limit(2).All(ctx)
|
nodes, err := acq.Limit(2).All(ctx)
|
||||||
@ -133,7 +133,7 @@ func (acq *AuthCodeQuery) OnlyX(ctx context.Context) *AuthCode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// OnlyID is like Only, but returns the only AuthCode ID in the query.
|
// OnlyID is like Only, but returns the only AuthCode ID in the query.
|
||||||
// Returns a *NotSingularError when exactly one AuthCode ID is not found.
|
// Returns a *NotSingularError when more than one AuthCode ID is found.
|
||||||
// Returns a *NotFoundError when no entities are found.
|
// Returns a *NotFoundError when no entities are found.
|
||||||
func (acq *AuthCodeQuery) OnlyID(ctx context.Context) (id string, err error) {
|
func (acq *AuthCodeQuery) OnlyID(ctx context.Context) (id string, err error) {
|
||||||
var ids []string
|
var ids []string
|
||||||
@ -242,8 +242,9 @@ func (acq *AuthCodeQuery) Clone() *AuthCodeQuery {
|
|||||||
order: append([]OrderFunc{}, acq.order...),
|
order: append([]OrderFunc{}, acq.order...),
|
||||||
predicates: append([]predicate.AuthCode{}, acq.predicates...),
|
predicates: append([]predicate.AuthCode{}, acq.predicates...),
|
||||||
// clone intermediate query.
|
// clone intermediate query.
|
||||||
sql: acq.sql.Clone(),
|
sql: acq.sql.Clone(),
|
||||||
path: acq.path,
|
path: acq.path,
|
||||||
|
unique: acq.unique,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,6 +337,10 @@ func (acq *AuthCodeQuery) sqlAll(ctx context.Context) ([]*AuthCode, error) {
|
|||||||
|
|
||||||
func (acq *AuthCodeQuery) sqlCount(ctx context.Context) (int, error) {
|
func (acq *AuthCodeQuery) sqlCount(ctx context.Context) (int, error) {
|
||||||
_spec := acq.querySpec()
|
_spec := acq.querySpec()
|
||||||
|
_spec.Node.Columns = acq.fields
|
||||||
|
if len(acq.fields) > 0 {
|
||||||
|
_spec.Unique = acq.unique != nil && *acq.unique
|
||||||
|
}
|
||||||
return sqlgraph.CountNodes(ctx, acq.driver, _spec)
|
return sqlgraph.CountNodes(ctx, acq.driver, _spec)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -407,6 +412,9 @@ func (acq *AuthCodeQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
|||||||
selector = acq.sql
|
selector = acq.sql
|
||||||
selector.Select(selector.Columns(columns...)...)
|
selector.Select(selector.Columns(columns...)...)
|
||||||
}
|
}
|
||||||
|
if acq.unique != nil && *acq.unique {
|
||||||
|
selector.Distinct()
|
||||||
|
}
|
||||||
for _, p := range acq.predicates {
|
for _, p := range acq.predicates {
|
||||||
p(selector)
|
p(selector)
|
||||||
}
|
}
|
||||||
@ -685,9 +693,7 @@ func (acgb *AuthCodeGroupBy) sqlQuery() *sql.Selector {
|
|||||||
for _, f := range acgb.fields {
|
for _, f := range acgb.fields {
|
||||||
columns = append(columns, selector.C(f))
|
columns = append(columns, selector.C(f))
|
||||||
}
|
}
|
||||||
for _, c := range aggregation {
|
columns = append(columns, aggregation...)
|
||||||
columns = append(columns, c)
|
|
||||||
}
|
|
||||||
selector.Select(columns...)
|
selector.Select(columns...)
|
||||||
}
|
}
|
||||||
return selector.GroupBy(selector.Columns(acgb.fields...)...)
|
return selector.GroupBy(selector.Columns(acgb.fields...)...)
|
||||||
|
@ -4,6 +4,7 @@ package db
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -228,37 +229,37 @@ func (acu *AuthCodeUpdate) ExecX(ctx context.Context) {
|
|||||||
func (acu *AuthCodeUpdate) check() error {
|
func (acu *AuthCodeUpdate) check() error {
|
||||||
if v, ok := acu.mutation.ClientID(); ok {
|
if v, ok := acu.mutation.ClientID(); ok {
|
||||||
if err := authcode.ClientIDValidator(v); err != nil {
|
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 "AuthCode.client_id": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v, ok := acu.mutation.Nonce(); ok {
|
if v, ok := acu.mutation.Nonce(); ok {
|
||||||
if err := authcode.NonceValidator(v); err != nil {
|
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 "AuthCode.nonce": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v, ok := acu.mutation.RedirectURI(); ok {
|
if v, ok := acu.mutation.RedirectURI(); ok {
|
||||||
if err := authcode.RedirectURIValidator(v); err != nil {
|
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 "AuthCode.redirect_uri": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v, ok := acu.mutation.ClaimsUserID(); ok {
|
if v, ok := acu.mutation.ClaimsUserID(); ok {
|
||||||
if err := authcode.ClaimsUserIDValidator(v); err != nil {
|
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 "AuthCode.claims_user_id": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v, ok := acu.mutation.ClaimsUsername(); ok {
|
if v, ok := acu.mutation.ClaimsUsername(); ok {
|
||||||
if err := authcode.ClaimsUsernameValidator(v); err != nil {
|
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 "AuthCode.claims_username": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v, ok := acu.mutation.ClaimsEmail(); ok {
|
if v, ok := acu.mutation.ClaimsEmail(); ok {
|
||||||
if err := authcode.ClaimsEmailValidator(v); err != nil {
|
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 "AuthCode.claims_email": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v, ok := acu.mutation.ConnectorID(); ok {
|
if v, ok := acu.mutation.ConnectorID(); ok {
|
||||||
if err := authcode.ConnectorIDValidator(v); err != nil {
|
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 "AuthCode.connector_id": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -632,37 +633,37 @@ func (acuo *AuthCodeUpdateOne) ExecX(ctx context.Context) {
|
|||||||
func (acuo *AuthCodeUpdateOne) check() error {
|
func (acuo *AuthCodeUpdateOne) check() error {
|
||||||
if v, ok := acuo.mutation.ClientID(); ok {
|
if v, ok := acuo.mutation.ClientID(); ok {
|
||||||
if err := authcode.ClientIDValidator(v); err != nil {
|
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 "AuthCode.client_id": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v, ok := acuo.mutation.Nonce(); ok {
|
if v, ok := acuo.mutation.Nonce(); ok {
|
||||||
if err := authcode.NonceValidator(v); err != nil {
|
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 "AuthCode.nonce": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v, ok := acuo.mutation.RedirectURI(); ok {
|
if v, ok := acuo.mutation.RedirectURI(); ok {
|
||||||
if err := authcode.RedirectURIValidator(v); err != nil {
|
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 "AuthCode.redirect_uri": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v, ok := acuo.mutation.ClaimsUserID(); ok {
|
if v, ok := acuo.mutation.ClaimsUserID(); ok {
|
||||||
if err := authcode.ClaimsUserIDValidator(v); err != nil {
|
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 "AuthCode.claims_user_id": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v, ok := acuo.mutation.ClaimsUsername(); ok {
|
if v, ok := acuo.mutation.ClaimsUsername(); ok {
|
||||||
if err := authcode.ClaimsUsernameValidator(v); err != nil {
|
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 "AuthCode.claims_username": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v, ok := acuo.mutation.ClaimsEmail(); ok {
|
if v, ok := acuo.mutation.ClaimsEmail(); ok {
|
||||||
if err := authcode.ClaimsEmailValidator(v); err != nil {
|
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 "AuthCode.claims_email": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v, ok := acuo.mutation.ConnectorID(); ok {
|
if v, ok := acuo.mutation.ConnectorID(); ok {
|
||||||
if err := authcode.ConnectorIDValidator(v); err != nil {
|
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 "AuthCode.connector_id": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -681,7 +682,7 @@ func (acuo *AuthCodeUpdateOne) sqlSave(ctx context.Context) (_node *AuthCode, er
|
|||||||
}
|
}
|
||||||
id, ok := acuo.mutation.ID()
|
id, ok := acuo.mutation.ID()
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing AuthCode.ID for update")}
|
return nil, &ValidationError{Name: "id", err: errors.New(`db: missing "AuthCode.id" for update`)}
|
||||||
}
|
}
|
||||||
_spec.Node.ID.Value = id
|
_spec.Node.ID.Value = id
|
||||||
if fields := acuo.fields; len(fields) > 0 {
|
if fields := acuo.fields; len(fields) > 0 {
|
||||||
|
@ -252,53 +252,53 @@ func (arc *AuthRequestCreate) defaults() {
|
|||||||
// check runs all checks and user-defined validators on the builder.
|
// check runs all checks and user-defined validators on the builder.
|
||||||
func (arc *AuthRequestCreate) check() error {
|
func (arc *AuthRequestCreate) check() error {
|
||||||
if _, ok := arc.mutation.ClientID(); !ok {
|
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 "AuthRequest.client_id"`)}
|
||||||
}
|
}
|
||||||
if _, ok := arc.mutation.RedirectURI(); !ok {
|
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 "AuthRequest.redirect_uri"`)}
|
||||||
}
|
}
|
||||||
if _, ok := arc.mutation.Nonce(); !ok {
|
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 "AuthRequest.nonce"`)}
|
||||||
}
|
}
|
||||||
if _, ok := arc.mutation.State(); !ok {
|
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 "AuthRequest.state"`)}
|
||||||
}
|
}
|
||||||
if _, ok := arc.mutation.ForceApprovalPrompt(); !ok {
|
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 "AuthRequest.force_approval_prompt"`)}
|
||||||
}
|
}
|
||||||
if _, ok := arc.mutation.LoggedIn(); !ok {
|
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 "AuthRequest.logged_in"`)}
|
||||||
}
|
}
|
||||||
if _, ok := arc.mutation.ClaimsUserID(); !ok {
|
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 "AuthRequest.claims_user_id"`)}
|
||||||
}
|
}
|
||||||
if _, ok := arc.mutation.ClaimsUsername(); !ok {
|
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 "AuthRequest.claims_username"`)}
|
||||||
}
|
}
|
||||||
if _, ok := arc.mutation.ClaimsEmail(); !ok {
|
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 "AuthRequest.claims_email"`)}
|
||||||
}
|
}
|
||||||
if _, ok := arc.mutation.ClaimsEmailVerified(); !ok {
|
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 "AuthRequest.claims_email_verified"`)}
|
||||||
}
|
}
|
||||||
if _, ok := arc.mutation.ClaimsPreferredUsername(); !ok {
|
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 "AuthRequest.claims_preferred_username"`)}
|
||||||
}
|
}
|
||||||
if _, ok := arc.mutation.ConnectorID(); !ok {
|
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 "AuthRequest.connector_id"`)}
|
||||||
}
|
}
|
||||||
if _, ok := arc.mutation.Expiry(); !ok {
|
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 "AuthRequest.expiry"`)}
|
||||||
}
|
}
|
||||||
if _, ok := arc.mutation.CodeChallenge(); !ok {
|
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 "AuthRequest.code_challenge"`)}
|
||||||
}
|
}
|
||||||
if _, ok := arc.mutation.CodeChallengeMethod(); !ok {
|
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 "AuthRequest.code_challenge_method"`)}
|
||||||
}
|
}
|
||||||
if v, ok := arc.mutation.ID(); ok {
|
if v, ok := arc.mutation.ID(); ok {
|
||||||
if err := authrequest.IDValidator(v); err != nil {
|
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 "AuthRequest.id": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -312,6 +312,13 @@ func (arc *AuthRequestCreate) sqlSave(ctx context.Context) (*AuthRequest, error)
|
|||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if _spec.ID.Value != nil {
|
||||||
|
if id, ok := _spec.ID.Value.(string); ok {
|
||||||
|
_node.ID = id
|
||||||
|
} else {
|
||||||
|
return nil, fmt.Errorf("unexpected AuthRequest.ID type: %T", _spec.ID.Value)
|
||||||
|
}
|
||||||
|
}
|
||||||
return _node, nil
|
return _node, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ func (arq *AuthRequestQuery) FirstIDX(ctx context.Context) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Only returns a single AuthRequest entity found by the query, ensuring it only returns one.
|
// Only returns a single AuthRequest entity found by the query, ensuring it only returns one.
|
||||||
// Returns a *NotSingularError when exactly one AuthRequest entity is not found.
|
// Returns a *NotSingularError when more than one AuthRequest entity is found.
|
||||||
// Returns a *NotFoundError when no AuthRequest entities are found.
|
// Returns a *NotFoundError when no AuthRequest entities are found.
|
||||||
func (arq *AuthRequestQuery) Only(ctx context.Context) (*AuthRequest, error) {
|
func (arq *AuthRequestQuery) Only(ctx context.Context) (*AuthRequest, error) {
|
||||||
nodes, err := arq.Limit(2).All(ctx)
|
nodes, err := arq.Limit(2).All(ctx)
|
||||||
@ -133,7 +133,7 @@ func (arq *AuthRequestQuery) OnlyX(ctx context.Context) *AuthRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// OnlyID is like Only, but returns the only AuthRequest ID in the query.
|
// OnlyID is like Only, but returns the only AuthRequest ID in the query.
|
||||||
// Returns a *NotSingularError when exactly one AuthRequest ID is not found.
|
// Returns a *NotSingularError when more than one AuthRequest ID is found.
|
||||||
// Returns a *NotFoundError when no entities are found.
|
// Returns a *NotFoundError when no entities are found.
|
||||||
func (arq *AuthRequestQuery) OnlyID(ctx context.Context) (id string, err error) {
|
func (arq *AuthRequestQuery) OnlyID(ctx context.Context) (id string, err error) {
|
||||||
var ids []string
|
var ids []string
|
||||||
@ -242,8 +242,9 @@ func (arq *AuthRequestQuery) Clone() *AuthRequestQuery {
|
|||||||
order: append([]OrderFunc{}, arq.order...),
|
order: append([]OrderFunc{}, arq.order...),
|
||||||
predicates: append([]predicate.AuthRequest{}, arq.predicates...),
|
predicates: append([]predicate.AuthRequest{}, arq.predicates...),
|
||||||
// clone intermediate query.
|
// clone intermediate query.
|
||||||
sql: arq.sql.Clone(),
|
sql: arq.sql.Clone(),
|
||||||
path: arq.path,
|
path: arq.path,
|
||||||
|
unique: arq.unique,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,6 +337,10 @@ func (arq *AuthRequestQuery) sqlAll(ctx context.Context) ([]*AuthRequest, error)
|
|||||||
|
|
||||||
func (arq *AuthRequestQuery) sqlCount(ctx context.Context) (int, error) {
|
func (arq *AuthRequestQuery) sqlCount(ctx context.Context) (int, error) {
|
||||||
_spec := arq.querySpec()
|
_spec := arq.querySpec()
|
||||||
|
_spec.Node.Columns = arq.fields
|
||||||
|
if len(arq.fields) > 0 {
|
||||||
|
_spec.Unique = arq.unique != nil && *arq.unique
|
||||||
|
}
|
||||||
return sqlgraph.CountNodes(ctx, arq.driver, _spec)
|
return sqlgraph.CountNodes(ctx, arq.driver, _spec)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -407,6 +412,9 @@ func (arq *AuthRequestQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
|||||||
selector = arq.sql
|
selector = arq.sql
|
||||||
selector.Select(selector.Columns(columns...)...)
|
selector.Select(selector.Columns(columns...)...)
|
||||||
}
|
}
|
||||||
|
if arq.unique != nil && *arq.unique {
|
||||||
|
selector.Distinct()
|
||||||
|
}
|
||||||
for _, p := range arq.predicates {
|
for _, p := range arq.predicates {
|
||||||
p(selector)
|
p(selector)
|
||||||
}
|
}
|
||||||
@ -685,9 +693,7 @@ func (argb *AuthRequestGroupBy) sqlQuery() *sql.Selector {
|
|||||||
for _, f := range argb.fields {
|
for _, f := range argb.fields {
|
||||||
columns = append(columns, selector.C(f))
|
columns = append(columns, selector.C(f))
|
||||||
}
|
}
|
||||||
for _, c := range aggregation {
|
columns = append(columns, aggregation...)
|
||||||
columns = append(columns, c)
|
|
||||||
}
|
|
||||||
selector.Select(columns...)
|
selector.Select(columns...)
|
||||||
}
|
}
|
||||||
return selector.GroupBy(selector.Columns(argb.fields...)...)
|
return selector.GroupBy(selector.Columns(argb.fields...)...)
|
||||||
|
@ -4,6 +4,7 @@ package db
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -683,7 +684,7 @@ func (aruo *AuthRequestUpdateOne) sqlSave(ctx context.Context) (_node *AuthReque
|
|||||||
}
|
}
|
||||||
id, ok := aruo.mutation.ID()
|
id, ok := aruo.mutation.ID()
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing AuthRequest.ID for update")}
|
return nil, &ValidationError{Name: "id", err: errors.New(`db: missing "AuthRequest.id" for update`)}
|
||||||
}
|
}
|
||||||
_spec.Node.ID.Value = id
|
_spec.Node.ID.Value = id
|
||||||
if fields := aruo.fields; len(fields) > 0 {
|
if fields := aruo.fields; len(fields) > 0 {
|
||||||
|
@ -132,6 +132,7 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
|
|||||||
cfg := c.config
|
cfg := c.config
|
||||||
cfg.driver = &txDriver{tx: tx, drv: c.driver}
|
cfg.driver = &txDriver{tx: tx, drv: c.driver}
|
||||||
return &Tx{
|
return &Tx{
|
||||||
|
ctx: ctx,
|
||||||
config: cfg,
|
config: cfg,
|
||||||
AuthCode: NewAuthCodeClient(cfg),
|
AuthCode: NewAuthCodeClient(cfg),
|
||||||
AuthRequest: NewAuthRequestClient(cfg),
|
AuthRequest: NewAuthRequestClient(cfg),
|
||||||
|
@ -120,30 +120,30 @@ func (cc *ConnectorCreate) ExecX(ctx context.Context) {
|
|||||||
// check runs all checks and user-defined validators on the builder.
|
// check runs all checks and user-defined validators on the builder.
|
||||||
func (cc *ConnectorCreate) check() error {
|
func (cc *ConnectorCreate) check() error {
|
||||||
if _, ok := cc.mutation.GetType(); !ok {
|
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 "Connector.type"`)}
|
||||||
}
|
}
|
||||||
if v, ok := cc.mutation.GetType(); ok {
|
if v, ok := cc.mutation.GetType(); ok {
|
||||||
if err := connector.TypeValidator(v); err != nil {
|
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 "Connector.type": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if _, ok := cc.mutation.Name(); !ok {
|
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 "Connector.name"`)}
|
||||||
}
|
}
|
||||||
if v, ok := cc.mutation.Name(); ok {
|
if v, ok := cc.mutation.Name(); ok {
|
||||||
if err := connector.NameValidator(v); err != nil {
|
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 "Connector.name": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if _, ok := cc.mutation.ResourceVersion(); !ok {
|
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 "Connector.resource_version"`)}
|
||||||
}
|
}
|
||||||
if _, ok := cc.mutation.Config(); !ok {
|
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 "Connector.config"`)}
|
||||||
}
|
}
|
||||||
if v, ok := cc.mutation.ID(); ok {
|
if v, ok := cc.mutation.ID(); ok {
|
||||||
if err := connector.IDValidator(v); err != nil {
|
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 "Connector.id": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -157,6 +157,13 @@ func (cc *ConnectorCreate) sqlSave(ctx context.Context) (*Connector, error) {
|
|||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if _spec.ID.Value != nil {
|
||||||
|
if id, ok := _spec.ID.Value.(string); ok {
|
||||||
|
_node.ID = id
|
||||||
|
} else {
|
||||||
|
return nil, fmt.Errorf("unexpected Connector.ID type: %T", _spec.ID.Value)
|
||||||
|
}
|
||||||
|
}
|
||||||
return _node, nil
|
return _node, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ func (cq *ConnectorQuery) FirstIDX(ctx context.Context) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Only returns a single Connector entity found by the query, ensuring it only returns one.
|
// Only returns a single Connector entity found by the query, ensuring it only returns one.
|
||||||
// Returns a *NotSingularError when exactly one Connector entity is not found.
|
// Returns a *NotSingularError when more than one Connector entity is found.
|
||||||
// Returns a *NotFoundError when no Connector entities are found.
|
// Returns a *NotFoundError when no Connector entities are found.
|
||||||
func (cq *ConnectorQuery) Only(ctx context.Context) (*Connector, error) {
|
func (cq *ConnectorQuery) Only(ctx context.Context) (*Connector, error) {
|
||||||
nodes, err := cq.Limit(2).All(ctx)
|
nodes, err := cq.Limit(2).All(ctx)
|
||||||
@ -133,7 +133,7 @@ func (cq *ConnectorQuery) OnlyX(ctx context.Context) *Connector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// OnlyID is like Only, but returns the only Connector ID in the query.
|
// OnlyID is like Only, but returns the only Connector ID in the query.
|
||||||
// Returns a *NotSingularError when exactly one Connector ID is not found.
|
// Returns a *NotSingularError when more than one Connector ID is found.
|
||||||
// Returns a *NotFoundError when no entities are found.
|
// Returns a *NotFoundError when no entities are found.
|
||||||
func (cq *ConnectorQuery) OnlyID(ctx context.Context) (id string, err error) {
|
func (cq *ConnectorQuery) OnlyID(ctx context.Context) (id string, err error) {
|
||||||
var ids []string
|
var ids []string
|
||||||
@ -242,8 +242,9 @@ func (cq *ConnectorQuery) Clone() *ConnectorQuery {
|
|||||||
order: append([]OrderFunc{}, cq.order...),
|
order: append([]OrderFunc{}, cq.order...),
|
||||||
predicates: append([]predicate.Connector{}, cq.predicates...),
|
predicates: append([]predicate.Connector{}, cq.predicates...),
|
||||||
// clone intermediate query.
|
// clone intermediate query.
|
||||||
sql: cq.sql.Clone(),
|
sql: cq.sql.Clone(),
|
||||||
path: cq.path,
|
path: cq.path,
|
||||||
|
unique: cq.unique,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,6 +337,10 @@ func (cq *ConnectorQuery) sqlAll(ctx context.Context) ([]*Connector, error) {
|
|||||||
|
|
||||||
func (cq *ConnectorQuery) sqlCount(ctx context.Context) (int, error) {
|
func (cq *ConnectorQuery) sqlCount(ctx context.Context) (int, error) {
|
||||||
_spec := cq.querySpec()
|
_spec := cq.querySpec()
|
||||||
|
_spec.Node.Columns = cq.fields
|
||||||
|
if len(cq.fields) > 0 {
|
||||||
|
_spec.Unique = cq.unique != nil && *cq.unique
|
||||||
|
}
|
||||||
return sqlgraph.CountNodes(ctx, cq.driver, _spec)
|
return sqlgraph.CountNodes(ctx, cq.driver, _spec)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -407,6 +412,9 @@ func (cq *ConnectorQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
|||||||
selector = cq.sql
|
selector = cq.sql
|
||||||
selector.Select(selector.Columns(columns...)...)
|
selector.Select(selector.Columns(columns...)...)
|
||||||
}
|
}
|
||||||
|
if cq.unique != nil && *cq.unique {
|
||||||
|
selector.Distinct()
|
||||||
|
}
|
||||||
for _, p := range cq.predicates {
|
for _, p := range cq.predicates {
|
||||||
p(selector)
|
p(selector)
|
||||||
}
|
}
|
||||||
@ -685,9 +693,7 @@ func (cgb *ConnectorGroupBy) sqlQuery() *sql.Selector {
|
|||||||
for _, f := range cgb.fields {
|
for _, f := range cgb.fields {
|
||||||
columns = append(columns, selector.C(f))
|
columns = append(columns, selector.C(f))
|
||||||
}
|
}
|
||||||
for _, c := range aggregation {
|
columns = append(columns, aggregation...)
|
||||||
columns = append(columns, c)
|
|
||||||
}
|
|
||||||
selector.Select(columns...)
|
selector.Select(columns...)
|
||||||
}
|
}
|
||||||
return selector.GroupBy(selector.Columns(cgb.fields...)...)
|
return selector.GroupBy(selector.Columns(cgb.fields...)...)
|
||||||
|
@ -4,6 +4,7 @@ package db
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"entgo.io/ent/dialect/sql"
|
"entgo.io/ent/dialect/sql"
|
||||||
@ -119,12 +120,12 @@ func (cu *ConnectorUpdate) ExecX(ctx context.Context) {
|
|||||||
func (cu *ConnectorUpdate) check() error {
|
func (cu *ConnectorUpdate) check() error {
|
||||||
if v, ok := cu.mutation.GetType(); ok {
|
if v, ok := cu.mutation.GetType(); ok {
|
||||||
if err := connector.TypeValidator(v); err != nil {
|
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 "Connector.type": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v, ok := cu.mutation.Name(); ok {
|
if v, ok := cu.mutation.Name(); ok {
|
||||||
if err := connector.NameValidator(v); err != nil {
|
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 "Connector.name": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -295,12 +296,12 @@ func (cuo *ConnectorUpdateOne) ExecX(ctx context.Context) {
|
|||||||
func (cuo *ConnectorUpdateOne) check() error {
|
func (cuo *ConnectorUpdateOne) check() error {
|
||||||
if v, ok := cuo.mutation.GetType(); ok {
|
if v, ok := cuo.mutation.GetType(); ok {
|
||||||
if err := connector.TypeValidator(v); err != nil {
|
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 "Connector.type": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v, ok := cuo.mutation.Name(); ok {
|
if v, ok := cuo.mutation.Name(); ok {
|
||||||
if err := connector.NameValidator(v); err != nil {
|
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 "Connector.name": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -319,7 +320,7 @@ func (cuo *ConnectorUpdateOne) sqlSave(ctx context.Context) (_node *Connector, e
|
|||||||
}
|
}
|
||||||
id, ok := cuo.mutation.ID()
|
id, ok := cuo.mutation.ID()
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing Connector.ID for update")}
|
return nil, &ValidationError{Name: "id", err: errors.New(`db: missing "Connector.id" for update`)}
|
||||||
}
|
}
|
||||||
_spec.Node.ID.Value = id
|
_spec.Node.ID.Value = id
|
||||||
if fields := cuo.fields; len(fields) > 0 {
|
if fields := cuo.fields; len(fields) > 0 {
|
||||||
|
@ -127,39 +127,39 @@ func (drc *DeviceRequestCreate) ExecX(ctx context.Context) {
|
|||||||
// check runs all checks and user-defined validators on the builder.
|
// check runs all checks and user-defined validators on the builder.
|
||||||
func (drc *DeviceRequestCreate) check() error {
|
func (drc *DeviceRequestCreate) check() error {
|
||||||
if _, ok := drc.mutation.UserCode(); !ok {
|
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 "DeviceRequest.user_code"`)}
|
||||||
}
|
}
|
||||||
if v, ok := drc.mutation.UserCode(); ok {
|
if v, ok := drc.mutation.UserCode(); ok {
|
||||||
if err := devicerequest.UserCodeValidator(v); err != nil {
|
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 "DeviceRequest.user_code": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if _, ok := drc.mutation.DeviceCode(); !ok {
|
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 "DeviceRequest.device_code"`)}
|
||||||
}
|
}
|
||||||
if v, ok := drc.mutation.DeviceCode(); ok {
|
if v, ok := drc.mutation.DeviceCode(); ok {
|
||||||
if err := devicerequest.DeviceCodeValidator(v); err != nil {
|
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 "DeviceRequest.device_code": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if _, ok := drc.mutation.ClientID(); !ok {
|
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 "DeviceRequest.client_id"`)}
|
||||||
}
|
}
|
||||||
if v, ok := drc.mutation.ClientID(); ok {
|
if v, ok := drc.mutation.ClientID(); ok {
|
||||||
if err := devicerequest.ClientIDValidator(v); err != nil {
|
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 "DeviceRequest.client_id": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if _, ok := drc.mutation.ClientSecret(); !ok {
|
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 "DeviceRequest.client_secret"`)}
|
||||||
}
|
}
|
||||||
if v, ok := drc.mutation.ClientSecret(); ok {
|
if v, ok := drc.mutation.ClientSecret(); ok {
|
||||||
if err := devicerequest.ClientSecretValidator(v); err != nil {
|
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 "DeviceRequest.client_secret": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if _, ok := drc.mutation.Expiry(); !ok {
|
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 "DeviceRequest.expiry"`)}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ func (drq *DeviceRequestQuery) FirstIDX(ctx context.Context) int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Only returns a single DeviceRequest entity found by the query, ensuring it only returns one.
|
// Only returns a single DeviceRequest entity found by the query, ensuring it only returns one.
|
||||||
// Returns a *NotSingularError when exactly one DeviceRequest entity is not found.
|
// Returns a *NotSingularError when more than one DeviceRequest entity is found.
|
||||||
// Returns a *NotFoundError when no DeviceRequest entities are found.
|
// Returns a *NotFoundError when no DeviceRequest entities are found.
|
||||||
func (drq *DeviceRequestQuery) Only(ctx context.Context) (*DeviceRequest, error) {
|
func (drq *DeviceRequestQuery) Only(ctx context.Context) (*DeviceRequest, error) {
|
||||||
nodes, err := drq.Limit(2).All(ctx)
|
nodes, err := drq.Limit(2).All(ctx)
|
||||||
@ -133,7 +133,7 @@ func (drq *DeviceRequestQuery) OnlyX(ctx context.Context) *DeviceRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// OnlyID is like Only, but returns the only DeviceRequest ID in the query.
|
// OnlyID is like Only, but returns the only DeviceRequest ID in the query.
|
||||||
// Returns a *NotSingularError when exactly one DeviceRequest ID is not found.
|
// Returns a *NotSingularError when more than one DeviceRequest ID is found.
|
||||||
// Returns a *NotFoundError when no entities are found.
|
// Returns a *NotFoundError when no entities are found.
|
||||||
func (drq *DeviceRequestQuery) OnlyID(ctx context.Context) (id int, err error) {
|
func (drq *DeviceRequestQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||||
var ids []int
|
var ids []int
|
||||||
@ -242,8 +242,9 @@ func (drq *DeviceRequestQuery) Clone() *DeviceRequestQuery {
|
|||||||
order: append([]OrderFunc{}, drq.order...),
|
order: append([]OrderFunc{}, drq.order...),
|
||||||
predicates: append([]predicate.DeviceRequest{}, drq.predicates...),
|
predicates: append([]predicate.DeviceRequest{}, drq.predicates...),
|
||||||
// clone intermediate query.
|
// clone intermediate query.
|
||||||
sql: drq.sql.Clone(),
|
sql: drq.sql.Clone(),
|
||||||
path: drq.path,
|
path: drq.path,
|
||||||
|
unique: drq.unique,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,6 +337,10 @@ func (drq *DeviceRequestQuery) sqlAll(ctx context.Context) ([]*DeviceRequest, er
|
|||||||
|
|
||||||
func (drq *DeviceRequestQuery) sqlCount(ctx context.Context) (int, error) {
|
func (drq *DeviceRequestQuery) sqlCount(ctx context.Context) (int, error) {
|
||||||
_spec := drq.querySpec()
|
_spec := drq.querySpec()
|
||||||
|
_spec.Node.Columns = drq.fields
|
||||||
|
if len(drq.fields) > 0 {
|
||||||
|
_spec.Unique = drq.unique != nil && *drq.unique
|
||||||
|
}
|
||||||
return sqlgraph.CountNodes(ctx, drq.driver, _spec)
|
return sqlgraph.CountNodes(ctx, drq.driver, _spec)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -407,6 +412,9 @@ func (drq *DeviceRequestQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
|||||||
selector = drq.sql
|
selector = drq.sql
|
||||||
selector.Select(selector.Columns(columns...)...)
|
selector.Select(selector.Columns(columns...)...)
|
||||||
}
|
}
|
||||||
|
if drq.unique != nil && *drq.unique {
|
||||||
|
selector.Distinct()
|
||||||
|
}
|
||||||
for _, p := range drq.predicates {
|
for _, p := range drq.predicates {
|
||||||
p(selector)
|
p(selector)
|
||||||
}
|
}
|
||||||
@ -685,9 +693,7 @@ func (drgb *DeviceRequestGroupBy) sqlQuery() *sql.Selector {
|
|||||||
for _, f := range drgb.fields {
|
for _, f := range drgb.fields {
|
||||||
columns = append(columns, selector.C(f))
|
columns = append(columns, selector.C(f))
|
||||||
}
|
}
|
||||||
for _, c := range aggregation {
|
columns = append(columns, aggregation...)
|
||||||
columns = append(columns, c)
|
|
||||||
}
|
|
||||||
selector.Select(columns...)
|
selector.Select(columns...)
|
||||||
}
|
}
|
||||||
return selector.GroupBy(selector.Columns(drgb.fields...)...)
|
return selector.GroupBy(selector.Columns(drgb.fields...)...)
|
||||||
|
@ -4,6 +4,7 @@ package db
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -138,22 +139,22 @@ func (dru *DeviceRequestUpdate) ExecX(ctx context.Context) {
|
|||||||
func (dru *DeviceRequestUpdate) check() error {
|
func (dru *DeviceRequestUpdate) check() error {
|
||||||
if v, ok := dru.mutation.UserCode(); ok {
|
if v, ok := dru.mutation.UserCode(); ok {
|
||||||
if err := devicerequest.UserCodeValidator(v); err != nil {
|
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 "DeviceRequest.user_code": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v, ok := dru.mutation.DeviceCode(); ok {
|
if v, ok := dru.mutation.DeviceCode(); ok {
|
||||||
if err := devicerequest.DeviceCodeValidator(v); err != nil {
|
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 "DeviceRequest.device_code": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v, ok := dru.mutation.ClientID(); ok {
|
if v, ok := dru.mutation.ClientID(); ok {
|
||||||
if err := devicerequest.ClientIDValidator(v); err != nil {
|
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 "DeviceRequest.client_id": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v, ok := dru.mutation.ClientSecret(); ok {
|
if v, ok := dru.mutation.ClientSecret(); ok {
|
||||||
if err := devicerequest.ClientSecretValidator(v); err != nil {
|
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 "DeviceRequest.client_secret": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -362,22 +363,22 @@ func (druo *DeviceRequestUpdateOne) ExecX(ctx context.Context) {
|
|||||||
func (druo *DeviceRequestUpdateOne) check() error {
|
func (druo *DeviceRequestUpdateOne) check() error {
|
||||||
if v, ok := druo.mutation.UserCode(); ok {
|
if v, ok := druo.mutation.UserCode(); ok {
|
||||||
if err := devicerequest.UserCodeValidator(v); err != nil {
|
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 "DeviceRequest.user_code": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v, ok := druo.mutation.DeviceCode(); ok {
|
if v, ok := druo.mutation.DeviceCode(); ok {
|
||||||
if err := devicerequest.DeviceCodeValidator(v); err != nil {
|
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 "DeviceRequest.device_code": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v, ok := druo.mutation.ClientID(); ok {
|
if v, ok := druo.mutation.ClientID(); ok {
|
||||||
if err := devicerequest.ClientIDValidator(v); err != nil {
|
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 "DeviceRequest.client_id": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v, ok := druo.mutation.ClientSecret(); ok {
|
if v, ok := druo.mutation.ClientSecret(); ok {
|
||||||
if err := devicerequest.ClientSecretValidator(v); err != nil {
|
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 "DeviceRequest.client_secret": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -396,7 +397,7 @@ func (druo *DeviceRequestUpdateOne) sqlSave(ctx context.Context) (_node *DeviceR
|
|||||||
}
|
}
|
||||||
id, ok := druo.mutation.ID()
|
id, ok := druo.mutation.ID()
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing DeviceRequest.ID for update")}
|
return nil, &ValidationError{Name: "id", err: errors.New(`db: missing "DeviceRequest.id" for update`)}
|
||||||
}
|
}
|
||||||
_spec.Node.ID.Value = id
|
_spec.Node.ID.Value = id
|
||||||
if fields := druo.fields; len(fields) > 0 {
|
if fields := druo.fields; len(fields) > 0 {
|
||||||
|
@ -127,29 +127,29 @@ func (dtc *DeviceTokenCreate) ExecX(ctx context.Context) {
|
|||||||
// check runs all checks and user-defined validators on the builder.
|
// check runs all checks and user-defined validators on the builder.
|
||||||
func (dtc *DeviceTokenCreate) check() error {
|
func (dtc *DeviceTokenCreate) check() error {
|
||||||
if _, ok := dtc.mutation.DeviceCode(); !ok {
|
if _, ok := dtc.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 "DeviceToken.device_code"`)}
|
||||||
}
|
}
|
||||||
if v, ok := dtc.mutation.DeviceCode(); ok {
|
if v, ok := dtc.mutation.DeviceCode(); ok {
|
||||||
if err := devicetoken.DeviceCodeValidator(v); err != nil {
|
if err := devicetoken.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 "DeviceToken.device_code": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if _, ok := dtc.mutation.Status(); !ok {
|
if _, ok := dtc.mutation.Status(); !ok {
|
||||||
return &ValidationError{Name: "status", err: errors.New(`db: missing required field "status"`)}
|
return &ValidationError{Name: "status", err: errors.New(`db: missing required field "DeviceToken.status"`)}
|
||||||
}
|
}
|
||||||
if v, ok := dtc.mutation.Status(); ok {
|
if v, ok := dtc.mutation.Status(); ok {
|
||||||
if err := devicetoken.StatusValidator(v); err != nil {
|
if err := devicetoken.StatusValidator(v); err != nil {
|
||||||
return &ValidationError{Name: "status", err: fmt.Errorf(`db: validator failed for field "status": %w`, err)}
|
return &ValidationError{Name: "status", err: fmt.Errorf(`db: validator failed for field "DeviceToken.status": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if _, ok := dtc.mutation.Expiry(); !ok {
|
if _, ok := dtc.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 "DeviceToken.expiry"`)}
|
||||||
}
|
}
|
||||||
if _, ok := dtc.mutation.LastRequest(); !ok {
|
if _, ok := dtc.mutation.LastRequest(); !ok {
|
||||||
return &ValidationError{Name: "last_request", err: errors.New(`db: missing required field "last_request"`)}
|
return &ValidationError{Name: "last_request", err: errors.New(`db: missing required field "DeviceToken.last_request"`)}
|
||||||
}
|
}
|
||||||
if _, ok := dtc.mutation.PollInterval(); !ok {
|
if _, ok := dtc.mutation.PollInterval(); !ok {
|
||||||
return &ValidationError{Name: "poll_interval", err: errors.New(`db: missing required field "poll_interval"`)}
|
return &ValidationError{Name: "poll_interval", err: errors.New(`db: missing required field "DeviceToken.poll_interval"`)}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ func (dtq *DeviceTokenQuery) FirstIDX(ctx context.Context) int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Only returns a single DeviceToken entity found by the query, ensuring it only returns one.
|
// Only returns a single DeviceToken entity found by the query, ensuring it only returns one.
|
||||||
// Returns a *NotSingularError when exactly one DeviceToken entity is not found.
|
// Returns a *NotSingularError when more than one DeviceToken entity is found.
|
||||||
// Returns a *NotFoundError when no DeviceToken entities are found.
|
// Returns a *NotFoundError when no DeviceToken entities are found.
|
||||||
func (dtq *DeviceTokenQuery) Only(ctx context.Context) (*DeviceToken, error) {
|
func (dtq *DeviceTokenQuery) Only(ctx context.Context) (*DeviceToken, error) {
|
||||||
nodes, err := dtq.Limit(2).All(ctx)
|
nodes, err := dtq.Limit(2).All(ctx)
|
||||||
@ -133,7 +133,7 @@ func (dtq *DeviceTokenQuery) OnlyX(ctx context.Context) *DeviceToken {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// OnlyID is like Only, but returns the only DeviceToken ID in the query.
|
// OnlyID is like Only, but returns the only DeviceToken ID in the query.
|
||||||
// Returns a *NotSingularError when exactly one DeviceToken ID is not found.
|
// Returns a *NotSingularError when more than one DeviceToken ID is found.
|
||||||
// Returns a *NotFoundError when no entities are found.
|
// Returns a *NotFoundError when no entities are found.
|
||||||
func (dtq *DeviceTokenQuery) OnlyID(ctx context.Context) (id int, err error) {
|
func (dtq *DeviceTokenQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||||
var ids []int
|
var ids []int
|
||||||
@ -242,8 +242,9 @@ func (dtq *DeviceTokenQuery) Clone() *DeviceTokenQuery {
|
|||||||
order: append([]OrderFunc{}, dtq.order...),
|
order: append([]OrderFunc{}, dtq.order...),
|
||||||
predicates: append([]predicate.DeviceToken{}, dtq.predicates...),
|
predicates: append([]predicate.DeviceToken{}, dtq.predicates...),
|
||||||
// clone intermediate query.
|
// clone intermediate query.
|
||||||
sql: dtq.sql.Clone(),
|
sql: dtq.sql.Clone(),
|
||||||
path: dtq.path,
|
path: dtq.path,
|
||||||
|
unique: dtq.unique,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,6 +337,10 @@ func (dtq *DeviceTokenQuery) sqlAll(ctx context.Context) ([]*DeviceToken, error)
|
|||||||
|
|
||||||
func (dtq *DeviceTokenQuery) sqlCount(ctx context.Context) (int, error) {
|
func (dtq *DeviceTokenQuery) sqlCount(ctx context.Context) (int, error) {
|
||||||
_spec := dtq.querySpec()
|
_spec := dtq.querySpec()
|
||||||
|
_spec.Node.Columns = dtq.fields
|
||||||
|
if len(dtq.fields) > 0 {
|
||||||
|
_spec.Unique = dtq.unique != nil && *dtq.unique
|
||||||
|
}
|
||||||
return sqlgraph.CountNodes(ctx, dtq.driver, _spec)
|
return sqlgraph.CountNodes(ctx, dtq.driver, _spec)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -407,6 +412,9 @@ func (dtq *DeviceTokenQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
|||||||
selector = dtq.sql
|
selector = dtq.sql
|
||||||
selector.Select(selector.Columns(columns...)...)
|
selector.Select(selector.Columns(columns...)...)
|
||||||
}
|
}
|
||||||
|
if dtq.unique != nil && *dtq.unique {
|
||||||
|
selector.Distinct()
|
||||||
|
}
|
||||||
for _, p := range dtq.predicates {
|
for _, p := range dtq.predicates {
|
||||||
p(selector)
|
p(selector)
|
||||||
}
|
}
|
||||||
@ -685,9 +693,7 @@ func (dtgb *DeviceTokenGroupBy) sqlQuery() *sql.Selector {
|
|||||||
for _, f := range dtgb.fields {
|
for _, f := range dtgb.fields {
|
||||||
columns = append(columns, selector.C(f))
|
columns = append(columns, selector.C(f))
|
||||||
}
|
}
|
||||||
for _, c := range aggregation {
|
columns = append(columns, aggregation...)
|
||||||
columns = append(columns, c)
|
|
||||||
}
|
|
||||||
selector.Select(columns...)
|
selector.Select(columns...)
|
||||||
}
|
}
|
||||||
return selector.GroupBy(selector.Columns(dtgb.fields...)...)
|
return selector.GroupBy(selector.Columns(dtgb.fields...)...)
|
||||||
|
@ -4,6 +4,7 @@ package db
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -145,12 +146,12 @@ func (dtu *DeviceTokenUpdate) ExecX(ctx context.Context) {
|
|||||||
func (dtu *DeviceTokenUpdate) check() error {
|
func (dtu *DeviceTokenUpdate) check() error {
|
||||||
if v, ok := dtu.mutation.DeviceCode(); ok {
|
if v, ok := dtu.mutation.DeviceCode(); ok {
|
||||||
if err := devicetoken.DeviceCodeValidator(v); err != nil {
|
if err := devicetoken.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 "DeviceToken.device_code": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v, ok := dtu.mutation.Status(); ok {
|
if v, ok := dtu.mutation.Status(); ok {
|
||||||
if err := devicetoken.StatusValidator(v); err != nil {
|
if err := devicetoken.StatusValidator(v); err != nil {
|
||||||
return &ValidationError{Name: "status", err: fmt.Errorf("db: validator failed for field \"status\": %w", err)}
|
return &ValidationError{Name: "status", err: fmt.Errorf(`db: validator failed for field "DeviceToken.status": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -373,12 +374,12 @@ func (dtuo *DeviceTokenUpdateOne) ExecX(ctx context.Context) {
|
|||||||
func (dtuo *DeviceTokenUpdateOne) check() error {
|
func (dtuo *DeviceTokenUpdateOne) check() error {
|
||||||
if v, ok := dtuo.mutation.DeviceCode(); ok {
|
if v, ok := dtuo.mutation.DeviceCode(); ok {
|
||||||
if err := devicetoken.DeviceCodeValidator(v); err != nil {
|
if err := devicetoken.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 "DeviceToken.device_code": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v, ok := dtuo.mutation.Status(); ok {
|
if v, ok := dtuo.mutation.Status(); ok {
|
||||||
if err := devicetoken.StatusValidator(v); err != nil {
|
if err := devicetoken.StatusValidator(v); err != nil {
|
||||||
return &ValidationError{Name: "status", err: fmt.Errorf("db: validator failed for field \"status\": %w", err)}
|
return &ValidationError{Name: "status", err: fmt.Errorf(`db: validator failed for field "DeviceToken.status": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -397,7 +398,7 @@ func (dtuo *DeviceTokenUpdateOne) sqlSave(ctx context.Context) (_node *DeviceTok
|
|||||||
}
|
}
|
||||||
id, ok := dtuo.mutation.ID()
|
id, ok := dtuo.mutation.ID()
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing DeviceToken.ID for update")}
|
return nil, &ValidationError{Name: "id", err: errors.New(`db: missing "DeviceToken.id" for update`)}
|
||||||
}
|
}
|
||||||
_spec.Node.ID.Value = id
|
_spec.Node.ID.Value = id
|
||||||
if fields := dtuo.fields; len(fields) > 0 {
|
if fields := dtuo.fields; len(fields) > 0 {
|
||||||
|
@ -159,7 +159,7 @@ func Sum(field string) AggregateFunc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValidationError returns when validating a field fails.
|
// ValidationError returns when validating a field or edge fails.
|
||||||
type ValidationError struct {
|
type ValidationError struct {
|
||||||
Name string // Field or edge name.
|
Name string // Field or edge name.
|
||||||
err error
|
err error
|
||||||
|
@ -123,20 +123,20 @@ func (kc *KeysCreate) ExecX(ctx context.Context) {
|
|||||||
// check runs all checks and user-defined validators on the builder.
|
// check runs all checks and user-defined validators on the builder.
|
||||||
func (kc *KeysCreate) check() error {
|
func (kc *KeysCreate) check() error {
|
||||||
if _, ok := kc.mutation.VerificationKeys(); !ok {
|
if _, ok := kc.mutation.VerificationKeys(); !ok {
|
||||||
return &ValidationError{Name: "verification_keys", err: errors.New(`db: missing required field "verification_keys"`)}
|
return &ValidationError{Name: "verification_keys", err: errors.New(`db: missing required field "Keys.verification_keys"`)}
|
||||||
}
|
}
|
||||||
if _, ok := kc.mutation.SigningKey(); !ok {
|
if _, ok := kc.mutation.SigningKey(); !ok {
|
||||||
return &ValidationError{Name: "signing_key", err: errors.New(`db: missing required field "signing_key"`)}
|
return &ValidationError{Name: "signing_key", err: errors.New(`db: missing required field "Keys.signing_key"`)}
|
||||||
}
|
}
|
||||||
if _, ok := kc.mutation.SigningKeyPub(); !ok {
|
if _, ok := kc.mutation.SigningKeyPub(); !ok {
|
||||||
return &ValidationError{Name: "signing_key_pub", err: errors.New(`db: missing required field "signing_key_pub"`)}
|
return &ValidationError{Name: "signing_key_pub", err: errors.New(`db: missing required field "Keys.signing_key_pub"`)}
|
||||||
}
|
}
|
||||||
if _, ok := kc.mutation.NextRotation(); !ok {
|
if _, ok := kc.mutation.NextRotation(); !ok {
|
||||||
return &ValidationError{Name: "next_rotation", err: errors.New(`db: missing required field "next_rotation"`)}
|
return &ValidationError{Name: "next_rotation", err: errors.New(`db: missing required field "Keys.next_rotation"`)}
|
||||||
}
|
}
|
||||||
if v, ok := kc.mutation.ID(); ok {
|
if v, ok := kc.mutation.ID(); ok {
|
||||||
if err := keys.IDValidator(v); err != nil {
|
if err := keys.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 "Keys.id": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -150,6 +150,13 @@ func (kc *KeysCreate) sqlSave(ctx context.Context) (*Keys, error) {
|
|||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if _spec.ID.Value != nil {
|
||||||
|
if id, ok := _spec.ID.Value.(string); ok {
|
||||||
|
_node.ID = id
|
||||||
|
} else {
|
||||||
|
return nil, fmt.Errorf("unexpected Keys.ID type: %T", _spec.ID.Value)
|
||||||
|
}
|
||||||
|
}
|
||||||
return _node, nil
|
return _node, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ func (kq *KeysQuery) FirstIDX(ctx context.Context) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Only returns a single Keys entity found by the query, ensuring it only returns one.
|
// Only returns a single Keys entity found by the query, ensuring it only returns one.
|
||||||
// Returns a *NotSingularError when exactly one Keys entity is not found.
|
// Returns a *NotSingularError when more than one Keys entity is found.
|
||||||
// Returns a *NotFoundError when no Keys entities are found.
|
// Returns a *NotFoundError when no Keys entities are found.
|
||||||
func (kq *KeysQuery) Only(ctx context.Context) (*Keys, error) {
|
func (kq *KeysQuery) Only(ctx context.Context) (*Keys, error) {
|
||||||
nodes, err := kq.Limit(2).All(ctx)
|
nodes, err := kq.Limit(2).All(ctx)
|
||||||
@ -133,7 +133,7 @@ func (kq *KeysQuery) OnlyX(ctx context.Context) *Keys {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// OnlyID is like Only, but returns the only Keys ID in the query.
|
// OnlyID is like Only, but returns the only Keys ID in the query.
|
||||||
// Returns a *NotSingularError when exactly one Keys ID is not found.
|
// Returns a *NotSingularError when more than one Keys ID is found.
|
||||||
// Returns a *NotFoundError when no entities are found.
|
// Returns a *NotFoundError when no entities are found.
|
||||||
func (kq *KeysQuery) OnlyID(ctx context.Context) (id string, err error) {
|
func (kq *KeysQuery) OnlyID(ctx context.Context) (id string, err error) {
|
||||||
var ids []string
|
var ids []string
|
||||||
@ -242,8 +242,9 @@ func (kq *KeysQuery) Clone() *KeysQuery {
|
|||||||
order: append([]OrderFunc{}, kq.order...),
|
order: append([]OrderFunc{}, kq.order...),
|
||||||
predicates: append([]predicate.Keys{}, kq.predicates...),
|
predicates: append([]predicate.Keys{}, kq.predicates...),
|
||||||
// clone intermediate query.
|
// clone intermediate query.
|
||||||
sql: kq.sql.Clone(),
|
sql: kq.sql.Clone(),
|
||||||
path: kq.path,
|
path: kq.path,
|
||||||
|
unique: kq.unique,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,6 +337,10 @@ func (kq *KeysQuery) sqlAll(ctx context.Context) ([]*Keys, error) {
|
|||||||
|
|
||||||
func (kq *KeysQuery) sqlCount(ctx context.Context) (int, error) {
|
func (kq *KeysQuery) sqlCount(ctx context.Context) (int, error) {
|
||||||
_spec := kq.querySpec()
|
_spec := kq.querySpec()
|
||||||
|
_spec.Node.Columns = kq.fields
|
||||||
|
if len(kq.fields) > 0 {
|
||||||
|
_spec.Unique = kq.unique != nil && *kq.unique
|
||||||
|
}
|
||||||
return sqlgraph.CountNodes(ctx, kq.driver, _spec)
|
return sqlgraph.CountNodes(ctx, kq.driver, _spec)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -407,6 +412,9 @@ func (kq *KeysQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
|||||||
selector = kq.sql
|
selector = kq.sql
|
||||||
selector.Select(selector.Columns(columns...)...)
|
selector.Select(selector.Columns(columns...)...)
|
||||||
}
|
}
|
||||||
|
if kq.unique != nil && *kq.unique {
|
||||||
|
selector.Distinct()
|
||||||
|
}
|
||||||
for _, p := range kq.predicates {
|
for _, p := range kq.predicates {
|
||||||
p(selector)
|
p(selector)
|
||||||
}
|
}
|
||||||
@ -685,9 +693,7 @@ func (kgb *KeysGroupBy) sqlQuery() *sql.Selector {
|
|||||||
for _, f := range kgb.fields {
|
for _, f := range kgb.fields {
|
||||||
columns = append(columns, selector.C(f))
|
columns = append(columns, selector.C(f))
|
||||||
}
|
}
|
||||||
for _, c := range aggregation {
|
columns = append(columns, aggregation...)
|
||||||
columns = append(columns, c)
|
|
||||||
}
|
|
||||||
selector.Select(columns...)
|
selector.Select(columns...)
|
||||||
}
|
}
|
||||||
return selector.GroupBy(selector.Columns(kgb.fields...)...)
|
return selector.GroupBy(selector.Columns(kgb.fields...)...)
|
||||||
|
@ -4,6 +4,7 @@ package db
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -280,7 +281,7 @@ func (kuo *KeysUpdateOne) sqlSave(ctx context.Context) (_node *Keys, err error)
|
|||||||
}
|
}
|
||||||
id, ok := kuo.mutation.ID()
|
id, ok := kuo.mutation.ID()
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing Keys.ID for update")}
|
return nil, &ValidationError{Name: "id", err: errors.New(`db: missing "Keys.id" for update`)}
|
||||||
}
|
}
|
||||||
_spec.Node.ID.Value = id
|
_spec.Node.ID.Value = id
|
||||||
if fields := kuo.fields; len(fields) > 0 {
|
if fields := kuo.fields; len(fields) > 0 {
|
||||||
|
@ -37,8 +37,7 @@ var (
|
|||||||
|
|
||||||
// Schema is the API for creating, migrating and dropping a schema.
|
// Schema is the API for creating, migrating and dropping a schema.
|
||||||
type Schema struct {
|
type Schema struct {
|
||||||
drv dialect.Driver
|
drv dialect.Driver
|
||||||
universalID bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewSchema creates a new schema client.
|
// NewSchema creates a new schema client.
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -132,35 +132,35 @@ func (oc *OAuth2ClientCreate) ExecX(ctx context.Context) {
|
|||||||
// check runs all checks and user-defined validators on the builder.
|
// check runs all checks and user-defined validators on the builder.
|
||||||
func (oc *OAuth2ClientCreate) check() error {
|
func (oc *OAuth2ClientCreate) check() error {
|
||||||
if _, ok := oc.mutation.Secret(); !ok {
|
if _, ok := oc.mutation.Secret(); !ok {
|
||||||
return &ValidationError{Name: "secret", err: errors.New(`db: missing required field "secret"`)}
|
return &ValidationError{Name: "secret", err: errors.New(`db: missing required field "OAuth2Client.secret"`)}
|
||||||
}
|
}
|
||||||
if v, ok := oc.mutation.Secret(); ok {
|
if v, ok := oc.mutation.Secret(); ok {
|
||||||
if err := oauth2client.SecretValidator(v); err != nil {
|
if err := oauth2client.SecretValidator(v); err != nil {
|
||||||
return &ValidationError{Name: "secret", err: fmt.Errorf(`db: validator failed for field "secret": %w`, err)}
|
return &ValidationError{Name: "secret", err: fmt.Errorf(`db: validator failed for field "OAuth2Client.secret": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if _, ok := oc.mutation.Public(); !ok {
|
if _, ok := oc.mutation.Public(); !ok {
|
||||||
return &ValidationError{Name: "public", err: errors.New(`db: missing required field "public"`)}
|
return &ValidationError{Name: "public", err: errors.New(`db: missing required field "OAuth2Client.public"`)}
|
||||||
}
|
}
|
||||||
if _, ok := oc.mutation.Name(); !ok {
|
if _, ok := oc.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 "OAuth2Client.name"`)}
|
||||||
}
|
}
|
||||||
if v, ok := oc.mutation.Name(); ok {
|
if v, ok := oc.mutation.Name(); ok {
|
||||||
if err := oauth2client.NameValidator(v); err != nil {
|
if err := oauth2client.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 "OAuth2Client.name": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if _, ok := oc.mutation.LogoURL(); !ok {
|
if _, ok := oc.mutation.LogoURL(); !ok {
|
||||||
return &ValidationError{Name: "logo_url", err: errors.New(`db: missing required field "logo_url"`)}
|
return &ValidationError{Name: "logo_url", err: errors.New(`db: missing required field "OAuth2Client.logo_url"`)}
|
||||||
}
|
}
|
||||||
if v, ok := oc.mutation.LogoURL(); ok {
|
if v, ok := oc.mutation.LogoURL(); ok {
|
||||||
if err := oauth2client.LogoURLValidator(v); err != nil {
|
if err := oauth2client.LogoURLValidator(v); err != nil {
|
||||||
return &ValidationError{Name: "logo_url", err: fmt.Errorf(`db: validator failed for field "logo_url": %w`, err)}
|
return &ValidationError{Name: "logo_url", err: fmt.Errorf(`db: validator failed for field "OAuth2Client.logo_url": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v, ok := oc.mutation.ID(); ok {
|
if v, ok := oc.mutation.ID(); ok {
|
||||||
if err := oauth2client.IDValidator(v); err != nil {
|
if err := oauth2client.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 "OAuth2Client.id": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -174,6 +174,13 @@ func (oc *OAuth2ClientCreate) sqlSave(ctx context.Context) (*OAuth2Client, error
|
|||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if _spec.ID.Value != nil {
|
||||||
|
if id, ok := _spec.ID.Value.(string); ok {
|
||||||
|
_node.ID = id
|
||||||
|
} else {
|
||||||
|
return nil, fmt.Errorf("unexpected OAuth2Client.ID type: %T", _spec.ID.Value)
|
||||||
|
}
|
||||||
|
}
|
||||||
return _node, nil
|
return _node, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ func (oq *OAuth2ClientQuery) FirstIDX(ctx context.Context) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Only returns a single OAuth2Client entity found by the query, ensuring it only returns one.
|
// Only returns a single OAuth2Client entity found by the query, ensuring it only returns one.
|
||||||
// Returns a *NotSingularError when exactly one OAuth2Client entity is not found.
|
// Returns a *NotSingularError when more than one OAuth2Client entity is found.
|
||||||
// Returns a *NotFoundError when no OAuth2Client entities are found.
|
// Returns a *NotFoundError when no OAuth2Client entities are found.
|
||||||
func (oq *OAuth2ClientQuery) Only(ctx context.Context) (*OAuth2Client, error) {
|
func (oq *OAuth2ClientQuery) Only(ctx context.Context) (*OAuth2Client, error) {
|
||||||
nodes, err := oq.Limit(2).All(ctx)
|
nodes, err := oq.Limit(2).All(ctx)
|
||||||
@ -133,7 +133,7 @@ func (oq *OAuth2ClientQuery) OnlyX(ctx context.Context) *OAuth2Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// OnlyID is like Only, but returns the only OAuth2Client ID in the query.
|
// OnlyID is like Only, but returns the only OAuth2Client ID in the query.
|
||||||
// Returns a *NotSingularError when exactly one OAuth2Client ID is not found.
|
// Returns a *NotSingularError when more than one OAuth2Client ID is found.
|
||||||
// Returns a *NotFoundError when no entities are found.
|
// Returns a *NotFoundError when no entities are found.
|
||||||
func (oq *OAuth2ClientQuery) OnlyID(ctx context.Context) (id string, err error) {
|
func (oq *OAuth2ClientQuery) OnlyID(ctx context.Context) (id string, err error) {
|
||||||
var ids []string
|
var ids []string
|
||||||
@ -242,8 +242,9 @@ func (oq *OAuth2ClientQuery) Clone() *OAuth2ClientQuery {
|
|||||||
order: append([]OrderFunc{}, oq.order...),
|
order: append([]OrderFunc{}, oq.order...),
|
||||||
predicates: append([]predicate.OAuth2Client{}, oq.predicates...),
|
predicates: append([]predicate.OAuth2Client{}, oq.predicates...),
|
||||||
// clone intermediate query.
|
// clone intermediate query.
|
||||||
sql: oq.sql.Clone(),
|
sql: oq.sql.Clone(),
|
||||||
path: oq.path,
|
path: oq.path,
|
||||||
|
unique: oq.unique,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,6 +337,10 @@ func (oq *OAuth2ClientQuery) sqlAll(ctx context.Context) ([]*OAuth2Client, error
|
|||||||
|
|
||||||
func (oq *OAuth2ClientQuery) sqlCount(ctx context.Context) (int, error) {
|
func (oq *OAuth2ClientQuery) sqlCount(ctx context.Context) (int, error) {
|
||||||
_spec := oq.querySpec()
|
_spec := oq.querySpec()
|
||||||
|
_spec.Node.Columns = oq.fields
|
||||||
|
if len(oq.fields) > 0 {
|
||||||
|
_spec.Unique = oq.unique != nil && *oq.unique
|
||||||
|
}
|
||||||
return sqlgraph.CountNodes(ctx, oq.driver, _spec)
|
return sqlgraph.CountNodes(ctx, oq.driver, _spec)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -407,6 +412,9 @@ func (oq *OAuth2ClientQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
|||||||
selector = oq.sql
|
selector = oq.sql
|
||||||
selector.Select(selector.Columns(columns...)...)
|
selector.Select(selector.Columns(columns...)...)
|
||||||
}
|
}
|
||||||
|
if oq.unique != nil && *oq.unique {
|
||||||
|
selector.Distinct()
|
||||||
|
}
|
||||||
for _, p := range oq.predicates {
|
for _, p := range oq.predicates {
|
||||||
p(selector)
|
p(selector)
|
||||||
}
|
}
|
||||||
@ -685,9 +693,7 @@ func (ogb *OAuth2ClientGroupBy) sqlQuery() *sql.Selector {
|
|||||||
for _, f := range ogb.fields {
|
for _, f := range ogb.fields {
|
||||||
columns = append(columns, selector.C(f))
|
columns = append(columns, selector.C(f))
|
||||||
}
|
}
|
||||||
for _, c := range aggregation {
|
columns = append(columns, aggregation...)
|
||||||
columns = append(columns, c)
|
|
||||||
}
|
|
||||||
selector.Select(columns...)
|
selector.Select(columns...)
|
||||||
}
|
}
|
||||||
return selector.GroupBy(selector.Columns(ogb.fields...)...)
|
return selector.GroupBy(selector.Columns(ogb.fields...)...)
|
||||||
|
@ -4,6 +4,7 @@ package db
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"entgo.io/ent/dialect/sql"
|
"entgo.io/ent/dialect/sql"
|
||||||
@ -143,17 +144,17 @@ func (ou *OAuth2ClientUpdate) ExecX(ctx context.Context) {
|
|||||||
func (ou *OAuth2ClientUpdate) check() error {
|
func (ou *OAuth2ClientUpdate) check() error {
|
||||||
if v, ok := ou.mutation.Secret(); ok {
|
if v, ok := ou.mutation.Secret(); ok {
|
||||||
if err := oauth2client.SecretValidator(v); err != nil {
|
if err := oauth2client.SecretValidator(v); err != nil {
|
||||||
return &ValidationError{Name: "secret", err: fmt.Errorf("db: validator failed for field \"secret\": %w", err)}
|
return &ValidationError{Name: "secret", err: fmt.Errorf(`db: validator failed for field "OAuth2Client.secret": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v, ok := ou.mutation.Name(); ok {
|
if v, ok := ou.mutation.Name(); ok {
|
||||||
if err := oauth2client.NameValidator(v); err != nil {
|
if err := oauth2client.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 "OAuth2Client.name": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v, ok := ou.mutation.LogoURL(); ok {
|
if v, ok := ou.mutation.LogoURL(); ok {
|
||||||
if err := oauth2client.LogoURLValidator(v); err != nil {
|
if err := oauth2client.LogoURLValidator(v); err != nil {
|
||||||
return &ValidationError{Name: "logo_url", err: fmt.Errorf("db: validator failed for field \"logo_url\": %w", err)}
|
return &ValidationError{Name: "logo_url", err: fmt.Errorf(`db: validator failed for field "OAuth2Client.logo_url": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -374,17 +375,17 @@ func (ouo *OAuth2ClientUpdateOne) ExecX(ctx context.Context) {
|
|||||||
func (ouo *OAuth2ClientUpdateOne) check() error {
|
func (ouo *OAuth2ClientUpdateOne) check() error {
|
||||||
if v, ok := ouo.mutation.Secret(); ok {
|
if v, ok := ouo.mutation.Secret(); ok {
|
||||||
if err := oauth2client.SecretValidator(v); err != nil {
|
if err := oauth2client.SecretValidator(v); err != nil {
|
||||||
return &ValidationError{Name: "secret", err: fmt.Errorf("db: validator failed for field \"secret\": %w", err)}
|
return &ValidationError{Name: "secret", err: fmt.Errorf(`db: validator failed for field "OAuth2Client.secret": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v, ok := ouo.mutation.Name(); ok {
|
if v, ok := ouo.mutation.Name(); ok {
|
||||||
if err := oauth2client.NameValidator(v); err != nil {
|
if err := oauth2client.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 "OAuth2Client.name": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v, ok := ouo.mutation.LogoURL(); ok {
|
if v, ok := ouo.mutation.LogoURL(); ok {
|
||||||
if err := oauth2client.LogoURLValidator(v); err != nil {
|
if err := oauth2client.LogoURLValidator(v); err != nil {
|
||||||
return &ValidationError{Name: "logo_url", err: fmt.Errorf("db: validator failed for field \"logo_url\": %w", err)}
|
return &ValidationError{Name: "logo_url", err: fmt.Errorf(`db: validator failed for field "OAuth2Client.logo_url": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -403,7 +404,7 @@ func (ouo *OAuth2ClientUpdateOne) sqlSave(ctx context.Context) (_node *OAuth2Cli
|
|||||||
}
|
}
|
||||||
id, ok := ouo.mutation.ID()
|
id, ok := ouo.mutation.ID()
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing OAuth2Client.ID for update")}
|
return nil, &ValidationError{Name: "id", err: errors.New(`db: missing "OAuth2Client.id" for update`)}
|
||||||
}
|
}
|
||||||
_spec.Node.ID.Value = id
|
_spec.Node.ID.Value = id
|
||||||
if fields := ouo.fields; len(fields) > 0 {
|
if fields := ouo.fields; len(fields) > 0 {
|
||||||
|
@ -120,27 +120,27 @@ func (osc *OfflineSessionCreate) ExecX(ctx context.Context) {
|
|||||||
// check runs all checks and user-defined validators on the builder.
|
// check runs all checks and user-defined validators on the builder.
|
||||||
func (osc *OfflineSessionCreate) check() error {
|
func (osc *OfflineSessionCreate) check() error {
|
||||||
if _, ok := osc.mutation.UserID(); !ok {
|
if _, ok := osc.mutation.UserID(); !ok {
|
||||||
return &ValidationError{Name: "user_id", err: errors.New(`db: missing required field "user_id"`)}
|
return &ValidationError{Name: "user_id", err: errors.New(`db: missing required field "OfflineSession.user_id"`)}
|
||||||
}
|
}
|
||||||
if v, ok := osc.mutation.UserID(); ok {
|
if v, ok := osc.mutation.UserID(); ok {
|
||||||
if err := offlinesession.UserIDValidator(v); err != nil {
|
if err := offlinesession.UserIDValidator(v); err != nil {
|
||||||
return &ValidationError{Name: "user_id", err: fmt.Errorf(`db: validator failed for field "user_id": %w`, err)}
|
return &ValidationError{Name: "user_id", err: fmt.Errorf(`db: validator failed for field "OfflineSession.user_id": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if _, ok := osc.mutation.ConnID(); !ok {
|
if _, ok := osc.mutation.ConnID(); !ok {
|
||||||
return &ValidationError{Name: "conn_id", err: errors.New(`db: missing required field "conn_id"`)}
|
return &ValidationError{Name: "conn_id", err: errors.New(`db: missing required field "OfflineSession.conn_id"`)}
|
||||||
}
|
}
|
||||||
if v, ok := osc.mutation.ConnID(); ok {
|
if v, ok := osc.mutation.ConnID(); ok {
|
||||||
if err := offlinesession.ConnIDValidator(v); err != nil {
|
if err := offlinesession.ConnIDValidator(v); err != nil {
|
||||||
return &ValidationError{Name: "conn_id", err: fmt.Errorf(`db: validator failed for field "conn_id": %w`, err)}
|
return &ValidationError{Name: "conn_id", err: fmt.Errorf(`db: validator failed for field "OfflineSession.conn_id": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if _, ok := osc.mutation.Refresh(); !ok {
|
if _, ok := osc.mutation.Refresh(); !ok {
|
||||||
return &ValidationError{Name: "refresh", err: errors.New(`db: missing required field "refresh"`)}
|
return &ValidationError{Name: "refresh", err: errors.New(`db: missing required field "OfflineSession.refresh"`)}
|
||||||
}
|
}
|
||||||
if v, ok := osc.mutation.ID(); ok {
|
if v, ok := osc.mutation.ID(); ok {
|
||||||
if err := offlinesession.IDValidator(v); err != nil {
|
if err := offlinesession.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 "OfflineSession.id": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -154,6 +154,13 @@ func (osc *OfflineSessionCreate) sqlSave(ctx context.Context) (*OfflineSession,
|
|||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if _spec.ID.Value != nil {
|
||||||
|
if id, ok := _spec.ID.Value.(string); ok {
|
||||||
|
_node.ID = id
|
||||||
|
} else {
|
||||||
|
return nil, fmt.Errorf("unexpected OfflineSession.ID type: %T", _spec.ID.Value)
|
||||||
|
}
|
||||||
|
}
|
||||||
return _node, nil
|
return _node, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ func (osq *OfflineSessionQuery) FirstIDX(ctx context.Context) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Only returns a single OfflineSession entity found by the query, ensuring it only returns one.
|
// Only returns a single OfflineSession entity found by the query, ensuring it only returns one.
|
||||||
// Returns a *NotSingularError when exactly one OfflineSession entity is not found.
|
// Returns a *NotSingularError when more than one OfflineSession entity is found.
|
||||||
// Returns a *NotFoundError when no OfflineSession entities are found.
|
// Returns a *NotFoundError when no OfflineSession entities are found.
|
||||||
func (osq *OfflineSessionQuery) Only(ctx context.Context) (*OfflineSession, error) {
|
func (osq *OfflineSessionQuery) Only(ctx context.Context) (*OfflineSession, error) {
|
||||||
nodes, err := osq.Limit(2).All(ctx)
|
nodes, err := osq.Limit(2).All(ctx)
|
||||||
@ -133,7 +133,7 @@ func (osq *OfflineSessionQuery) OnlyX(ctx context.Context) *OfflineSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// OnlyID is like Only, but returns the only OfflineSession ID in the query.
|
// OnlyID is like Only, but returns the only OfflineSession ID in the query.
|
||||||
// Returns a *NotSingularError when exactly one OfflineSession ID is not found.
|
// Returns a *NotSingularError when more than one OfflineSession ID is found.
|
||||||
// Returns a *NotFoundError when no entities are found.
|
// Returns a *NotFoundError when no entities are found.
|
||||||
func (osq *OfflineSessionQuery) OnlyID(ctx context.Context) (id string, err error) {
|
func (osq *OfflineSessionQuery) OnlyID(ctx context.Context) (id string, err error) {
|
||||||
var ids []string
|
var ids []string
|
||||||
@ -242,8 +242,9 @@ func (osq *OfflineSessionQuery) Clone() *OfflineSessionQuery {
|
|||||||
order: append([]OrderFunc{}, osq.order...),
|
order: append([]OrderFunc{}, osq.order...),
|
||||||
predicates: append([]predicate.OfflineSession{}, osq.predicates...),
|
predicates: append([]predicate.OfflineSession{}, osq.predicates...),
|
||||||
// clone intermediate query.
|
// clone intermediate query.
|
||||||
sql: osq.sql.Clone(),
|
sql: osq.sql.Clone(),
|
||||||
path: osq.path,
|
path: osq.path,
|
||||||
|
unique: osq.unique,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,6 +337,10 @@ func (osq *OfflineSessionQuery) sqlAll(ctx context.Context) ([]*OfflineSession,
|
|||||||
|
|
||||||
func (osq *OfflineSessionQuery) sqlCount(ctx context.Context) (int, error) {
|
func (osq *OfflineSessionQuery) sqlCount(ctx context.Context) (int, error) {
|
||||||
_spec := osq.querySpec()
|
_spec := osq.querySpec()
|
||||||
|
_spec.Node.Columns = osq.fields
|
||||||
|
if len(osq.fields) > 0 {
|
||||||
|
_spec.Unique = osq.unique != nil && *osq.unique
|
||||||
|
}
|
||||||
return sqlgraph.CountNodes(ctx, osq.driver, _spec)
|
return sqlgraph.CountNodes(ctx, osq.driver, _spec)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -407,6 +412,9 @@ func (osq *OfflineSessionQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
|||||||
selector = osq.sql
|
selector = osq.sql
|
||||||
selector.Select(selector.Columns(columns...)...)
|
selector.Select(selector.Columns(columns...)...)
|
||||||
}
|
}
|
||||||
|
if osq.unique != nil && *osq.unique {
|
||||||
|
selector.Distinct()
|
||||||
|
}
|
||||||
for _, p := range osq.predicates {
|
for _, p := range osq.predicates {
|
||||||
p(selector)
|
p(selector)
|
||||||
}
|
}
|
||||||
@ -685,9 +693,7 @@ func (osgb *OfflineSessionGroupBy) sqlQuery() *sql.Selector {
|
|||||||
for _, f := range osgb.fields {
|
for _, f := range osgb.fields {
|
||||||
columns = append(columns, selector.C(f))
|
columns = append(columns, selector.C(f))
|
||||||
}
|
}
|
||||||
for _, c := range aggregation {
|
columns = append(columns, aggregation...)
|
||||||
columns = append(columns, c)
|
|
||||||
}
|
|
||||||
selector.Select(columns...)
|
selector.Select(columns...)
|
||||||
}
|
}
|
||||||
return selector.GroupBy(selector.Columns(osgb.fields...)...)
|
return selector.GroupBy(selector.Columns(osgb.fields...)...)
|
||||||
|
@ -4,6 +4,7 @@ package db
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"entgo.io/ent/dialect/sql"
|
"entgo.io/ent/dialect/sql"
|
||||||
@ -125,12 +126,12 @@ func (osu *OfflineSessionUpdate) ExecX(ctx context.Context) {
|
|||||||
func (osu *OfflineSessionUpdate) check() error {
|
func (osu *OfflineSessionUpdate) check() error {
|
||||||
if v, ok := osu.mutation.UserID(); ok {
|
if v, ok := osu.mutation.UserID(); ok {
|
||||||
if err := offlinesession.UserIDValidator(v); err != nil {
|
if err := offlinesession.UserIDValidator(v); err != nil {
|
||||||
return &ValidationError{Name: "user_id", err: fmt.Errorf("db: validator failed for field \"user_id\": %w", err)}
|
return &ValidationError{Name: "user_id", err: fmt.Errorf(`db: validator failed for field "OfflineSession.user_id": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v, ok := osu.mutation.ConnID(); ok {
|
if v, ok := osu.mutation.ConnID(); ok {
|
||||||
if err := offlinesession.ConnIDValidator(v); err != nil {
|
if err := offlinesession.ConnIDValidator(v); err != nil {
|
||||||
return &ValidationError{Name: "conn_id", err: fmt.Errorf("db: validator failed for field \"conn_id\": %w", err)}
|
return &ValidationError{Name: "conn_id", err: fmt.Errorf(`db: validator failed for field "OfflineSession.conn_id": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -313,12 +314,12 @@ func (osuo *OfflineSessionUpdateOne) ExecX(ctx context.Context) {
|
|||||||
func (osuo *OfflineSessionUpdateOne) check() error {
|
func (osuo *OfflineSessionUpdateOne) check() error {
|
||||||
if v, ok := osuo.mutation.UserID(); ok {
|
if v, ok := osuo.mutation.UserID(); ok {
|
||||||
if err := offlinesession.UserIDValidator(v); err != nil {
|
if err := offlinesession.UserIDValidator(v); err != nil {
|
||||||
return &ValidationError{Name: "user_id", err: fmt.Errorf("db: validator failed for field \"user_id\": %w", err)}
|
return &ValidationError{Name: "user_id", err: fmt.Errorf(`db: validator failed for field "OfflineSession.user_id": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v, ok := osuo.mutation.ConnID(); ok {
|
if v, ok := osuo.mutation.ConnID(); ok {
|
||||||
if err := offlinesession.ConnIDValidator(v); err != nil {
|
if err := offlinesession.ConnIDValidator(v); err != nil {
|
||||||
return &ValidationError{Name: "conn_id", err: fmt.Errorf("db: validator failed for field \"conn_id\": %w", err)}
|
return &ValidationError{Name: "conn_id", err: fmt.Errorf(`db: validator failed for field "OfflineSession.conn_id": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -337,7 +338,7 @@ func (osuo *OfflineSessionUpdateOne) sqlSave(ctx context.Context) (_node *Offlin
|
|||||||
}
|
}
|
||||||
id, ok := osuo.mutation.ID()
|
id, ok := osuo.mutation.ID()
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing OfflineSession.ID for update")}
|
return nil, &ValidationError{Name: "id", err: errors.New(`db: missing "OfflineSession.id" for update`)}
|
||||||
}
|
}
|
||||||
_spec.Node.ID.Value = id
|
_spec.Node.ID.Value = id
|
||||||
if fields := osuo.fields; len(fields) > 0 {
|
if fields := osuo.fields; len(fields) > 0 {
|
||||||
|
@ -114,30 +114,30 @@ func (pc *PasswordCreate) ExecX(ctx context.Context) {
|
|||||||
// check runs all checks and user-defined validators on the builder.
|
// check runs all checks and user-defined validators on the builder.
|
||||||
func (pc *PasswordCreate) check() error {
|
func (pc *PasswordCreate) check() error {
|
||||||
if _, ok := pc.mutation.Email(); !ok {
|
if _, ok := pc.mutation.Email(); !ok {
|
||||||
return &ValidationError{Name: "email", err: errors.New(`db: missing required field "email"`)}
|
return &ValidationError{Name: "email", err: errors.New(`db: missing required field "Password.email"`)}
|
||||||
}
|
}
|
||||||
if v, ok := pc.mutation.Email(); ok {
|
if v, ok := pc.mutation.Email(); ok {
|
||||||
if err := password.EmailValidator(v); err != nil {
|
if err := password.EmailValidator(v); err != nil {
|
||||||
return &ValidationError{Name: "email", err: fmt.Errorf(`db: validator failed for field "email": %w`, err)}
|
return &ValidationError{Name: "email", err: fmt.Errorf(`db: validator failed for field "Password.email": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if _, ok := pc.mutation.Hash(); !ok {
|
if _, ok := pc.mutation.Hash(); !ok {
|
||||||
return &ValidationError{Name: "hash", err: errors.New(`db: missing required field "hash"`)}
|
return &ValidationError{Name: "hash", err: errors.New(`db: missing required field "Password.hash"`)}
|
||||||
}
|
}
|
||||||
if _, ok := pc.mutation.Username(); !ok {
|
if _, ok := pc.mutation.Username(); !ok {
|
||||||
return &ValidationError{Name: "username", err: errors.New(`db: missing required field "username"`)}
|
return &ValidationError{Name: "username", err: errors.New(`db: missing required field "Password.username"`)}
|
||||||
}
|
}
|
||||||
if v, ok := pc.mutation.Username(); ok {
|
if v, ok := pc.mutation.Username(); ok {
|
||||||
if err := password.UsernameValidator(v); err != nil {
|
if err := password.UsernameValidator(v); err != nil {
|
||||||
return &ValidationError{Name: "username", err: fmt.Errorf(`db: validator failed for field "username": %w`, err)}
|
return &ValidationError{Name: "username", err: fmt.Errorf(`db: validator failed for field "Password.username": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if _, ok := pc.mutation.UserID(); !ok {
|
if _, ok := pc.mutation.UserID(); !ok {
|
||||||
return &ValidationError{Name: "user_id", err: errors.New(`db: missing required field "user_id"`)}
|
return &ValidationError{Name: "user_id", err: errors.New(`db: missing required field "Password.user_id"`)}
|
||||||
}
|
}
|
||||||
if v, ok := pc.mutation.UserID(); ok {
|
if v, ok := pc.mutation.UserID(); ok {
|
||||||
if err := password.UserIDValidator(v); err != nil {
|
if err := password.UserIDValidator(v); err != nil {
|
||||||
return &ValidationError{Name: "user_id", err: fmt.Errorf(`db: validator failed for field "user_id": %w`, err)}
|
return &ValidationError{Name: "user_id", err: fmt.Errorf(`db: validator failed for field "Password.user_id": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -106,7 +106,7 @@ func (pq *PasswordQuery) FirstIDX(ctx context.Context) int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Only returns a single Password entity found by the query, ensuring it only returns one.
|
// Only returns a single Password entity found by the query, ensuring it only returns one.
|
||||||
// Returns a *NotSingularError when exactly one Password entity is not found.
|
// Returns a *NotSingularError when more than one Password entity is found.
|
||||||
// Returns a *NotFoundError when no Password entities are found.
|
// Returns a *NotFoundError when no Password entities are found.
|
||||||
func (pq *PasswordQuery) Only(ctx context.Context) (*Password, error) {
|
func (pq *PasswordQuery) Only(ctx context.Context) (*Password, error) {
|
||||||
nodes, err := pq.Limit(2).All(ctx)
|
nodes, err := pq.Limit(2).All(ctx)
|
||||||
@ -133,7 +133,7 @@ func (pq *PasswordQuery) OnlyX(ctx context.Context) *Password {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// OnlyID is like Only, but returns the only Password ID in the query.
|
// OnlyID is like Only, but returns the only Password ID in the query.
|
||||||
// Returns a *NotSingularError when exactly one Password ID is not found.
|
// Returns a *NotSingularError when more than one Password ID is found.
|
||||||
// Returns a *NotFoundError when no entities are found.
|
// Returns a *NotFoundError when no entities are found.
|
||||||
func (pq *PasswordQuery) OnlyID(ctx context.Context) (id int, err error) {
|
func (pq *PasswordQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||||
var ids []int
|
var ids []int
|
||||||
@ -242,8 +242,9 @@ func (pq *PasswordQuery) Clone() *PasswordQuery {
|
|||||||
order: append([]OrderFunc{}, pq.order...),
|
order: append([]OrderFunc{}, pq.order...),
|
||||||
predicates: append([]predicate.Password{}, pq.predicates...),
|
predicates: append([]predicate.Password{}, pq.predicates...),
|
||||||
// clone intermediate query.
|
// clone intermediate query.
|
||||||
sql: pq.sql.Clone(),
|
sql: pq.sql.Clone(),
|
||||||
path: pq.path,
|
path: pq.path,
|
||||||
|
unique: pq.unique,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,6 +337,10 @@ func (pq *PasswordQuery) sqlAll(ctx context.Context) ([]*Password, error) {
|
|||||||
|
|
||||||
func (pq *PasswordQuery) sqlCount(ctx context.Context) (int, error) {
|
func (pq *PasswordQuery) sqlCount(ctx context.Context) (int, error) {
|
||||||
_spec := pq.querySpec()
|
_spec := pq.querySpec()
|
||||||
|
_spec.Node.Columns = pq.fields
|
||||||
|
if len(pq.fields) > 0 {
|
||||||
|
_spec.Unique = pq.unique != nil && *pq.unique
|
||||||
|
}
|
||||||
return sqlgraph.CountNodes(ctx, pq.driver, _spec)
|
return sqlgraph.CountNodes(ctx, pq.driver, _spec)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -407,6 +412,9 @@ func (pq *PasswordQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
|||||||
selector = pq.sql
|
selector = pq.sql
|
||||||
selector.Select(selector.Columns(columns...)...)
|
selector.Select(selector.Columns(columns...)...)
|
||||||
}
|
}
|
||||||
|
if pq.unique != nil && *pq.unique {
|
||||||
|
selector.Distinct()
|
||||||
|
}
|
||||||
for _, p := range pq.predicates {
|
for _, p := range pq.predicates {
|
||||||
p(selector)
|
p(selector)
|
||||||
}
|
}
|
||||||
@ -685,9 +693,7 @@ func (pgb *PasswordGroupBy) sqlQuery() *sql.Selector {
|
|||||||
for _, f := range pgb.fields {
|
for _, f := range pgb.fields {
|
||||||
columns = append(columns, selector.C(f))
|
columns = append(columns, selector.C(f))
|
||||||
}
|
}
|
||||||
for _, c := range aggregation {
|
columns = append(columns, aggregation...)
|
||||||
columns = append(columns, c)
|
|
||||||
}
|
|
||||||
selector.Select(columns...)
|
selector.Select(columns...)
|
||||||
}
|
}
|
||||||
return selector.GroupBy(selector.Columns(pgb.fields...)...)
|
return selector.GroupBy(selector.Columns(pgb.fields...)...)
|
||||||
|
@ -4,6 +4,7 @@ package db
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"entgo.io/ent/dialect/sql"
|
"entgo.io/ent/dialect/sql"
|
||||||
@ -119,17 +120,17 @@ func (pu *PasswordUpdate) ExecX(ctx context.Context) {
|
|||||||
func (pu *PasswordUpdate) check() error {
|
func (pu *PasswordUpdate) check() error {
|
||||||
if v, ok := pu.mutation.Email(); ok {
|
if v, ok := pu.mutation.Email(); ok {
|
||||||
if err := password.EmailValidator(v); err != nil {
|
if err := password.EmailValidator(v); err != nil {
|
||||||
return &ValidationError{Name: "email", err: fmt.Errorf("db: validator failed for field \"email\": %w", err)}
|
return &ValidationError{Name: "email", err: fmt.Errorf(`db: validator failed for field "Password.email": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v, ok := pu.mutation.Username(); ok {
|
if v, ok := pu.mutation.Username(); ok {
|
||||||
if err := password.UsernameValidator(v); err != nil {
|
if err := password.UsernameValidator(v); err != nil {
|
||||||
return &ValidationError{Name: "username", err: fmt.Errorf("db: validator failed for field \"username\": %w", err)}
|
return &ValidationError{Name: "username", err: fmt.Errorf(`db: validator failed for field "Password.username": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v, ok := pu.mutation.UserID(); ok {
|
if v, ok := pu.mutation.UserID(); ok {
|
||||||
if err := password.UserIDValidator(v); err != nil {
|
if err := password.UserIDValidator(v); err != nil {
|
||||||
return &ValidationError{Name: "user_id", err: fmt.Errorf("db: validator failed for field \"user_id\": %w", err)}
|
return &ValidationError{Name: "user_id", err: fmt.Errorf(`db: validator failed for field "Password.user_id": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -300,17 +301,17 @@ func (puo *PasswordUpdateOne) ExecX(ctx context.Context) {
|
|||||||
func (puo *PasswordUpdateOne) check() error {
|
func (puo *PasswordUpdateOne) check() error {
|
||||||
if v, ok := puo.mutation.Email(); ok {
|
if v, ok := puo.mutation.Email(); ok {
|
||||||
if err := password.EmailValidator(v); err != nil {
|
if err := password.EmailValidator(v); err != nil {
|
||||||
return &ValidationError{Name: "email", err: fmt.Errorf("db: validator failed for field \"email\": %w", err)}
|
return &ValidationError{Name: "email", err: fmt.Errorf(`db: validator failed for field "Password.email": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v, ok := puo.mutation.Username(); ok {
|
if v, ok := puo.mutation.Username(); ok {
|
||||||
if err := password.UsernameValidator(v); err != nil {
|
if err := password.UsernameValidator(v); err != nil {
|
||||||
return &ValidationError{Name: "username", err: fmt.Errorf("db: validator failed for field \"username\": %w", err)}
|
return &ValidationError{Name: "username", err: fmt.Errorf(`db: validator failed for field "Password.username": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v, ok := puo.mutation.UserID(); ok {
|
if v, ok := puo.mutation.UserID(); ok {
|
||||||
if err := password.UserIDValidator(v); err != nil {
|
if err := password.UserIDValidator(v); err != nil {
|
||||||
return &ValidationError{Name: "user_id", err: fmt.Errorf("db: validator failed for field \"user_id\": %w", err)}
|
return &ValidationError{Name: "user_id", err: fmt.Errorf(`db: validator failed for field "Password.user_id": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -329,7 +330,7 @@ func (puo *PasswordUpdateOne) sqlSave(ctx context.Context) (_node *Password, err
|
|||||||
}
|
}
|
||||||
id, ok := puo.mutation.ID()
|
id, ok := puo.mutation.ID()
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing Password.ID for update")}
|
return nil, &ValidationError{Name: "id", err: errors.New(`db: missing "Password.id" for update`)}
|
||||||
}
|
}
|
||||||
_spec.Node.ID.Value = id
|
_spec.Node.ID.Value = id
|
||||||
if fields := puo.fields; len(fields) > 0 {
|
if fields := puo.fields; len(fields) > 0 {
|
||||||
|
@ -252,74 +252,74 @@ func (rtc *RefreshTokenCreate) defaults() {
|
|||||||
// check runs all checks and user-defined validators on the builder.
|
// check runs all checks and user-defined validators on the builder.
|
||||||
func (rtc *RefreshTokenCreate) check() error {
|
func (rtc *RefreshTokenCreate) check() error {
|
||||||
if _, ok := rtc.mutation.ClientID(); !ok {
|
if _, ok := rtc.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 "RefreshToken.client_id"`)}
|
||||||
}
|
}
|
||||||
if v, ok := rtc.mutation.ClientID(); ok {
|
if v, ok := rtc.mutation.ClientID(); ok {
|
||||||
if err := refreshtoken.ClientIDValidator(v); err != nil {
|
if err := refreshtoken.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 "RefreshToken.client_id": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if _, ok := rtc.mutation.Nonce(); !ok {
|
if _, ok := rtc.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 "RefreshToken.nonce"`)}
|
||||||
}
|
}
|
||||||
if v, ok := rtc.mutation.Nonce(); ok {
|
if v, ok := rtc.mutation.Nonce(); ok {
|
||||||
if err := refreshtoken.NonceValidator(v); err != nil {
|
if err := refreshtoken.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 "RefreshToken.nonce": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if _, ok := rtc.mutation.ClaimsUserID(); !ok {
|
if _, ok := rtc.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 "RefreshToken.claims_user_id"`)}
|
||||||
}
|
}
|
||||||
if v, ok := rtc.mutation.ClaimsUserID(); ok {
|
if v, ok := rtc.mutation.ClaimsUserID(); ok {
|
||||||
if err := refreshtoken.ClaimsUserIDValidator(v); err != nil {
|
if err := refreshtoken.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 "RefreshToken.claims_user_id": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if _, ok := rtc.mutation.ClaimsUsername(); !ok {
|
if _, ok := rtc.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 "RefreshToken.claims_username"`)}
|
||||||
}
|
}
|
||||||
if v, ok := rtc.mutation.ClaimsUsername(); ok {
|
if v, ok := rtc.mutation.ClaimsUsername(); ok {
|
||||||
if err := refreshtoken.ClaimsUsernameValidator(v); err != nil {
|
if err := refreshtoken.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 "RefreshToken.claims_username": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if _, ok := rtc.mutation.ClaimsEmail(); !ok {
|
if _, ok := rtc.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 "RefreshToken.claims_email"`)}
|
||||||
}
|
}
|
||||||
if v, ok := rtc.mutation.ClaimsEmail(); ok {
|
if v, ok := rtc.mutation.ClaimsEmail(); ok {
|
||||||
if err := refreshtoken.ClaimsEmailValidator(v); err != nil {
|
if err := refreshtoken.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 "RefreshToken.claims_email": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if _, ok := rtc.mutation.ClaimsEmailVerified(); !ok {
|
if _, ok := rtc.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 "RefreshToken.claims_email_verified"`)}
|
||||||
}
|
}
|
||||||
if _, ok := rtc.mutation.ClaimsPreferredUsername(); !ok {
|
if _, ok := rtc.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 "RefreshToken.claims_preferred_username"`)}
|
||||||
}
|
}
|
||||||
if _, ok := rtc.mutation.ConnectorID(); !ok {
|
if _, ok := rtc.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 "RefreshToken.connector_id"`)}
|
||||||
}
|
}
|
||||||
if v, ok := rtc.mutation.ConnectorID(); ok {
|
if v, ok := rtc.mutation.ConnectorID(); ok {
|
||||||
if err := refreshtoken.ConnectorIDValidator(v); err != nil {
|
if err := refreshtoken.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 "RefreshToken.connector_id": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if _, ok := rtc.mutation.Token(); !ok {
|
if _, ok := rtc.mutation.Token(); !ok {
|
||||||
return &ValidationError{Name: "token", err: errors.New(`db: missing required field "token"`)}
|
return &ValidationError{Name: "token", err: errors.New(`db: missing required field "RefreshToken.token"`)}
|
||||||
}
|
}
|
||||||
if _, ok := rtc.mutation.ObsoleteToken(); !ok {
|
if _, ok := rtc.mutation.ObsoleteToken(); !ok {
|
||||||
return &ValidationError{Name: "obsolete_token", err: errors.New(`db: missing required field "obsolete_token"`)}
|
return &ValidationError{Name: "obsolete_token", err: errors.New(`db: missing required field "RefreshToken.obsolete_token"`)}
|
||||||
}
|
}
|
||||||
if _, ok := rtc.mutation.CreatedAt(); !ok {
|
if _, ok := rtc.mutation.CreatedAt(); !ok {
|
||||||
return &ValidationError{Name: "created_at", err: errors.New(`db: missing required field "created_at"`)}
|
return &ValidationError{Name: "created_at", err: errors.New(`db: missing required field "RefreshToken.created_at"`)}
|
||||||
}
|
}
|
||||||
if _, ok := rtc.mutation.LastUsed(); !ok {
|
if _, ok := rtc.mutation.LastUsed(); !ok {
|
||||||
return &ValidationError{Name: "last_used", err: errors.New(`db: missing required field "last_used"`)}
|
return &ValidationError{Name: "last_used", err: errors.New(`db: missing required field "RefreshToken.last_used"`)}
|
||||||
}
|
}
|
||||||
if v, ok := rtc.mutation.ID(); ok {
|
if v, ok := rtc.mutation.ID(); ok {
|
||||||
if err := refreshtoken.IDValidator(v); err != nil {
|
if err := refreshtoken.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 "RefreshToken.id": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -333,6 +333,13 @@ func (rtc *RefreshTokenCreate) sqlSave(ctx context.Context) (*RefreshToken, erro
|
|||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if _spec.ID.Value != nil {
|
||||||
|
if id, ok := _spec.ID.Value.(string); ok {
|
||||||
|
_node.ID = id
|
||||||
|
} else {
|
||||||
|
return nil, fmt.Errorf("unexpected RefreshToken.ID type: %T", _spec.ID.Value)
|
||||||
|
}
|
||||||
|
}
|
||||||
return _node, nil
|
return _node, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ func (rtq *RefreshTokenQuery) FirstIDX(ctx context.Context) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Only returns a single RefreshToken entity found by the query, ensuring it only returns one.
|
// Only returns a single RefreshToken entity found by the query, ensuring it only returns one.
|
||||||
// Returns a *NotSingularError when exactly one RefreshToken entity is not found.
|
// Returns a *NotSingularError when more than one RefreshToken entity is found.
|
||||||
// Returns a *NotFoundError when no RefreshToken entities are found.
|
// Returns a *NotFoundError when no RefreshToken entities are found.
|
||||||
func (rtq *RefreshTokenQuery) Only(ctx context.Context) (*RefreshToken, error) {
|
func (rtq *RefreshTokenQuery) Only(ctx context.Context) (*RefreshToken, error) {
|
||||||
nodes, err := rtq.Limit(2).All(ctx)
|
nodes, err := rtq.Limit(2).All(ctx)
|
||||||
@ -133,7 +133,7 @@ func (rtq *RefreshTokenQuery) OnlyX(ctx context.Context) *RefreshToken {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// OnlyID is like Only, but returns the only RefreshToken ID in the query.
|
// OnlyID is like Only, but returns the only RefreshToken ID in the query.
|
||||||
// Returns a *NotSingularError when exactly one RefreshToken ID is not found.
|
// Returns a *NotSingularError when more than one RefreshToken ID is found.
|
||||||
// Returns a *NotFoundError when no entities are found.
|
// Returns a *NotFoundError when no entities are found.
|
||||||
func (rtq *RefreshTokenQuery) OnlyID(ctx context.Context) (id string, err error) {
|
func (rtq *RefreshTokenQuery) OnlyID(ctx context.Context) (id string, err error) {
|
||||||
var ids []string
|
var ids []string
|
||||||
@ -242,8 +242,9 @@ func (rtq *RefreshTokenQuery) Clone() *RefreshTokenQuery {
|
|||||||
order: append([]OrderFunc{}, rtq.order...),
|
order: append([]OrderFunc{}, rtq.order...),
|
||||||
predicates: append([]predicate.RefreshToken{}, rtq.predicates...),
|
predicates: append([]predicate.RefreshToken{}, rtq.predicates...),
|
||||||
// clone intermediate query.
|
// clone intermediate query.
|
||||||
sql: rtq.sql.Clone(),
|
sql: rtq.sql.Clone(),
|
||||||
path: rtq.path,
|
path: rtq.path,
|
||||||
|
unique: rtq.unique,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,6 +337,10 @@ func (rtq *RefreshTokenQuery) sqlAll(ctx context.Context) ([]*RefreshToken, erro
|
|||||||
|
|
||||||
func (rtq *RefreshTokenQuery) sqlCount(ctx context.Context) (int, error) {
|
func (rtq *RefreshTokenQuery) sqlCount(ctx context.Context) (int, error) {
|
||||||
_spec := rtq.querySpec()
|
_spec := rtq.querySpec()
|
||||||
|
_spec.Node.Columns = rtq.fields
|
||||||
|
if len(rtq.fields) > 0 {
|
||||||
|
_spec.Unique = rtq.unique != nil && *rtq.unique
|
||||||
|
}
|
||||||
return sqlgraph.CountNodes(ctx, rtq.driver, _spec)
|
return sqlgraph.CountNodes(ctx, rtq.driver, _spec)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -407,6 +412,9 @@ func (rtq *RefreshTokenQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
|||||||
selector = rtq.sql
|
selector = rtq.sql
|
||||||
selector.Select(selector.Columns(columns...)...)
|
selector.Select(selector.Columns(columns...)...)
|
||||||
}
|
}
|
||||||
|
if rtq.unique != nil && *rtq.unique {
|
||||||
|
selector.Distinct()
|
||||||
|
}
|
||||||
for _, p := range rtq.predicates {
|
for _, p := range rtq.predicates {
|
||||||
p(selector)
|
p(selector)
|
||||||
}
|
}
|
||||||
@ -685,9 +693,7 @@ func (rtgb *RefreshTokenGroupBy) sqlQuery() *sql.Selector {
|
|||||||
for _, f := range rtgb.fields {
|
for _, f := range rtgb.fields {
|
||||||
columns = append(columns, selector.C(f))
|
columns = append(columns, selector.C(f))
|
||||||
}
|
}
|
||||||
for _, c := range aggregation {
|
columns = append(columns, aggregation...)
|
||||||
columns = append(columns, c)
|
|
||||||
}
|
|
||||||
selector.Select(columns...)
|
selector.Select(columns...)
|
||||||
}
|
}
|
||||||
return selector.GroupBy(selector.Columns(rtgb.fields...)...)
|
return selector.GroupBy(selector.Columns(rtgb.fields...)...)
|
||||||
|
@ -4,6 +4,7 @@ package db
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -244,32 +245,32 @@ func (rtu *RefreshTokenUpdate) ExecX(ctx context.Context) {
|
|||||||
func (rtu *RefreshTokenUpdate) check() error {
|
func (rtu *RefreshTokenUpdate) check() error {
|
||||||
if v, ok := rtu.mutation.ClientID(); ok {
|
if v, ok := rtu.mutation.ClientID(); ok {
|
||||||
if err := refreshtoken.ClientIDValidator(v); err != nil {
|
if err := refreshtoken.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 "RefreshToken.client_id": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v, ok := rtu.mutation.Nonce(); ok {
|
if v, ok := rtu.mutation.Nonce(); ok {
|
||||||
if err := refreshtoken.NonceValidator(v); err != nil {
|
if err := refreshtoken.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 "RefreshToken.nonce": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v, ok := rtu.mutation.ClaimsUserID(); ok {
|
if v, ok := rtu.mutation.ClaimsUserID(); ok {
|
||||||
if err := refreshtoken.ClaimsUserIDValidator(v); err != nil {
|
if err := refreshtoken.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 "RefreshToken.claims_user_id": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v, ok := rtu.mutation.ClaimsUsername(); ok {
|
if v, ok := rtu.mutation.ClaimsUsername(); ok {
|
||||||
if err := refreshtoken.ClaimsUsernameValidator(v); err != nil {
|
if err := refreshtoken.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 "RefreshToken.claims_username": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v, ok := rtu.mutation.ClaimsEmail(); ok {
|
if v, ok := rtu.mutation.ClaimsEmail(); ok {
|
||||||
if err := refreshtoken.ClaimsEmailValidator(v); err != nil {
|
if err := refreshtoken.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 "RefreshToken.claims_email": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v, ok := rtu.mutation.ConnectorID(); ok {
|
if v, ok := rtu.mutation.ConnectorID(); ok {
|
||||||
if err := refreshtoken.ConnectorIDValidator(v); err != nil {
|
if err := refreshtoken.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 "RefreshToken.connector_id": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -659,32 +660,32 @@ func (rtuo *RefreshTokenUpdateOne) ExecX(ctx context.Context) {
|
|||||||
func (rtuo *RefreshTokenUpdateOne) check() error {
|
func (rtuo *RefreshTokenUpdateOne) check() error {
|
||||||
if v, ok := rtuo.mutation.ClientID(); ok {
|
if v, ok := rtuo.mutation.ClientID(); ok {
|
||||||
if err := refreshtoken.ClientIDValidator(v); err != nil {
|
if err := refreshtoken.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 "RefreshToken.client_id": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v, ok := rtuo.mutation.Nonce(); ok {
|
if v, ok := rtuo.mutation.Nonce(); ok {
|
||||||
if err := refreshtoken.NonceValidator(v); err != nil {
|
if err := refreshtoken.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 "RefreshToken.nonce": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v, ok := rtuo.mutation.ClaimsUserID(); ok {
|
if v, ok := rtuo.mutation.ClaimsUserID(); ok {
|
||||||
if err := refreshtoken.ClaimsUserIDValidator(v); err != nil {
|
if err := refreshtoken.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 "RefreshToken.claims_user_id": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v, ok := rtuo.mutation.ClaimsUsername(); ok {
|
if v, ok := rtuo.mutation.ClaimsUsername(); ok {
|
||||||
if err := refreshtoken.ClaimsUsernameValidator(v); err != nil {
|
if err := refreshtoken.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 "RefreshToken.claims_username": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v, ok := rtuo.mutation.ClaimsEmail(); ok {
|
if v, ok := rtuo.mutation.ClaimsEmail(); ok {
|
||||||
if err := refreshtoken.ClaimsEmailValidator(v); err != nil {
|
if err := refreshtoken.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 "RefreshToken.claims_email": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v, ok := rtuo.mutation.ConnectorID(); ok {
|
if v, ok := rtuo.mutation.ConnectorID(); ok {
|
||||||
if err := refreshtoken.ConnectorIDValidator(v); err != nil {
|
if err := refreshtoken.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 "RefreshToken.connector_id": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -703,7 +704,7 @@ func (rtuo *RefreshTokenUpdateOne) sqlSave(ctx context.Context) (_node *RefreshT
|
|||||||
}
|
}
|
||||||
id, ok := rtuo.mutation.ID()
|
id, ok := rtuo.mutation.ID()
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing RefreshToken.ID for update")}
|
return nil, &ValidationError{Name: "id", err: errors.New(`db: missing "RefreshToken.id" for update`)}
|
||||||
}
|
}
|
||||||
_spec.Node.ID.Value = id
|
_spec.Node.ID.Value = id
|
||||||
if fields := rtuo.fields; len(fields) > 0 {
|
if fields := rtuo.fields; len(fields) > 0 {
|
||||||
|
@ -5,6 +5,6 @@ package runtime
|
|||||||
// The schema-stitching logic is generated in github.com/dexidp/dex/storage/ent/db/runtime.go
|
// The schema-stitching logic is generated in github.com/dexidp/dex/storage/ent/db/runtime.go
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Version = "v0.9.0" // Version of ent codegen.
|
Version = "v0.10.1" // Version of ent codegen.
|
||||||
Sum = "h1:2S1zfpMMW6p+wctj6kcYUprNPNjLWFW06T5MdyAfmWc=" // Sum of ent codegen.
|
Sum = "h1:dM5h4Zk6yHGIgw4dCqVzGw3nWgpGYJiV4/kyHEF6PFo=" // Sum of ent codegen.
|
||||||
)
|
)
|
||||||
|
@ -48,7 +48,7 @@ type Tx struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type (
|
type (
|
||||||
// Committer is the interface that wraps the Committer method.
|
// Committer is the interface that wraps the Commit method.
|
||||||
Committer interface {
|
Committer interface {
|
||||||
Commit(context.Context, *Tx) error
|
Commit(context.Context, *Tx) error
|
||||||
}
|
}
|
||||||
@ -62,7 +62,7 @@ type (
|
|||||||
// and returns a Committer. For example:
|
// and returns a Committer. For example:
|
||||||
//
|
//
|
||||||
// hook := func(next ent.Committer) ent.Committer {
|
// hook := func(next ent.Committer) ent.Committer {
|
||||||
// return ent.CommitFunc(func(context.Context, tx *ent.Tx) error {
|
// return ent.CommitFunc(func(ctx context.Context, tx *ent.Tx) error {
|
||||||
// // Do some stuff before.
|
// // Do some stuff before.
|
||||||
// if err := next.Commit(ctx, tx); err != nil {
|
// if err := next.Commit(ctx, tx); err != nil {
|
||||||
// return err
|
// return err
|
||||||
@ -103,7 +103,7 @@ func (tx *Tx) OnCommit(f CommitHook) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type (
|
type (
|
||||||
// Rollbacker is the interface that wraps the Rollbacker method.
|
// Rollbacker is the interface that wraps the Rollback method.
|
||||||
Rollbacker interface {
|
Rollbacker interface {
|
||||||
Rollback(context.Context, *Tx) error
|
Rollback(context.Context, *Tx) error
|
||||||
}
|
}
|
||||||
@ -117,7 +117,7 @@ type (
|
|||||||
// and returns a Rollbacker. For example:
|
// and returns a Rollbacker. For example:
|
||||||
//
|
//
|
||||||
// hook := func(next ent.Rollbacker) ent.Rollbacker {
|
// hook := func(next ent.Rollbacker) ent.Rollbacker {
|
||||||
// return ent.RollbackFunc(func(context.Context, tx *ent.Tx) error {
|
// return ent.RollbackFunc(func(ctx context.Context, tx *ent.Tx) error {
|
||||||
// // Do some stuff before.
|
// // Do some stuff before.
|
||||||
// if err := next.Rollback(ctx, tx); err != nil {
|
// if err := next.Rollback(ctx, tx); err != nil {
|
||||||
// return err
|
// return err
|
||||||
|
Reference in New Issue
Block a user