chore: update ent

Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com>
This commit is contained in:
m.nabokikh 2021-03-24 10:37:51 +04:00
parent 2e61860d5a
commit 24fa4def5b
94 changed files with 311 additions and 261 deletions

2
go.mod
View file

@ -3,11 +3,11 @@ module github.com/dexidp/dex
go 1.16 go 1.16
require ( require (
entgo.io/ent v0.7.0
github.com/AppsFlyer/go-sundheit v0.3.1 github.com/AppsFlyer/go-sundheit v0.3.1
github.com/beevik/etree v1.1.0 github.com/beevik/etree v1.1.0
github.com/coreos/go-oidc/v3 v3.0.0 github.com/coreos/go-oidc/v3 v3.0.0
github.com/dexidp/dex/api/v2 v2.0.0 github.com/dexidp/dex/api/v2 v2.0.0
github.com/facebook/ent v0.5.4
github.com/felixge/httpsnoop v1.0.1 github.com/felixge/httpsnoop v1.0.1
github.com/ghodss/yaml v1.0.0 github.com/ghodss/yaml v1.0.0
github.com/go-ldap/ldap/v3 v3.3.0 github.com/go-ldap/ldap/v3 v3.3.0

View file

@ -8,8 +8,8 @@ import (
"strings" "strings"
"time" "time"
"entgo.io/ent/dialect/sql"
"github.com/dexidp/dex/storage/ent/db/authcode" "github.com/dexidp/dex/storage/ent/db/authcode"
"github.com/facebook/ent/dialect/sql"
) )
// AuthCode is the model entity for the AuthCode schema. // AuthCode is the model entity for the AuthCode schema.
@ -95,7 +95,7 @@ func (ac *AuthCode) assignValues(columns []string, values []interface{}) error {
return fmt.Errorf("unexpected type %T for field scopes", values[i]) return fmt.Errorf("unexpected type %T for field scopes", values[i])
} else if value != nil && len(*value) > 0 { } else if value != nil && len(*value) > 0 {
if err := json.Unmarshal(*value, &ac.Scopes); err != nil { if err := json.Unmarshal(*value, &ac.Scopes); err != nil {
return fmt.Errorf("unmarshal field scopes: %v", err) return fmt.Errorf("unmarshal field scopes: %w", err)
} }
} }
case authcode.FieldNonce: case authcode.FieldNonce:
@ -140,7 +140,7 @@ func (ac *AuthCode) assignValues(columns []string, values []interface{}) error {
return fmt.Errorf("unexpected type %T for field claims_groups", values[i]) return fmt.Errorf("unexpected type %T for field claims_groups", values[i])
} else if value != nil && len(*value) > 0 { } else if value != nil && len(*value) > 0 {
if err := json.Unmarshal(*value, &ac.ClaimsGroups); err != nil { if err := json.Unmarshal(*value, &ac.ClaimsGroups); err != nil {
return fmt.Errorf("unmarshal field claims_groups: %v", err) return fmt.Errorf("unmarshal field claims_groups: %w", err)
} }
} }
case authcode.FieldClaimsPreferredUsername: case authcode.FieldClaimsPreferredUsername:

View file

@ -37,7 +37,6 @@ const (
FieldCodeChallenge = "code_challenge" FieldCodeChallenge = "code_challenge"
// FieldCodeChallengeMethod holds the string denoting the code_challenge_method field in the database. // FieldCodeChallengeMethod holds the string denoting the code_challenge_method field in the database.
FieldCodeChallengeMethod = "code_challenge_method" FieldCodeChallengeMethod = "code_challenge_method"
// Table holds the table name of the authcode in the database. // Table holds the table name of the authcode in the database.
Table = "auth_codes" Table = "auth_codes"
) )

View file

@ -5,8 +5,8 @@ package authcode
import ( import (
"time" "time"
"entgo.io/ent/dialect/sql"
"github.com/dexidp/dex/storage/ent/db/predicate" "github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/facebook/ent/dialect/sql"
) )
// ID filters vertices based on their ID field. // ID filters vertices based on their ID field.

View file

@ -8,9 +8,9 @@ import (
"fmt" "fmt"
"time" "time"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/dexidp/dex/storage/ent/db/authcode" "github.com/dexidp/dex/storage/ent/db/authcode"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
) )
// AuthCodeCreate is the builder for creating a AuthCode entity. // AuthCodeCreate is the builder for creating a AuthCode entity.

View file

@ -6,11 +6,11 @@ import (
"context" "context"
"fmt" "fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/dexidp/dex/storage/ent/db/authcode" "github.com/dexidp/dex/storage/ent/db/authcode"
"github.com/dexidp/dex/storage/ent/db/predicate" "github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
) )
// AuthCodeDelete is the builder for deleting a AuthCode entity. // AuthCodeDelete is the builder for deleting a AuthCode entity.

View file

@ -8,11 +8,11 @@ import (
"fmt" "fmt"
"math" "math"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/dexidp/dex/storage/ent/db/authcode" "github.com/dexidp/dex/storage/ent/db/authcode"
"github.com/dexidp/dex/storage/ent/db/predicate" "github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
) )
// AuthCodeQuery is the builder for querying AuthCode entities. // AuthCodeQuery is the builder for querying AuthCode entities.
@ -261,7 +261,7 @@ func (acq *AuthCodeQuery) GroupBy(field string, fields ...string) *AuthCodeGroup
if err := acq.prepareQuery(ctx); err != nil { if err := acq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
} }
return acq.sqlQuery(), nil return acq.sqlQuery(ctx), nil
} }
return group return group
} }
@ -334,7 +334,7 @@ func (acq *AuthCodeQuery) sqlCount(ctx context.Context) (int, error) {
func (acq *AuthCodeQuery) sqlExist(ctx context.Context) (bool, error) { func (acq *AuthCodeQuery) sqlExist(ctx context.Context) (bool, error) {
n, err := acq.sqlCount(ctx) n, err := acq.sqlCount(ctx)
if err != nil { if err != nil {
return false, fmt.Errorf("db: check existence: %v", err) return false, fmt.Errorf("db: check existence: %w", err)
} }
return n > 0, nil return n > 0, nil
} }
@ -384,7 +384,7 @@ func (acq *AuthCodeQuery) querySpec() *sqlgraph.QuerySpec {
return _spec return _spec
} }
func (acq *AuthCodeQuery) sqlQuery() *sql.Selector { func (acq *AuthCodeQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(acq.driver.Dialect()) builder := sql.Dialect(acq.driver.Dialect())
t1 := builder.Table(authcode.Table) t1 := builder.Table(authcode.Table)
selector := builder.Select(t1.Columns(authcode.Columns...)...).From(t1) selector := builder.Select(t1.Columns(authcode.Columns...)...).From(t1)
@ -679,7 +679,7 @@ func (acs *AuthCodeSelect) Scan(ctx context.Context, v interface{}) error {
if err := acs.prepareQuery(ctx); err != nil { if err := acs.prepareQuery(ctx); err != nil {
return err return err
} }
acs.sql = acs.AuthCodeQuery.sqlQuery() acs.sql = acs.AuthCodeQuery.sqlQuery(ctx)
return acs.sqlScan(ctx, v) return acs.sqlScan(ctx, v)
} }

View file

@ -7,11 +7,11 @@ import (
"fmt" "fmt"
"time" "time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/dexidp/dex/storage/ent/db/authcode" "github.com/dexidp/dex/storage/ent/db/authcode"
"github.com/dexidp/dex/storage/ent/db/predicate" "github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
) )
// AuthCodeUpdate is the builder for updating AuthCode entities. // AuthCodeUpdate is the builder for updating AuthCode entities.
@ -670,6 +670,13 @@ func (acuo *AuthCodeUpdateOne) sqlSave(ctx context.Context) (_node *AuthCode, er
return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing AuthCode.ID for update")} return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing AuthCode.ID for update")}
} }
_spec.Node.ID.Value = id _spec.Node.ID.Value = id
if ps := acuo.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := acuo.mutation.ClientID(); ok { if value, ok := acuo.mutation.ClientID(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeString, Type: field.TypeString,

View file

@ -8,8 +8,8 @@ import (
"strings" "strings"
"time" "time"
"entgo.io/ent/dialect/sql"
"github.com/dexidp/dex/storage/ent/db/authrequest" "github.com/dexidp/dex/storage/ent/db/authrequest"
"github.com/facebook/ent/dialect/sql"
) )
// AuthRequest is the model entity for the AuthRequest schema. // AuthRequest is the model entity for the AuthRequest schema.
@ -103,7 +103,7 @@ func (ar *AuthRequest) assignValues(columns []string, values []interface{}) erro
return fmt.Errorf("unexpected type %T for field scopes", values[i]) return fmt.Errorf("unexpected type %T for field scopes", values[i])
} else if value != nil && len(*value) > 0 { } else if value != nil && len(*value) > 0 {
if err := json.Unmarshal(*value, &ar.Scopes); err != nil { if err := json.Unmarshal(*value, &ar.Scopes); err != nil {
return fmt.Errorf("unmarshal field scopes: %v", err) return fmt.Errorf("unmarshal field scopes: %w", err)
} }
} }
case authrequest.FieldResponseTypes: case authrequest.FieldResponseTypes:
@ -112,7 +112,7 @@ func (ar *AuthRequest) assignValues(columns []string, values []interface{}) erro
return fmt.Errorf("unexpected type %T for field response_types", values[i]) return fmt.Errorf("unexpected type %T for field response_types", values[i])
} else if value != nil && len(*value) > 0 { } else if value != nil && len(*value) > 0 {
if err := json.Unmarshal(*value, &ar.ResponseTypes); err != nil { if err := json.Unmarshal(*value, &ar.ResponseTypes); err != nil {
return fmt.Errorf("unmarshal field response_types: %v", err) return fmt.Errorf("unmarshal field response_types: %w", err)
} }
} }
case authrequest.FieldRedirectURI: case authrequest.FieldRedirectURI:
@ -175,7 +175,7 @@ func (ar *AuthRequest) assignValues(columns []string, values []interface{}) erro
return fmt.Errorf("unexpected type %T for field claims_groups", values[i]) return fmt.Errorf("unexpected type %T for field claims_groups", values[i])
} else if value != nil && len(*value) > 0 { } else if value != nil && len(*value) > 0 {
if err := json.Unmarshal(*value, &ar.ClaimsGroups); err != nil { if err := json.Unmarshal(*value, &ar.ClaimsGroups); err != nil {
return fmt.Errorf("unmarshal field claims_groups: %v", err) return fmt.Errorf("unmarshal field claims_groups: %w", err)
} }
} }
case authrequest.FieldClaimsPreferredUsername: case authrequest.FieldClaimsPreferredUsername:

View file

@ -45,7 +45,6 @@ const (
FieldCodeChallenge = "code_challenge" FieldCodeChallenge = "code_challenge"
// FieldCodeChallengeMethod holds the string denoting the code_challenge_method field in the database. // FieldCodeChallengeMethod holds the string denoting the code_challenge_method field in the database.
FieldCodeChallengeMethod = "code_challenge_method" FieldCodeChallengeMethod = "code_challenge_method"
// Table holds the table name of the authrequest in the database. // Table holds the table name of the authrequest in the database.
Table = "auth_requests" Table = "auth_requests"
) )

View file

@ -5,8 +5,8 @@ package authrequest
import ( import (
"time" "time"
"entgo.io/ent/dialect/sql"
"github.com/dexidp/dex/storage/ent/db/predicate" "github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/facebook/ent/dialect/sql"
) )
// ID filters vertices based on their ID field. // ID filters vertices based on their ID field.

View file

@ -8,9 +8,9 @@ import (
"fmt" "fmt"
"time" "time"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/dexidp/dex/storage/ent/db/authrequest" "github.com/dexidp/dex/storage/ent/db/authrequest"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
) )
// AuthRequestCreate is the builder for creating a AuthRequest entity. // AuthRequestCreate is the builder for creating a AuthRequest entity.

View file

@ -6,11 +6,11 @@ import (
"context" "context"
"fmt" "fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/dexidp/dex/storage/ent/db/authrequest" "github.com/dexidp/dex/storage/ent/db/authrequest"
"github.com/dexidp/dex/storage/ent/db/predicate" "github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
) )
// AuthRequestDelete is the builder for deleting a AuthRequest entity. // AuthRequestDelete is the builder for deleting a AuthRequest entity.

View file

@ -8,11 +8,11 @@ import (
"fmt" "fmt"
"math" "math"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/dexidp/dex/storage/ent/db/authrequest" "github.com/dexidp/dex/storage/ent/db/authrequest"
"github.com/dexidp/dex/storage/ent/db/predicate" "github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
) )
// AuthRequestQuery is the builder for querying AuthRequest entities. // AuthRequestQuery is the builder for querying AuthRequest entities.
@ -261,7 +261,7 @@ func (arq *AuthRequestQuery) GroupBy(field string, fields ...string) *AuthReques
if err := arq.prepareQuery(ctx); err != nil { if err := arq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
} }
return arq.sqlQuery(), nil return arq.sqlQuery(ctx), nil
} }
return group return group
} }
@ -334,7 +334,7 @@ func (arq *AuthRequestQuery) sqlCount(ctx context.Context) (int, error) {
func (arq *AuthRequestQuery) sqlExist(ctx context.Context) (bool, error) { func (arq *AuthRequestQuery) sqlExist(ctx context.Context) (bool, error) {
n, err := arq.sqlCount(ctx) n, err := arq.sqlCount(ctx)
if err != nil { if err != nil {
return false, fmt.Errorf("db: check existence: %v", err) return false, fmt.Errorf("db: check existence: %w", err)
} }
return n > 0, nil return n > 0, nil
} }
@ -384,7 +384,7 @@ func (arq *AuthRequestQuery) querySpec() *sqlgraph.QuerySpec {
return _spec return _spec
} }
func (arq *AuthRequestQuery) sqlQuery() *sql.Selector { func (arq *AuthRequestQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(arq.driver.Dialect()) builder := sql.Dialect(arq.driver.Dialect())
t1 := builder.Table(authrequest.Table) t1 := builder.Table(authrequest.Table)
selector := builder.Select(t1.Columns(authrequest.Columns...)...).From(t1) selector := builder.Select(t1.Columns(authrequest.Columns...)...).From(t1)
@ -679,7 +679,7 @@ func (ars *AuthRequestSelect) Scan(ctx context.Context, v interface{}) error {
if err := ars.prepareQuery(ctx); err != nil { if err := ars.prepareQuery(ctx); err != nil {
return err return err
} }
ars.sql = ars.AuthRequestQuery.sqlQuery() ars.sql = ars.AuthRequestQuery.sqlQuery(ctx)
return ars.sqlScan(ctx, v) return ars.sqlScan(ctx, v)
} }

View file

@ -7,11 +7,11 @@ import (
"fmt" "fmt"
"time" "time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/dexidp/dex/storage/ent/db/authrequest" "github.com/dexidp/dex/storage/ent/db/authrequest"
"github.com/dexidp/dex/storage/ent/db/predicate" "github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
) )
// AuthRequestUpdate is the builder for updating AuthRequest entities. // AuthRequestUpdate is the builder for updating AuthRequest entities.
@ -672,6 +672,13 @@ func (aruo *AuthRequestUpdateOne) sqlSave(ctx context.Context) (_node *AuthReque
return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing AuthRequest.ID for update")} return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing AuthRequest.ID for update")}
} }
_spec.Node.ID.Value = id _spec.Node.ID.Value = id
if ps := aruo.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := aruo.mutation.ClientID(); ok { if value, ok := aruo.mutation.ClientID(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeString, Type: field.TypeString,

View file

@ -20,8 +20,8 @@ import (
"github.com/dexidp/dex/storage/ent/db/password" "github.com/dexidp/dex/storage/ent/db/password"
"github.com/dexidp/dex/storage/ent/db/refreshtoken" "github.com/dexidp/dex/storage/ent/db/refreshtoken"
"github.com/facebook/ent/dialect" "entgo.io/ent/dialect"
"github.com/facebook/ent/dialect/sql" "entgo.io/ent/dialect/sql"
) )
// Client is the client that holds all ent builders. // Client is the client that holds all ent builders.
@ -98,9 +98,10 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) {
} }
tx, err := newTx(ctx, c.driver) tx, err := newTx(ctx, c.driver)
if err != nil { if err != nil {
return nil, fmt.Errorf("db: starting a transaction: %v", err) return nil, fmt.Errorf("db: starting a transaction: %w", err)
} }
cfg := config{driver: tx, log: c.log, debug: c.debug, hooks: c.hooks} cfg := c.config
cfg.driver = tx
return &Tx{ return &Tx{
ctx: ctx, ctx: ctx,
config: cfg, config: cfg,
@ -122,11 +123,14 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
if _, ok := c.driver.(*txDriver); ok { if _, ok := c.driver.(*txDriver); ok {
return nil, fmt.Errorf("ent: cannot start a transaction within a transaction") return nil, fmt.Errorf("ent: cannot start a transaction within a transaction")
} }
tx, err := c.driver.(*sql.Driver).BeginTx(ctx, opts) tx, err := c.driver.(interface {
BeginTx(context.Context, *sql.TxOptions) (dialect.Tx, error)
}).BeginTx(ctx, opts)
if err != nil { if err != nil {
return nil, fmt.Errorf("ent: starting a transaction: %v", err) return nil, fmt.Errorf("ent: starting a transaction: %w", err)
} }
cfg := config{driver: &txDriver{tx: tx, drv: c.driver}, log: c.log, debug: c.debug, hooks: c.hooks} cfg := c.config
cfg.driver = &txDriver{tx: tx, drv: c.driver}
return &Tx{ return &Tx{
config: cfg, config: cfg,
AuthCode: NewAuthCodeClient(cfg), AuthCode: NewAuthCodeClient(cfg),
@ -153,7 +157,8 @@ func (c *Client) Debug() *Client {
if c.debug { if c.debug {
return c return c
} }
cfg := config{driver: dialect.Debug(c.driver, c.log), log: c.log, debug: true, hooks: c.hooks} cfg := c.config
cfg.driver = dialect.Debug(c.driver, c.log)
client := &Client{config: cfg} client := &Client{config: cfg}
client.init() client.init()
return client return client

View file

@ -3,8 +3,8 @@
package db package db
import ( import (
"github.com/facebook/ent" "entgo.io/ent"
"github.com/facebook/ent/dialect" "entgo.io/ent/dialect"
) )
// Option function to configure the client. // Option function to configure the client.

View file

@ -6,8 +6,8 @@ import (
"fmt" "fmt"
"strings" "strings"
"entgo.io/ent/dialect/sql"
"github.com/dexidp/dex/storage/ent/db/connector" "github.com/dexidp/dex/storage/ent/db/connector"
"github.com/facebook/ent/dialect/sql"
) )
// Connector is the model entity for the Connector schema. // Connector is the model entity for the Connector schema.

View file

@ -15,7 +15,6 @@ const (
FieldResourceVersion = "resource_version" FieldResourceVersion = "resource_version"
// FieldConfig holds the string denoting the config field in the database. // FieldConfig holds the string denoting the config field in the database.
FieldConfig = "config" FieldConfig = "config"
// Table holds the table name of the connector in the database. // Table holds the table name of the connector in the database.
Table = "connectors" Table = "connectors"
) )

View file

@ -3,8 +3,8 @@
package connector package connector
import ( import (
"entgo.io/ent/dialect/sql"
"github.com/dexidp/dex/storage/ent/db/predicate" "github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/facebook/ent/dialect/sql"
) )
// ID filters vertices based on their ID field. // ID filters vertices based on their ID field.

View file

@ -7,9 +7,9 @@ import (
"errors" "errors"
"fmt" "fmt"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/dexidp/dex/storage/ent/db/connector" "github.com/dexidp/dex/storage/ent/db/connector"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
) )
// ConnectorCreate is the builder for creating a Connector entity. // ConnectorCreate is the builder for creating a Connector entity.

View file

@ -6,11 +6,11 @@ import (
"context" "context"
"fmt" "fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/dexidp/dex/storage/ent/db/connector" "github.com/dexidp/dex/storage/ent/db/connector"
"github.com/dexidp/dex/storage/ent/db/predicate" "github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
) )
// ConnectorDelete is the builder for deleting a Connector entity. // ConnectorDelete is the builder for deleting a Connector entity.

View file

@ -8,11 +8,11 @@ import (
"fmt" "fmt"
"math" "math"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/dexidp/dex/storage/ent/db/connector" "github.com/dexidp/dex/storage/ent/db/connector"
"github.com/dexidp/dex/storage/ent/db/predicate" "github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
) )
// ConnectorQuery is the builder for querying Connector entities. // ConnectorQuery is the builder for querying Connector entities.
@ -261,7 +261,7 @@ func (cq *ConnectorQuery) GroupBy(field string, fields ...string) *ConnectorGrou
if err := cq.prepareQuery(ctx); err != nil { if err := cq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
} }
return cq.sqlQuery(), nil return cq.sqlQuery(ctx), nil
} }
return group return group
} }
@ -334,7 +334,7 @@ func (cq *ConnectorQuery) sqlCount(ctx context.Context) (int, error) {
func (cq *ConnectorQuery) sqlExist(ctx context.Context) (bool, error) { func (cq *ConnectorQuery) sqlExist(ctx context.Context) (bool, error) {
n, err := cq.sqlCount(ctx) n, err := cq.sqlCount(ctx)
if err != nil { if err != nil {
return false, fmt.Errorf("db: check existence: %v", err) return false, fmt.Errorf("db: check existence: %w", err)
} }
return n > 0, nil return n > 0, nil
} }
@ -384,7 +384,7 @@ func (cq *ConnectorQuery) querySpec() *sqlgraph.QuerySpec {
return _spec return _spec
} }
func (cq *ConnectorQuery) sqlQuery() *sql.Selector { func (cq *ConnectorQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(cq.driver.Dialect()) builder := sql.Dialect(cq.driver.Dialect())
t1 := builder.Table(connector.Table) t1 := builder.Table(connector.Table)
selector := builder.Select(t1.Columns(connector.Columns...)...).From(t1) selector := builder.Select(t1.Columns(connector.Columns...)...).From(t1)
@ -679,7 +679,7 @@ func (cs *ConnectorSelect) Scan(ctx context.Context, v interface{}) error {
if err := cs.prepareQuery(ctx); err != nil { if err := cs.prepareQuery(ctx); err != nil {
return err return err
} }
cs.sql = cs.ConnectorQuery.sqlQuery() cs.sql = cs.ConnectorQuery.sqlQuery(ctx)
return cs.sqlScan(ctx, v) return cs.sqlScan(ctx, v)
} }

View file

@ -6,11 +6,11 @@ import (
"context" "context"
"fmt" "fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/dexidp/dex/storage/ent/db/connector" "github.com/dexidp/dex/storage/ent/db/connector"
"github.com/dexidp/dex/storage/ent/db/predicate" "github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
) )
// ConnectorUpdate is the builder for updating Connector entities. // ConnectorUpdate is the builder for updating Connector entities.
@ -308,6 +308,13 @@ func (cuo *ConnectorUpdateOne) sqlSave(ctx context.Context) (_node *Connector, e
return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing Connector.ID for update")} return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing Connector.ID for update")}
} }
_spec.Node.ID.Value = id _spec.Node.ID.Value = id
if ps := cuo.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := cuo.mutation.GetType(); ok { if value, ok := cuo.mutation.GetType(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeString, Type: field.TypeString,

View file

@ -8,8 +8,8 @@ import (
"strings" "strings"
"time" "time"
"entgo.io/ent/dialect/sql"
"github.com/dexidp/dex/storage/ent/db/devicerequest" "github.com/dexidp/dex/storage/ent/db/devicerequest"
"github.com/facebook/ent/dialect/sql"
) )
// DeviceRequest is the model entity for the DeviceRequest schema. // DeviceRequest is the model entity for the DeviceRequest schema.
@ -95,7 +95,7 @@ func (dr *DeviceRequest) assignValues(columns []string, values []interface{}) er
return fmt.Errorf("unexpected type %T for field scopes", values[i]) return fmt.Errorf("unexpected type %T for field scopes", values[i])
} else if value != nil && len(*value) > 0 { } else if value != nil && len(*value) > 0 {
if err := json.Unmarshal(*value, &dr.Scopes); err != nil { if err := json.Unmarshal(*value, &dr.Scopes); err != nil {
return fmt.Errorf("unmarshal field scopes: %v", err) return fmt.Errorf("unmarshal field scopes: %w", err)
} }
} }
case devicerequest.FieldExpiry: case devicerequest.FieldExpiry:

View file

@ -19,7 +19,6 @@ const (
FieldScopes = "scopes" FieldScopes = "scopes"
// FieldExpiry holds the string denoting the expiry field in the database. // FieldExpiry holds the string denoting the expiry field in the database.
FieldExpiry = "expiry" FieldExpiry = "expiry"
// Table holds the table name of the devicerequest in the database. // Table holds the table name of the devicerequest in the database.
Table = "device_requests" Table = "device_requests"
) )

View file

@ -5,8 +5,8 @@ package devicerequest
import ( import (
"time" "time"
"entgo.io/ent/dialect/sql"
"github.com/dexidp/dex/storage/ent/db/predicate" "github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/facebook/ent/dialect/sql"
) )
// ID filters vertices based on their ID field. // ID filters vertices based on their ID field.

View file

@ -8,9 +8,9 @@ import (
"fmt" "fmt"
"time" "time"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/dexidp/dex/storage/ent/db/devicerequest" "github.com/dexidp/dex/storage/ent/db/devicerequest"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
) )
// DeviceRequestCreate is the builder for creating a DeviceRequest entity. // DeviceRequestCreate is the builder for creating a DeviceRequest entity.

View file

@ -6,11 +6,11 @@ import (
"context" "context"
"fmt" "fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/dexidp/dex/storage/ent/db/devicerequest" "github.com/dexidp/dex/storage/ent/db/devicerequest"
"github.com/dexidp/dex/storage/ent/db/predicate" "github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
) )
// DeviceRequestDelete is the builder for deleting a DeviceRequest entity. // DeviceRequestDelete is the builder for deleting a DeviceRequest entity.

View file

@ -8,11 +8,11 @@ import (
"fmt" "fmt"
"math" "math"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/dexidp/dex/storage/ent/db/devicerequest" "github.com/dexidp/dex/storage/ent/db/devicerequest"
"github.com/dexidp/dex/storage/ent/db/predicate" "github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
) )
// DeviceRequestQuery is the builder for querying DeviceRequest entities. // DeviceRequestQuery is the builder for querying DeviceRequest entities.
@ -261,7 +261,7 @@ func (drq *DeviceRequestQuery) GroupBy(field string, fields ...string) *DeviceRe
if err := drq.prepareQuery(ctx); err != nil { if err := drq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
} }
return drq.sqlQuery(), nil return drq.sqlQuery(ctx), nil
} }
return group return group
} }
@ -334,7 +334,7 @@ func (drq *DeviceRequestQuery) sqlCount(ctx context.Context) (int, error) {
func (drq *DeviceRequestQuery) sqlExist(ctx context.Context) (bool, error) { func (drq *DeviceRequestQuery) sqlExist(ctx context.Context) (bool, error) {
n, err := drq.sqlCount(ctx) n, err := drq.sqlCount(ctx)
if err != nil { if err != nil {
return false, fmt.Errorf("db: check existence: %v", err) return false, fmt.Errorf("db: check existence: %w", err)
} }
return n > 0, nil return n > 0, nil
} }
@ -384,7 +384,7 @@ func (drq *DeviceRequestQuery) querySpec() *sqlgraph.QuerySpec {
return _spec return _spec
} }
func (drq *DeviceRequestQuery) sqlQuery() *sql.Selector { func (drq *DeviceRequestQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(drq.driver.Dialect()) builder := sql.Dialect(drq.driver.Dialect())
t1 := builder.Table(devicerequest.Table) t1 := builder.Table(devicerequest.Table)
selector := builder.Select(t1.Columns(devicerequest.Columns...)...).From(t1) selector := builder.Select(t1.Columns(devicerequest.Columns...)...).From(t1)
@ -679,7 +679,7 @@ func (drs *DeviceRequestSelect) Scan(ctx context.Context, v interface{}) error {
if err := drs.prepareQuery(ctx); err != nil { if err := drs.prepareQuery(ctx); err != nil {
return err return err
} }
drs.sql = drs.DeviceRequestQuery.sqlQuery() drs.sql = drs.DeviceRequestQuery.sqlQuery(ctx)
return drs.sqlScan(ctx, v) return drs.sqlScan(ctx, v)
} }

View file

@ -7,11 +7,11 @@ import (
"fmt" "fmt"
"time" "time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/dexidp/dex/storage/ent/db/devicerequest" "github.com/dexidp/dex/storage/ent/db/devicerequest"
"github.com/dexidp/dex/storage/ent/db/predicate" "github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
) )
// DeviceRequestUpdate is the builder for updating DeviceRequest entities. // DeviceRequestUpdate is the builder for updating DeviceRequest entities.
@ -385,6 +385,13 @@ func (druo *DeviceRequestUpdateOne) sqlSave(ctx context.Context) (_node *DeviceR
return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing DeviceRequest.ID for update")} return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing DeviceRequest.ID for update")}
} }
_spec.Node.ID.Value = id _spec.Node.ID.Value = id
if ps := druo.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := druo.mutation.UserCode(); ok { if value, ok := druo.mutation.UserCode(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeString, Type: field.TypeString,

View file

@ -7,8 +7,8 @@ import (
"strings" "strings"
"time" "time"
"entgo.io/ent/dialect/sql"
"github.com/dexidp/dex/storage/ent/db/devicetoken" "github.com/dexidp/dex/storage/ent/db/devicetoken"
"github.com/facebook/ent/dialect/sql"
) )
// DeviceToken is the model entity for the DeviceToken schema. // DeviceToken is the model entity for the DeviceToken schema.

View file

@ -19,7 +19,6 @@ const (
FieldLastRequest = "last_request" FieldLastRequest = "last_request"
// FieldPollInterval holds the string denoting the poll_interval field in the database. // FieldPollInterval holds the string denoting the poll_interval field in the database.
FieldPollInterval = "poll_interval" FieldPollInterval = "poll_interval"
// Table holds the table name of the devicetoken in the database. // Table holds the table name of the devicetoken in the database.
Table = "device_tokens" Table = "device_tokens"
) )

View file

@ -5,8 +5,8 @@ package devicetoken
import ( import (
"time" "time"
"entgo.io/ent/dialect/sql"
"github.com/dexidp/dex/storage/ent/db/predicate" "github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/facebook/ent/dialect/sql"
) )
// ID filters vertices based on their ID field. // ID filters vertices based on their ID field.

View file

@ -8,9 +8,9 @@ import (
"fmt" "fmt"
"time" "time"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/dexidp/dex/storage/ent/db/devicetoken" "github.com/dexidp/dex/storage/ent/db/devicetoken"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
) )
// DeviceTokenCreate is the builder for creating a DeviceToken entity. // DeviceTokenCreate is the builder for creating a DeviceToken entity.

View file

@ -6,11 +6,11 @@ import (
"context" "context"
"fmt" "fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/dexidp/dex/storage/ent/db/devicetoken" "github.com/dexidp/dex/storage/ent/db/devicetoken"
"github.com/dexidp/dex/storage/ent/db/predicate" "github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
) )
// DeviceTokenDelete is the builder for deleting a DeviceToken entity. // DeviceTokenDelete is the builder for deleting a DeviceToken entity.

View file

@ -8,11 +8,11 @@ import (
"fmt" "fmt"
"math" "math"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/dexidp/dex/storage/ent/db/devicetoken" "github.com/dexidp/dex/storage/ent/db/devicetoken"
"github.com/dexidp/dex/storage/ent/db/predicate" "github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
) )
// DeviceTokenQuery is the builder for querying DeviceToken entities. // DeviceTokenQuery is the builder for querying DeviceToken entities.
@ -261,7 +261,7 @@ func (dtq *DeviceTokenQuery) GroupBy(field string, fields ...string) *DeviceToke
if err := dtq.prepareQuery(ctx); err != nil { if err := dtq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
} }
return dtq.sqlQuery(), nil return dtq.sqlQuery(ctx), nil
} }
return group return group
} }
@ -334,7 +334,7 @@ func (dtq *DeviceTokenQuery) sqlCount(ctx context.Context) (int, error) {
func (dtq *DeviceTokenQuery) sqlExist(ctx context.Context) (bool, error) { func (dtq *DeviceTokenQuery) sqlExist(ctx context.Context) (bool, error) {
n, err := dtq.sqlCount(ctx) n, err := dtq.sqlCount(ctx)
if err != nil { if err != nil {
return false, fmt.Errorf("db: check existence: %v", err) return false, fmt.Errorf("db: check existence: %w", err)
} }
return n > 0, nil return n > 0, nil
} }
@ -384,7 +384,7 @@ func (dtq *DeviceTokenQuery) querySpec() *sqlgraph.QuerySpec {
return _spec return _spec
} }
func (dtq *DeviceTokenQuery) sqlQuery() *sql.Selector { func (dtq *DeviceTokenQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(dtq.driver.Dialect()) builder := sql.Dialect(dtq.driver.Dialect())
t1 := builder.Table(devicetoken.Table) t1 := builder.Table(devicetoken.Table)
selector := builder.Select(t1.Columns(devicetoken.Columns...)...).From(t1) selector := builder.Select(t1.Columns(devicetoken.Columns...)...).From(t1)
@ -679,7 +679,7 @@ func (dts *DeviceTokenSelect) Scan(ctx context.Context, v interface{}) error {
if err := dts.prepareQuery(ctx); err != nil { if err := dts.prepareQuery(ctx); err != nil {
return err return err
} }
dts.sql = dts.DeviceTokenQuery.sqlQuery() dts.sql = dts.DeviceTokenQuery.sqlQuery(ctx)
return dts.sqlScan(ctx, v) return dts.sqlScan(ctx, v)
} }

View file

@ -7,11 +7,11 @@ import (
"fmt" "fmt"
"time" "time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/dexidp/dex/storage/ent/db/devicetoken" "github.com/dexidp/dex/storage/ent/db/devicetoken"
"github.com/dexidp/dex/storage/ent/db/predicate" "github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
) )
// DeviceTokenUpdate is the builder for updating DeviceToken entities. // DeviceTokenUpdate is the builder for updating DeviceToken entities.
@ -386,6 +386,13 @@ func (dtuo *DeviceTokenUpdateOne) sqlSave(ctx context.Context) (_node *DeviceTok
return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing DeviceToken.ID for update")} return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing DeviceToken.ID for update")}
} }
_spec.Node.ID.Value = id _spec.Node.ID.Value = id
if ps := dtuo.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := dtuo.mutation.DeviceCode(); ok { if value, ok := dtuo.mutation.DeviceCode(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeString, Type: field.TypeString,

View file

@ -5,12 +5,11 @@ package db
import ( import (
"errors" "errors"
"fmt" "fmt"
"strings"
"github.com/facebook/ent" "entgo.io/ent"
"github.com/facebook/ent/dialect" "entgo.io/ent/dialect"
"github.com/facebook/ent/dialect/sql" "entgo.io/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph" "entgo.io/ent/dialect/sql/sqlgraph"
) )
// ent aliases to avoid import conflicts in user's code. // ent aliases to avoid import conflicts in user's code.
@ -238,22 +237,8 @@ func IsConstraintError(err error) bool {
} }
func isSQLConstraintError(err error) (*ConstraintError, bool) { func isSQLConstraintError(err error) (*ConstraintError, bool) {
var ( if sqlgraph.IsConstraintError(err) {
msg = err.Error() return &ConstraintError{err.Error(), err}, true
// error format per dialect.
errors = [...]string{
"Error 1062", // MySQL 1062 error (ER_DUP_ENTRY).
"UNIQUE constraint failed", // SQLite.
"duplicate key value violates unique constraint", // PostgreSQL.
}
)
if _, ok := err.(*sqlgraph.ConstraintError); ok {
return &ConstraintError{msg, err}, true
}
for i := range errors {
if strings.Contains(msg, errors[i]) {
return &ConstraintError{msg, err}, true
}
} }
return nil, false return nil, false
} }
@ -261,7 +246,7 @@ func isSQLConstraintError(err error) (*ConstraintError, bool) {
// rollback calls tx.Rollback and wraps the given error with the rollback error if present. // rollback calls tx.Rollback and wraps the given error with the rollback error if present.
func rollback(tx dialect.Tx, err error) error { func rollback(tx dialect.Tx, err error) error {
if rerr := tx.Rollback(); rerr != nil { if rerr := tx.Rollback(); rerr != nil {
err = fmt.Errorf("%s: %v", err.Error(), rerr) err = fmt.Errorf("%w: %v", err, rerr)
} }
if err, ok := isSQLConstraintError(err); ok { if err, ok := isSQLConstraintError(err); ok {
return err return err

View file

@ -9,7 +9,7 @@ import (
// required by schema hooks. // required by schema hooks.
_ "github.com/dexidp/dex/storage/ent/db/runtime" _ "github.com/dexidp/dex/storage/ent/db/runtime"
"github.com/facebook/ent/dialect/sql/schema" "entgo.io/ent/dialect/sql/schema"
) )
type ( type (

View file

@ -8,9 +8,9 @@ import (
"strings" "strings"
"time" "time"
"entgo.io/ent/dialect/sql"
"github.com/dexidp/dex/storage" "github.com/dexidp/dex/storage"
"github.com/dexidp/dex/storage/ent/db/keys" "github.com/dexidp/dex/storage/ent/db/keys"
"github.com/facebook/ent/dialect/sql"
"gopkg.in/square/go-jose.v2" "gopkg.in/square/go-jose.v2"
) )
@ -67,7 +67,7 @@ func (k *Keys) assignValues(columns []string, values []interface{}) error {
return fmt.Errorf("unexpected type %T for field verification_keys", values[i]) return fmt.Errorf("unexpected type %T for field verification_keys", values[i])
} else if value != nil && len(*value) > 0 { } else if value != nil && len(*value) > 0 {
if err := json.Unmarshal(*value, &k.VerificationKeys); err != nil { if err := json.Unmarshal(*value, &k.VerificationKeys); err != nil {
return fmt.Errorf("unmarshal field verification_keys: %v", err) return fmt.Errorf("unmarshal field verification_keys: %w", err)
} }
} }
case keys.FieldSigningKey: case keys.FieldSigningKey:
@ -76,7 +76,7 @@ func (k *Keys) assignValues(columns []string, values []interface{}) error {
return fmt.Errorf("unexpected type %T for field signing_key", values[i]) return fmt.Errorf("unexpected type %T for field signing_key", values[i])
} else if value != nil && len(*value) > 0 { } else if value != nil && len(*value) > 0 {
if err := json.Unmarshal(*value, &k.SigningKey); err != nil { if err := json.Unmarshal(*value, &k.SigningKey); err != nil {
return fmt.Errorf("unmarshal field signing_key: %v", err) return fmt.Errorf("unmarshal field signing_key: %w", err)
} }
} }
case keys.FieldSigningKeyPub: case keys.FieldSigningKeyPub:
@ -85,7 +85,7 @@ func (k *Keys) assignValues(columns []string, values []interface{}) error {
return fmt.Errorf("unexpected type %T for field signing_key_pub", values[i]) return fmt.Errorf("unexpected type %T for field signing_key_pub", values[i])
} else if value != nil && len(*value) > 0 { } else if value != nil && len(*value) > 0 {
if err := json.Unmarshal(*value, &k.SigningKeyPub); err != nil { if err := json.Unmarshal(*value, &k.SigningKeyPub); err != nil {
return fmt.Errorf("unmarshal field signing_key_pub: %v", err) return fmt.Errorf("unmarshal field signing_key_pub: %w", err)
} }
} }
case keys.FieldNextRotation: case keys.FieldNextRotation:

View file

@ -15,7 +15,6 @@ const (
FieldSigningKeyPub = "signing_key_pub" FieldSigningKeyPub = "signing_key_pub"
// FieldNextRotation holds the string denoting the next_rotation field in the database. // FieldNextRotation holds the string denoting the next_rotation field in the database.
FieldNextRotation = "next_rotation" FieldNextRotation = "next_rotation"
// Table holds the table name of the keys in the database. // Table holds the table name of the keys in the database.
Table = "keys" Table = "keys"
) )

View file

@ -5,8 +5,8 @@ package keys
import ( import (
"time" "time"
"entgo.io/ent/dialect/sql"
"github.com/dexidp/dex/storage/ent/db/predicate" "github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/facebook/ent/dialect/sql"
) )
// ID filters vertices based on their ID field. // ID filters vertices based on their ID field.

View file

@ -8,10 +8,10 @@ import (
"fmt" "fmt"
"time" "time"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/dexidp/dex/storage" "github.com/dexidp/dex/storage"
"github.com/dexidp/dex/storage/ent/db/keys" "github.com/dexidp/dex/storage/ent/db/keys"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
"gopkg.in/square/go-jose.v2" "gopkg.in/square/go-jose.v2"
) )

View file

@ -6,11 +6,11 @@ import (
"context" "context"
"fmt" "fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/dexidp/dex/storage/ent/db/keys" "github.com/dexidp/dex/storage/ent/db/keys"
"github.com/dexidp/dex/storage/ent/db/predicate" "github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
) )
// KeysDelete is the builder for deleting a Keys entity. // KeysDelete is the builder for deleting a Keys entity.

View file

@ -8,11 +8,11 @@ import (
"fmt" "fmt"
"math" "math"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/dexidp/dex/storage/ent/db/keys" "github.com/dexidp/dex/storage/ent/db/keys"
"github.com/dexidp/dex/storage/ent/db/predicate" "github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
) )
// KeysQuery is the builder for querying Keys entities. // KeysQuery is the builder for querying Keys entities.
@ -261,7 +261,7 @@ func (kq *KeysQuery) GroupBy(field string, fields ...string) *KeysGroupBy {
if err := kq.prepareQuery(ctx); err != nil { if err := kq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
} }
return kq.sqlQuery(), nil return kq.sqlQuery(ctx), nil
} }
return group return group
} }
@ -334,7 +334,7 @@ func (kq *KeysQuery) sqlCount(ctx context.Context) (int, error) {
func (kq *KeysQuery) sqlExist(ctx context.Context) (bool, error) { func (kq *KeysQuery) sqlExist(ctx context.Context) (bool, error) {
n, err := kq.sqlCount(ctx) n, err := kq.sqlCount(ctx)
if err != nil { if err != nil {
return false, fmt.Errorf("db: check existence: %v", err) return false, fmt.Errorf("db: check existence: %w", err)
} }
return n > 0, nil return n > 0, nil
} }
@ -384,7 +384,7 @@ func (kq *KeysQuery) querySpec() *sqlgraph.QuerySpec {
return _spec return _spec
} }
func (kq *KeysQuery) sqlQuery() *sql.Selector { func (kq *KeysQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(kq.driver.Dialect()) builder := sql.Dialect(kq.driver.Dialect())
t1 := builder.Table(keys.Table) t1 := builder.Table(keys.Table)
selector := builder.Select(t1.Columns(keys.Columns...)...).From(t1) selector := builder.Select(t1.Columns(keys.Columns...)...).From(t1)
@ -679,7 +679,7 @@ func (ks *KeysSelect) Scan(ctx context.Context, v interface{}) error {
if err := ks.prepareQuery(ctx); err != nil { if err := ks.prepareQuery(ctx); err != nil {
return err return err
} }
ks.sql = ks.KeysQuery.sqlQuery() ks.sql = ks.KeysQuery.sqlQuery(ctx)
return ks.sqlScan(ctx, v) return ks.sqlScan(ctx, v)
} }

View file

@ -7,12 +7,12 @@ import (
"fmt" "fmt"
"time" "time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/dexidp/dex/storage" "github.com/dexidp/dex/storage"
"github.com/dexidp/dex/storage/ent/db/keys" "github.com/dexidp/dex/storage/ent/db/keys"
"github.com/dexidp/dex/storage/ent/db/predicate" "github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
"gopkg.in/square/go-jose.v2" "gopkg.in/square/go-jose.v2"
) )
@ -269,6 +269,13 @@ func (kuo *KeysUpdateOne) sqlSave(ctx context.Context) (_node *Keys, err error)
return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing Keys.ID for update")} return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing Keys.ID for update")}
} }
_spec.Node.ID.Value = id _spec.Node.ID.Value = id
if ps := kuo.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := kuo.mutation.VerificationKeys(); ok { if value, ok := kuo.mutation.VerificationKeys(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeJSON, Type: field.TypeJSON,

View file

@ -7,8 +7,8 @@ import (
"fmt" "fmt"
"io" "io"
"github.com/facebook/ent/dialect" "entgo.io/ent/dialect"
"github.com/facebook/ent/dialect/sql/schema" "entgo.io/ent/dialect/sql/schema"
) )
var ( var (
@ -48,7 +48,7 @@ func NewSchema(drv dialect.Driver) *Schema { return &Schema{drv: drv} }
func (s *Schema) Create(ctx context.Context, opts ...schema.MigrateOption) error { func (s *Schema) Create(ctx context.Context, opts ...schema.MigrateOption) error {
migrate, err := schema.NewMigrate(s.drv, opts...) migrate, err := schema.NewMigrate(s.drv, opts...)
if err != nil { if err != nil {
return fmt.Errorf("ent/migrate: %v", err) return fmt.Errorf("ent/migrate: %w", err)
} }
return migrate.Create(ctx, Tables...) return migrate.Create(ctx, Tables...)
} }
@ -66,7 +66,7 @@ func (s *Schema) WriteTo(ctx context.Context, w io.Writer, opts ...schema.Migrat
} }
migrate, err := schema.NewMigrate(drv, opts...) migrate, err := schema.NewMigrate(drv, opts...)
if err != nil { if err != nil {
return fmt.Errorf("ent/migrate: %v", err) return fmt.Errorf("ent/migrate: %w", err)
} }
return migrate.Create(ctx, Tables...) return migrate.Create(ctx, Tables...)
} }

View file

@ -3,8 +3,8 @@
package migrate package migrate
import ( import (
"github.com/facebook/ent/dialect/sql/schema" "entgo.io/ent/dialect/sql/schema"
"github.com/facebook/ent/schema/field" "entgo.io/ent/schema/field"
) )
var ( var (

View file

@ -22,7 +22,7 @@ import (
"github.com/dexidp/dex/storage/ent/db/refreshtoken" "github.com/dexidp/dex/storage/ent/db/refreshtoken"
"gopkg.in/square/go-jose.v2" "gopkg.in/square/go-jose.v2"
"github.com/facebook/ent" "entgo.io/ent"
) )
const ( const (

View file

@ -7,8 +7,8 @@ import (
"fmt" "fmt"
"strings" "strings"
"entgo.io/ent/dialect/sql"
"github.com/dexidp/dex/storage/ent/db/oauth2client" "github.com/dexidp/dex/storage/ent/db/oauth2client"
"github.com/facebook/ent/dialect/sql"
) )
// OAuth2Client is the model entity for the OAuth2Client schema. // OAuth2Client is the model entity for the OAuth2Client schema.
@ -74,7 +74,7 @@ func (o *OAuth2Client) assignValues(columns []string, values []interface{}) erro
return fmt.Errorf("unexpected type %T for field redirect_uris", values[i]) return fmt.Errorf("unexpected type %T for field redirect_uris", values[i])
} else if value != nil && len(*value) > 0 { } else if value != nil && len(*value) > 0 {
if err := json.Unmarshal(*value, &o.RedirectUris); err != nil { if err := json.Unmarshal(*value, &o.RedirectUris); err != nil {
return fmt.Errorf("unmarshal field redirect_uris: %v", err) return fmt.Errorf("unmarshal field redirect_uris: %w", err)
} }
} }
case oauth2client.FieldTrustedPeers: case oauth2client.FieldTrustedPeers:
@ -83,7 +83,7 @@ func (o *OAuth2Client) assignValues(columns []string, values []interface{}) erro
return fmt.Errorf("unexpected type %T for field trusted_peers", values[i]) return fmt.Errorf("unexpected type %T for field trusted_peers", values[i])
} else if value != nil && len(*value) > 0 { } else if value != nil && len(*value) > 0 {
if err := json.Unmarshal(*value, &o.TrustedPeers); err != nil { if err := json.Unmarshal(*value, &o.TrustedPeers); err != nil {
return fmt.Errorf("unmarshal field trusted_peers: %v", err) return fmt.Errorf("unmarshal field trusted_peers: %w", err)
} }
} }
case oauth2client.FieldPublic: case oauth2client.FieldPublic:

View file

@ -19,7 +19,6 @@ const (
FieldName = "name" FieldName = "name"
// FieldLogoURL holds the string denoting the logo_url field in the database. // FieldLogoURL holds the string denoting the logo_url field in the database.
FieldLogoURL = "logo_url" FieldLogoURL = "logo_url"
// Table holds the table name of the oauth2client in the database. // Table holds the table name of the oauth2client in the database.
Table = "oauth2clients" Table = "oauth2clients"
) )

View file

@ -3,8 +3,8 @@
package oauth2client package oauth2client
import ( import (
"entgo.io/ent/dialect/sql"
"github.com/dexidp/dex/storage/ent/db/predicate" "github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/facebook/ent/dialect/sql"
) )
// ID filters vertices based on their ID field. // ID filters vertices based on their ID field.

View file

@ -7,9 +7,9 @@ import (
"errors" "errors"
"fmt" "fmt"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/dexidp/dex/storage/ent/db/oauth2client" "github.com/dexidp/dex/storage/ent/db/oauth2client"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
) )
// OAuth2ClientCreate is the builder for creating a OAuth2Client entity. // OAuth2ClientCreate is the builder for creating a OAuth2Client entity.

View file

@ -6,11 +6,11 @@ import (
"context" "context"
"fmt" "fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/dexidp/dex/storage/ent/db/oauth2client" "github.com/dexidp/dex/storage/ent/db/oauth2client"
"github.com/dexidp/dex/storage/ent/db/predicate" "github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
) )
// OAuth2ClientDelete is the builder for deleting a OAuth2Client entity. // OAuth2ClientDelete is the builder for deleting a OAuth2Client entity.

View file

@ -8,11 +8,11 @@ import (
"fmt" "fmt"
"math" "math"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/dexidp/dex/storage/ent/db/oauth2client" "github.com/dexidp/dex/storage/ent/db/oauth2client"
"github.com/dexidp/dex/storage/ent/db/predicate" "github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
) )
// OAuth2ClientQuery is the builder for querying OAuth2Client entities. // OAuth2ClientQuery is the builder for querying OAuth2Client entities.
@ -261,7 +261,7 @@ func (oq *OAuth2ClientQuery) GroupBy(field string, fields ...string) *OAuth2Clie
if err := oq.prepareQuery(ctx); err != nil { if err := oq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
} }
return oq.sqlQuery(), nil return oq.sqlQuery(ctx), nil
} }
return group return group
} }
@ -334,7 +334,7 @@ func (oq *OAuth2ClientQuery) sqlCount(ctx context.Context) (int, error) {
func (oq *OAuth2ClientQuery) sqlExist(ctx context.Context) (bool, error) { func (oq *OAuth2ClientQuery) sqlExist(ctx context.Context) (bool, error) {
n, err := oq.sqlCount(ctx) n, err := oq.sqlCount(ctx)
if err != nil { if err != nil {
return false, fmt.Errorf("db: check existence: %v", err) return false, fmt.Errorf("db: check existence: %w", err)
} }
return n > 0, nil return n > 0, nil
} }
@ -384,7 +384,7 @@ func (oq *OAuth2ClientQuery) querySpec() *sqlgraph.QuerySpec {
return _spec return _spec
} }
func (oq *OAuth2ClientQuery) sqlQuery() *sql.Selector { func (oq *OAuth2ClientQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(oq.driver.Dialect()) builder := sql.Dialect(oq.driver.Dialect())
t1 := builder.Table(oauth2client.Table) t1 := builder.Table(oauth2client.Table)
selector := builder.Select(t1.Columns(oauth2client.Columns...)...).From(t1) selector := builder.Select(t1.Columns(oauth2client.Columns...)...).From(t1)
@ -679,7 +679,7 @@ func (os *OAuth2ClientSelect) Scan(ctx context.Context, v interface{}) error {
if err := os.prepareQuery(ctx); err != nil { if err := os.prepareQuery(ctx); err != nil {
return err return err
} }
os.sql = os.OAuth2ClientQuery.sqlQuery() os.sql = os.OAuth2ClientQuery.sqlQuery(ctx)
return os.sqlScan(ctx, v) return os.sqlScan(ctx, v)
} }

View file

@ -6,11 +6,11 @@ import (
"context" "context"
"fmt" "fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/dexidp/dex/storage/ent/db/oauth2client" "github.com/dexidp/dex/storage/ent/db/oauth2client"
"github.com/dexidp/dex/storage/ent/db/predicate" "github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
) )
// OAuth2ClientUpdate is the builder for updating OAuth2Client entities. // OAuth2ClientUpdate is the builder for updating OAuth2Client entities.
@ -392,6 +392,13 @@ func (ouo *OAuth2ClientUpdateOne) sqlSave(ctx context.Context) (_node *OAuth2Cli
return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing OAuth2Client.ID for update")} return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing OAuth2Client.ID for update")}
} }
_spec.Node.ID.Value = id _spec.Node.ID.Value = id
if ps := ouo.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := ouo.mutation.Secret(); ok { if value, ok := ouo.mutation.Secret(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeString, Type: field.TypeString,

View file

@ -6,8 +6,8 @@ import (
"fmt" "fmt"
"strings" "strings"
"entgo.io/ent/dialect/sql"
"github.com/dexidp/dex/storage/ent/db/offlinesession" "github.com/dexidp/dex/storage/ent/db/offlinesession"
"github.com/facebook/ent/dialect/sql"
) )
// OfflineSession is the model entity for the OfflineSession schema. // OfflineSession is the model entity for the OfflineSession schema.

View file

@ -15,7 +15,6 @@ const (
FieldRefresh = "refresh" FieldRefresh = "refresh"
// FieldConnectorData holds the string denoting the connector_data field in the database. // FieldConnectorData holds the string denoting the connector_data field in the database.
FieldConnectorData = "connector_data" FieldConnectorData = "connector_data"
// Table holds the table name of the offlinesession in the database. // Table holds the table name of the offlinesession in the database.
Table = "offline_sessions" Table = "offline_sessions"
) )

View file

@ -3,8 +3,8 @@
package offlinesession package offlinesession
import ( import (
"entgo.io/ent/dialect/sql"
"github.com/dexidp/dex/storage/ent/db/predicate" "github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/facebook/ent/dialect/sql"
) )
// ID filters vertices based on their ID field. // ID filters vertices based on their ID field.

View file

@ -7,9 +7,9 @@ import (
"errors" "errors"
"fmt" "fmt"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/dexidp/dex/storage/ent/db/offlinesession" "github.com/dexidp/dex/storage/ent/db/offlinesession"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
) )
// OfflineSessionCreate is the builder for creating a OfflineSession entity. // OfflineSessionCreate is the builder for creating a OfflineSession entity.

View file

@ -6,11 +6,11 @@ import (
"context" "context"
"fmt" "fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/dexidp/dex/storage/ent/db/offlinesession" "github.com/dexidp/dex/storage/ent/db/offlinesession"
"github.com/dexidp/dex/storage/ent/db/predicate" "github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
) )
// OfflineSessionDelete is the builder for deleting a OfflineSession entity. // OfflineSessionDelete is the builder for deleting a OfflineSession entity.

View file

@ -8,11 +8,11 @@ import (
"fmt" "fmt"
"math" "math"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/dexidp/dex/storage/ent/db/offlinesession" "github.com/dexidp/dex/storage/ent/db/offlinesession"
"github.com/dexidp/dex/storage/ent/db/predicate" "github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
) )
// OfflineSessionQuery is the builder for querying OfflineSession entities. // OfflineSessionQuery is the builder for querying OfflineSession entities.
@ -261,7 +261,7 @@ func (osq *OfflineSessionQuery) GroupBy(field string, fields ...string) *Offline
if err := osq.prepareQuery(ctx); err != nil { if err := osq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
} }
return osq.sqlQuery(), nil return osq.sqlQuery(ctx), nil
} }
return group return group
} }
@ -334,7 +334,7 @@ func (osq *OfflineSessionQuery) sqlCount(ctx context.Context) (int, error) {
func (osq *OfflineSessionQuery) sqlExist(ctx context.Context) (bool, error) { func (osq *OfflineSessionQuery) sqlExist(ctx context.Context) (bool, error) {
n, err := osq.sqlCount(ctx) n, err := osq.sqlCount(ctx)
if err != nil { if err != nil {
return false, fmt.Errorf("db: check existence: %v", err) return false, fmt.Errorf("db: check existence: %w", err)
} }
return n > 0, nil return n > 0, nil
} }
@ -384,7 +384,7 @@ func (osq *OfflineSessionQuery) querySpec() *sqlgraph.QuerySpec {
return _spec return _spec
} }
func (osq *OfflineSessionQuery) sqlQuery() *sql.Selector { func (osq *OfflineSessionQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(osq.driver.Dialect()) builder := sql.Dialect(osq.driver.Dialect())
t1 := builder.Table(offlinesession.Table) t1 := builder.Table(offlinesession.Table)
selector := builder.Select(t1.Columns(offlinesession.Columns...)...).From(t1) selector := builder.Select(t1.Columns(offlinesession.Columns...)...).From(t1)
@ -679,7 +679,7 @@ func (oss *OfflineSessionSelect) Scan(ctx context.Context, v interface{}) error
if err := oss.prepareQuery(ctx); err != nil { if err := oss.prepareQuery(ctx); err != nil {
return err return err
} }
oss.sql = oss.OfflineSessionQuery.sqlQuery() oss.sql = oss.OfflineSessionQuery.sqlQuery(ctx)
return oss.sqlScan(ctx, v) return oss.sqlScan(ctx, v)
} }

View file

@ -6,11 +6,11 @@ import (
"context" "context"
"fmt" "fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/dexidp/dex/storage/ent/db/offlinesession" "github.com/dexidp/dex/storage/ent/db/offlinesession"
"github.com/dexidp/dex/storage/ent/db/predicate" "github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
) )
// OfflineSessionUpdate is the builder for updating OfflineSession entities. // OfflineSessionUpdate is the builder for updating OfflineSession entities.
@ -326,6 +326,13 @@ func (osuo *OfflineSessionUpdateOne) sqlSave(ctx context.Context) (_node *Offlin
return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing OfflineSession.ID for update")} return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing OfflineSession.ID for update")}
} }
_spec.Node.ID.Value = id _spec.Node.ID.Value = id
if ps := osuo.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := osuo.mutation.UserID(); ok { if value, ok := osuo.mutation.UserID(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeString, Type: field.TypeString,

View file

@ -6,8 +6,8 @@ import (
"fmt" "fmt"
"strings" "strings"
"entgo.io/ent/dialect/sql"
"github.com/dexidp/dex/storage/ent/db/password" "github.com/dexidp/dex/storage/ent/db/password"
"github.com/facebook/ent/dialect/sql"
) )
// Password is the model entity for the Password schema. // Password is the model entity for the Password schema.

View file

@ -15,7 +15,6 @@ const (
FieldUsername = "username" FieldUsername = "username"
// FieldUserID holds the string denoting the user_id field in the database. // FieldUserID holds the string denoting the user_id field in the database.
FieldUserID = "user_id" FieldUserID = "user_id"
// Table holds the table name of the password in the database. // Table holds the table name of the password in the database.
Table = "passwords" Table = "passwords"
) )

View file

@ -3,8 +3,8 @@
package password package password
import ( import (
"entgo.io/ent/dialect/sql"
"github.com/dexidp/dex/storage/ent/db/predicate" "github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/facebook/ent/dialect/sql"
) )
// ID filters vertices based on their ID field. // ID filters vertices based on their ID field.

View file

@ -7,9 +7,9 @@ import (
"errors" "errors"
"fmt" "fmt"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/dexidp/dex/storage/ent/db/password" "github.com/dexidp/dex/storage/ent/db/password"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
) )
// PasswordCreate is the builder for creating a Password entity. // PasswordCreate is the builder for creating a Password entity.

View file

@ -6,11 +6,11 @@ import (
"context" "context"
"fmt" "fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/dexidp/dex/storage/ent/db/password" "github.com/dexidp/dex/storage/ent/db/password"
"github.com/dexidp/dex/storage/ent/db/predicate" "github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
) )
// PasswordDelete is the builder for deleting a Password entity. // PasswordDelete is the builder for deleting a Password entity.

View file

@ -8,11 +8,11 @@ import (
"fmt" "fmt"
"math" "math"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/dexidp/dex/storage/ent/db/password" "github.com/dexidp/dex/storage/ent/db/password"
"github.com/dexidp/dex/storage/ent/db/predicate" "github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
) )
// PasswordQuery is the builder for querying Password entities. // PasswordQuery is the builder for querying Password entities.
@ -261,7 +261,7 @@ func (pq *PasswordQuery) GroupBy(field string, fields ...string) *PasswordGroupB
if err := pq.prepareQuery(ctx); err != nil { if err := pq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
} }
return pq.sqlQuery(), nil return pq.sqlQuery(ctx), nil
} }
return group return group
} }
@ -334,7 +334,7 @@ func (pq *PasswordQuery) sqlCount(ctx context.Context) (int, error) {
func (pq *PasswordQuery) sqlExist(ctx context.Context) (bool, error) { func (pq *PasswordQuery) sqlExist(ctx context.Context) (bool, error) {
n, err := pq.sqlCount(ctx) n, err := pq.sqlCount(ctx)
if err != nil { if err != nil {
return false, fmt.Errorf("db: check existence: %v", err) return false, fmt.Errorf("db: check existence: %w", err)
} }
return n > 0, nil return n > 0, nil
} }
@ -384,7 +384,7 @@ func (pq *PasswordQuery) querySpec() *sqlgraph.QuerySpec {
return _spec return _spec
} }
func (pq *PasswordQuery) sqlQuery() *sql.Selector { func (pq *PasswordQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(pq.driver.Dialect()) builder := sql.Dialect(pq.driver.Dialect())
t1 := builder.Table(password.Table) t1 := builder.Table(password.Table)
selector := builder.Select(t1.Columns(password.Columns...)...).From(t1) selector := builder.Select(t1.Columns(password.Columns...)...).From(t1)
@ -679,7 +679,7 @@ func (ps *PasswordSelect) Scan(ctx context.Context, v interface{}) error {
if err := ps.prepareQuery(ctx); err != nil { if err := ps.prepareQuery(ctx); err != nil {
return err return err
} }
ps.sql = ps.PasswordQuery.sqlQuery() ps.sql = ps.PasswordQuery.sqlQuery(ctx)
return ps.sqlScan(ctx, v) return ps.sqlScan(ctx, v)
} }

View file

@ -6,11 +6,11 @@ import (
"context" "context"
"fmt" "fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/dexidp/dex/storage/ent/db/password" "github.com/dexidp/dex/storage/ent/db/password"
"github.com/dexidp/dex/storage/ent/db/predicate" "github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
) )
// PasswordUpdate is the builder for updating Password entities. // PasswordUpdate is the builder for updating Password entities.
@ -318,6 +318,13 @@ func (puo *PasswordUpdateOne) sqlSave(ctx context.Context) (_node *Password, err
return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing Password.ID for update")} return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing Password.ID for update")}
} }
_spec.Node.ID.Value = id _spec.Node.ID.Value = id
if ps := puo.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := puo.mutation.Email(); ok { if value, ok := puo.mutation.Email(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeString, Type: field.TypeString,

View file

@ -3,7 +3,7 @@
package predicate package predicate
import ( import (
"github.com/facebook/ent/dialect/sql" "entgo.io/ent/dialect/sql"
) )
// AuthCode is the predicate function for authcode builders. // AuthCode is the predicate function for authcode builders.

View file

@ -8,8 +8,8 @@ import (
"strings" "strings"
"time" "time"
"entgo.io/ent/dialect/sql"
"github.com/dexidp/dex/storage/ent/db/refreshtoken" "github.com/dexidp/dex/storage/ent/db/refreshtoken"
"github.com/facebook/ent/dialect/sql"
) )
// RefreshToken is the model entity for the RefreshToken schema. // RefreshToken is the model entity for the RefreshToken schema.
@ -93,7 +93,7 @@ func (rt *RefreshToken) assignValues(columns []string, values []interface{}) err
return fmt.Errorf("unexpected type %T for field scopes", values[i]) return fmt.Errorf("unexpected type %T for field scopes", values[i])
} else if value != nil && len(*value) > 0 { } else if value != nil && len(*value) > 0 {
if err := json.Unmarshal(*value, &rt.Scopes); err != nil { if err := json.Unmarshal(*value, &rt.Scopes); err != nil {
return fmt.Errorf("unmarshal field scopes: %v", err) return fmt.Errorf("unmarshal field scopes: %w", err)
} }
} }
case refreshtoken.FieldNonce: case refreshtoken.FieldNonce:
@ -132,7 +132,7 @@ func (rt *RefreshToken) assignValues(columns []string, values []interface{}) err
return fmt.Errorf("unexpected type %T for field claims_groups", values[i]) return fmt.Errorf("unexpected type %T for field claims_groups", values[i])
} else if value != nil && len(*value) > 0 { } else if value != nil && len(*value) > 0 {
if err := json.Unmarshal(*value, &rt.ClaimsGroups); err != nil { if err := json.Unmarshal(*value, &rt.ClaimsGroups); err != nil {
return fmt.Errorf("unmarshal field claims_groups: %v", err) return fmt.Errorf("unmarshal field claims_groups: %w", err)
} }
} }
case refreshtoken.FieldClaimsPreferredUsername: case refreshtoken.FieldClaimsPreferredUsername:

View file

@ -39,7 +39,6 @@ const (
FieldCreatedAt = "created_at" FieldCreatedAt = "created_at"
// FieldLastUsed holds the string denoting the last_used field in the database. // FieldLastUsed holds the string denoting the last_used field in the database.
FieldLastUsed = "last_used" FieldLastUsed = "last_used"
// Table holds the table name of the refreshtoken in the database. // Table holds the table name of the refreshtoken in the database.
Table = "refresh_tokens" Table = "refresh_tokens"
) )

View file

@ -5,8 +5,8 @@ package refreshtoken
import ( import (
"time" "time"
"entgo.io/ent/dialect/sql"
"github.com/dexidp/dex/storage/ent/db/predicate" "github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/facebook/ent/dialect/sql"
) )
// ID filters vertices based on their ID field. // ID filters vertices based on their ID field.

View file

@ -8,9 +8,9 @@ import (
"fmt" "fmt"
"time" "time"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/dexidp/dex/storage/ent/db/refreshtoken" "github.com/dexidp/dex/storage/ent/db/refreshtoken"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
) )
// RefreshTokenCreate is the builder for creating a RefreshToken entity. // RefreshTokenCreate is the builder for creating a RefreshToken entity.

View file

@ -6,11 +6,11 @@ import (
"context" "context"
"fmt" "fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/dexidp/dex/storage/ent/db/predicate" "github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/dexidp/dex/storage/ent/db/refreshtoken" "github.com/dexidp/dex/storage/ent/db/refreshtoken"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
) )
// RefreshTokenDelete is the builder for deleting a RefreshToken entity. // RefreshTokenDelete is the builder for deleting a RefreshToken entity.

View file

@ -8,11 +8,11 @@ import (
"fmt" "fmt"
"math" "math"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/dexidp/dex/storage/ent/db/predicate" "github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/dexidp/dex/storage/ent/db/refreshtoken" "github.com/dexidp/dex/storage/ent/db/refreshtoken"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
) )
// RefreshTokenQuery is the builder for querying RefreshToken entities. // RefreshTokenQuery is the builder for querying RefreshToken entities.
@ -261,7 +261,7 @@ func (rtq *RefreshTokenQuery) GroupBy(field string, fields ...string) *RefreshTo
if err := rtq.prepareQuery(ctx); err != nil { if err := rtq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
} }
return rtq.sqlQuery(), nil return rtq.sqlQuery(ctx), nil
} }
return group return group
} }
@ -334,7 +334,7 @@ func (rtq *RefreshTokenQuery) sqlCount(ctx context.Context) (int, error) {
func (rtq *RefreshTokenQuery) sqlExist(ctx context.Context) (bool, error) { func (rtq *RefreshTokenQuery) sqlExist(ctx context.Context) (bool, error) {
n, err := rtq.sqlCount(ctx) n, err := rtq.sqlCount(ctx)
if err != nil { if err != nil {
return false, fmt.Errorf("db: check existence: %v", err) return false, fmt.Errorf("db: check existence: %w", err)
} }
return n > 0, nil return n > 0, nil
} }
@ -384,7 +384,7 @@ func (rtq *RefreshTokenQuery) querySpec() *sqlgraph.QuerySpec {
return _spec return _spec
} }
func (rtq *RefreshTokenQuery) sqlQuery() *sql.Selector { func (rtq *RefreshTokenQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(rtq.driver.Dialect()) builder := sql.Dialect(rtq.driver.Dialect())
t1 := builder.Table(refreshtoken.Table) t1 := builder.Table(refreshtoken.Table)
selector := builder.Select(t1.Columns(refreshtoken.Columns...)...).From(t1) selector := builder.Select(t1.Columns(refreshtoken.Columns...)...).From(t1)
@ -679,7 +679,7 @@ func (rts *RefreshTokenSelect) Scan(ctx context.Context, v interface{}) error {
if err := rts.prepareQuery(ctx); err != nil { if err := rts.prepareQuery(ctx); err != nil {
return err return err
} }
rts.sql = rts.RefreshTokenQuery.sqlQuery() rts.sql = rts.RefreshTokenQuery.sqlQuery(ctx)
return rts.sqlScan(ctx, v) return rts.sqlScan(ctx, v)
} }

View file

@ -7,11 +7,11 @@ import (
"fmt" "fmt"
"time" "time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/dexidp/dex/storage/ent/db/predicate" "github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/dexidp/dex/storage/ent/db/refreshtoken" "github.com/dexidp/dex/storage/ent/db/refreshtoken"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
) )
// RefreshTokenUpdate is the builder for updating RefreshToken entities. // RefreshTokenUpdate is the builder for updating RefreshToken entities.
@ -657,6 +657,13 @@ func (rtuo *RefreshTokenUpdateOne) sqlSave(ctx context.Context) (_node *RefreshT
return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing RefreshToken.ID for update")} return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing RefreshToken.ID for update")}
} }
_spec.Node.ID.Value = id _spec.Node.ID.Value = id
if ps := rtuo.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := rtuo.mutation.ClientID(); ok { if value, ok := rtuo.mutation.ClientID(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeString, Type: field.TypeString,

View file

@ -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.5.4" // Version of ent codegen. Version = "v0.7.0" // Version of ent codegen.
Sum = "h1:kIf2BQUdRJ7XrlTXzCyJCg69ar1K1FjFR2UQWRo/M8M=" // Sum of ent codegen. Sum = "h1:E3EjO0cUL61DvUg5ZEZdxa4yTL+4SuZv0LqBExo8CQA=" // Sum of ent codegen.
) )

View file

@ -6,7 +6,7 @@ import (
"context" "context"
"sync" "sync"
"github.com/facebook/ent/dialect" "entgo.io/ent/dialect"
) )
// Tx is a transactional client that is created by calling Client.Tx(). // Tx is a transactional client that is created by calling Client.Tx().

View file

@ -1,3 +1,3 @@
package ent package ent
//go:generate go run github.com/facebook/ent/cmd/entc generate ./schema --target ./db //go:generate go run -mod=mod entgo.io/ent/cmd/ent generate ./schema --target ./db

View file

@ -1,8 +1,8 @@
package schema package schema
import ( import (
"github.com/facebook/ent" "entgo.io/ent"
"github.com/facebook/ent/schema/field" "entgo.io/ent/schema/field"
) )
/* Original SQL table: /* Original SQL table:

View file

@ -1,8 +1,8 @@
package schema package schema
import ( import (
"github.com/facebook/ent" "entgo.io/ent"
"github.com/facebook/ent/schema/field" "entgo.io/ent/schema/field"
) )
/* Original SQL table: /* Original SQL table:

View file

@ -1,8 +1,8 @@
package schema package schema
import ( import (
"github.com/facebook/ent" "entgo.io/ent"
"github.com/facebook/ent/schema/field" "entgo.io/ent/schema/field"
) )
/* Original SQL table: /* Original SQL table:

View file

@ -1,8 +1,8 @@
package schema package schema
import ( import (
"github.com/facebook/ent" "entgo.io/ent"
"github.com/facebook/ent/schema/field" "entgo.io/ent/schema/field"
) )
/* Original SQL table: /* Original SQL table:

View file

@ -1,8 +1,8 @@
package schema package schema
import ( import (
"github.com/facebook/ent" "entgo.io/ent"
"github.com/facebook/ent/schema/field" "entgo.io/ent/schema/field"
) )
/* Original SQL table: /* Original SQL table:

View file

@ -1,8 +1,8 @@
package schema package schema
import ( import (
"github.com/facebook/ent" "entgo.io/ent"
"github.com/facebook/ent/schema/field" "entgo.io/ent/schema/field"
) )
/* Original SQL table: /* Original SQL table:

View file

@ -1,8 +1,8 @@
package schema package schema
import ( import (
"github.com/facebook/ent" "entgo.io/ent"
"github.com/facebook/ent/schema/field" "entgo.io/ent/schema/field"
"gopkg.in/square/go-jose.v2" "gopkg.in/square/go-jose.v2"
"github.com/dexidp/dex/storage" "github.com/dexidp/dex/storage"

View file

@ -1,8 +1,8 @@
package schema package schema
import ( import (
"github.com/facebook/ent" "entgo.io/ent"
"github.com/facebook/ent/schema/field" "entgo.io/ent/schema/field"
) )
/* Original SQL table: /* Original SQL table:

View file

@ -1,8 +1,8 @@
package schema package schema
import ( import (
"github.com/facebook/ent" "entgo.io/ent"
"github.com/facebook/ent/schema/field" "entgo.io/ent/schema/field"
) )
/* Original SQL table: /* Original SQL table:

View file

@ -3,8 +3,8 @@ package schema
import ( import (
"time" "time"
"github.com/facebook/ent" "entgo.io/ent"
"github.com/facebook/ent/schema/field" "entgo.io/ent/schema/field"
) )
/* Original SQL table: /* Original SQL table:

View file

@ -1,7 +1,7 @@
package schema package schema
import ( import (
"github.com/facebook/ent/dialect" "entgo.io/ent/dialect"
) )
var textSchema = map[string]string{ var textSchema = map[string]string{

View file

@ -5,7 +5,7 @@ import (
"crypto/sha256" "crypto/sha256"
"strings" "strings"
"github.com/facebook/ent/dialect/sql" "entgo.io/ent/dialect/sql"
// Register sqlite driver. // Register sqlite driver.
_ "github.com/mattn/go-sqlite3" _ "github.com/mattn/go-sqlite3"