feat: Verify generated files (#2833)

Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com>
This commit is contained in:
Maksim Nabokikh
2023-02-26 04:32:52 +04:00
committed by GitHub
parent fc0e2e9383
commit 5d7850eae5
73 changed files with 4019 additions and 8236 deletions
+3 -3
View File
@@ -124,6 +124,6 @@ jobs:
- name: Lint
run: make lint
# Ensure proto generation doesn't depend on external packages.
- name: Verify proto
run: make verify-proto
# Ensure that generated files were committed.
- name: Verify
run: make verify
+11 -5
View File
@@ -25,16 +25,22 @@ LD_FLAGS="-w -X main.version=$(VERSION)"
KIND_NODE_IMAGE = "kindest/node:v1.19.11@sha256:07db187ae84b4b7de440a73886f008cf903fcf5764ba8106a9fd5243d6f32729"
KIND_TMP_DIR = "$(PWD)/bin/test/dex-kind-kubeconfig"
.PHONY: generate
generate:
@go generate $(REPO_PATH)/storage/ent/
build: bin/dex
build: generate bin/dex
verify: verify-proto verify-ent
bin/dex:
@mkdir -p bin/
@go install -v -ldflags $(LD_FLAGS) $(REPO_PATH)/cmd/dex
.PHONY: ent-generate
ent-generate:
@go generate $(REPO_PATH)/storage/ent/
.PHONY: verify-ent
verify-ent: ent-generate
@./scripts/git-diff
examples: bin/grpc-client bin/example-app
bin/grpc-client:
@@ -47,7 +53,7 @@ bin/example-app:
.PHONY: release-binary
release-binary: LD_FLAGS = "-w -X main.version=$(VERSION) -extldflags \"-static\""
release-binary: generate
release-binary:
@go build -o /go/bin/dex -v -ldflags $(LD_FLAGS) $(REPO_PATH)/cmd/dex
@go build -o /go/bin/docker-entrypoint -v -ldflags $(LD_FLAGS) $(REPO_PATH)/cmd/docker-entrypoint
+3
View File
@@ -243,6 +243,7 @@ github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw=
github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/mattermost/xml-roundtrip-validator v0.1.0 h1:RXbVD2UAl7A7nOTR4u7E3ILa4IbtvKBHw64LDsmu9hU=
github.com/mattermost/xml-roundtrip-validator v0.1.0/go.mod h1:qccnGMcpgwcNaBnxqpJpWWUiPNr5H3O8eDgGV9gT5To=
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y=
github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
@@ -262,6 +263,7 @@ github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRW
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA=
github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU=
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
@@ -579,6 +581,7 @@ golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc
golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.3.1-0.20221202221704-aa9f4b2f3d57 h1:/X0t/E4VxbZE7MLS7auvE7YICHeVvbIa9vkOVvYW/24=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
-1
View File
@@ -1,5 +1,4 @@
#!/bin/sh -e
# Since this script will be run in a rkt container, use "/bin/sh" instead of "/bin/bash"
# parse the current git commit hash
COMMIT=`git rev-parse HEAD`
+4 -10
View File
@@ -50,8 +50,8 @@ type AuthCode struct {
}
// scanValues returns the types for scanning values from sql.Rows.
func (*AuthCode) scanValues(columns []string) ([]interface{}, error) {
values := make([]interface{}, len(columns))
func (*AuthCode) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case authcode.FieldScopes, authcode.FieldClaimsGroups, authcode.FieldConnectorData:
@@ -71,7 +71,7 @@ func (*AuthCode) scanValues(columns []string) ([]interface{}, error) {
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the AuthCode fields.
func (ac *AuthCode) assignValues(columns []string, values []interface{}) error {
func (ac *AuthCode) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
@@ -186,7 +186,7 @@ func (ac *AuthCode) assignValues(columns []string, values []interface{}) error {
// Note that you need to call AuthCode.Unwrap() before calling this method if this AuthCode
// was returned from a transaction, and the transaction was committed or rolled back.
func (ac *AuthCode) Update() *AuthCodeUpdateOne {
return (&AuthCodeClient{config: ac.config}).UpdateOne(ac)
return NewAuthCodeClient(ac.config).UpdateOne(ac)
}
// Unwrap unwraps the AuthCode entity that was returned from a transaction after it was closed,
@@ -257,9 +257,3 @@ func (ac *AuthCode) String() string {
// AuthCodes is a parsable slice of AuthCode.
type AuthCodes []*AuthCode
func (ac AuthCodes) config(cfg config) {
for _i := range ac {
ac[_i].config = cfg
}
}
File diff suppressed because it is too large Load Diff
+22 -125
View File
@@ -147,50 +147,8 @@ func (acc *AuthCodeCreate) Mutation() *AuthCodeMutation {
// Save creates the AuthCode in the database.
func (acc *AuthCodeCreate) Save(ctx context.Context) (*AuthCode, error) {
var (
err error
node *AuthCode
)
acc.defaults()
if len(acc.hooks) == 0 {
if err = acc.check(); err != nil {
return nil, err
}
node, err = acc.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*AuthCodeMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err = acc.check(); err != nil {
return nil, err
}
acc.mutation = mutation
if node, err = acc.sqlSave(ctx); err != nil {
return nil, err
}
mutation.id = &node.ID
mutation.done = true
return node, err
})
for i := len(acc.hooks) - 1; i >= 0; i-- {
if acc.hooks[i] == nil {
return nil, fmt.Errorf("db: uninitialized hook (forgotten import db/runtime?)")
}
mut = acc.hooks[i](mut)
}
v, err := mut.Mutate(ctx, acc.mutation)
if err != nil {
return nil, err
}
nv, ok := v.(*AuthCode)
if !ok {
return nil, fmt.Errorf("unexpected node type %T returned from AuthCodeMutation", v)
}
node = nv
}
return node, err
return withHooks[*AuthCode, AuthCodeMutation](ctx, acc.sqlSave, acc.mutation, acc.hooks)
}
// SaveX calls Save and panics if Save returns an error.
@@ -313,6 +271,9 @@ func (acc *AuthCodeCreate) check() error {
}
func (acc *AuthCodeCreate) sqlSave(ctx context.Context) (*AuthCode, error) {
if err := acc.check(); err != nil {
return nil, err
}
_node, _spec := acc.createSpec()
if err := sqlgraph.CreateNode(ctx, acc.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) {
@@ -327,142 +288,78 @@ func (acc *AuthCodeCreate) sqlSave(ctx context.Context) (*AuthCode, error) {
return nil, fmt.Errorf("unexpected AuthCode.ID type: %T", _spec.ID.Value)
}
}
acc.mutation.id = &_node.ID
acc.mutation.done = true
return _node, nil
}
func (acc *AuthCodeCreate) createSpec() (*AuthCode, *sqlgraph.CreateSpec) {
var (
_node = &AuthCode{config: acc.config}
_spec = &sqlgraph.CreateSpec{
Table: authcode.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeString,
Column: authcode.FieldID,
},
}
_spec = sqlgraph.NewCreateSpec(authcode.Table, sqlgraph.NewFieldSpec(authcode.FieldID, field.TypeString))
)
if id, ok := acc.mutation.ID(); ok {
_node.ID = id
_spec.ID.Value = id
}
if value, ok := acc.mutation.ClientID(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: authcode.FieldClientID,
})
_spec.SetField(authcode.FieldClientID, field.TypeString, value)
_node.ClientID = value
}
if value, ok := acc.mutation.Scopes(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeJSON,
Value: value,
Column: authcode.FieldScopes,
})
_spec.SetField(authcode.FieldScopes, field.TypeJSON, value)
_node.Scopes = value
}
if value, ok := acc.mutation.Nonce(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: authcode.FieldNonce,
})
_spec.SetField(authcode.FieldNonce, field.TypeString, value)
_node.Nonce = value
}
if value, ok := acc.mutation.RedirectURI(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: authcode.FieldRedirectURI,
})
_spec.SetField(authcode.FieldRedirectURI, field.TypeString, value)
_node.RedirectURI = value
}
if value, ok := acc.mutation.ClaimsUserID(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: authcode.FieldClaimsUserID,
})
_spec.SetField(authcode.FieldClaimsUserID, field.TypeString, value)
_node.ClaimsUserID = value
}
if value, ok := acc.mutation.ClaimsUsername(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: authcode.FieldClaimsUsername,
})
_spec.SetField(authcode.FieldClaimsUsername, field.TypeString, value)
_node.ClaimsUsername = value
}
if value, ok := acc.mutation.ClaimsEmail(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: authcode.FieldClaimsEmail,
})
_spec.SetField(authcode.FieldClaimsEmail, field.TypeString, value)
_node.ClaimsEmail = value
}
if value, ok := acc.mutation.ClaimsEmailVerified(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeBool,
Value: value,
Column: authcode.FieldClaimsEmailVerified,
})
_spec.SetField(authcode.FieldClaimsEmailVerified, field.TypeBool, value)
_node.ClaimsEmailVerified = value
}
if value, ok := acc.mutation.ClaimsGroups(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeJSON,
Value: value,
Column: authcode.FieldClaimsGroups,
})
_spec.SetField(authcode.FieldClaimsGroups, field.TypeJSON, value)
_node.ClaimsGroups = value
}
if value, ok := acc.mutation.ClaimsPreferredUsername(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: authcode.FieldClaimsPreferredUsername,
})
_spec.SetField(authcode.FieldClaimsPreferredUsername, field.TypeString, value)
_node.ClaimsPreferredUsername = value
}
if value, ok := acc.mutation.ConnectorID(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: authcode.FieldConnectorID,
})
_spec.SetField(authcode.FieldConnectorID, field.TypeString, value)
_node.ConnectorID = value
}
if value, ok := acc.mutation.ConnectorData(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeBytes,
Value: value,
Column: authcode.FieldConnectorData,
})
_spec.SetField(authcode.FieldConnectorData, field.TypeBytes, value)
_node.ConnectorData = &value
}
if value, ok := acc.mutation.Expiry(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeTime,
Value: value,
Column: authcode.FieldExpiry,
})
_spec.SetField(authcode.FieldExpiry, field.TypeTime, value)
_node.Expiry = value
}
if value, ok := acc.mutation.CodeChallenge(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: authcode.FieldCodeChallenge,
})
_spec.SetField(authcode.FieldCodeChallenge, field.TypeString, value)
_node.CodeChallenge = value
}
if value, ok := acc.mutation.CodeChallengeMethod(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: authcode.FieldCodeChallengeMethod,
})
_spec.SetField(authcode.FieldCodeChallengeMethod, field.TypeString, value)
_node.CodeChallengeMethod = value
}
return _node, _spec
+12 -39
View File
@@ -4,7 +4,6 @@ package db
import (
"context"
"fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
@@ -28,34 +27,7 @@ func (acd *AuthCodeDelete) Where(ps ...predicate.AuthCode) *AuthCodeDelete {
// Exec executes the deletion query and returns how many vertices were deleted.
func (acd *AuthCodeDelete) Exec(ctx context.Context) (int, error) {
var (
err error
affected int
)
if len(acd.hooks) == 0 {
affected, err = acd.sqlExec(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*AuthCodeMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
acd.mutation = mutation
affected, err = acd.sqlExec(ctx)
mutation.done = true
return affected, err
})
for i := len(acd.hooks) - 1; i >= 0; i-- {
if acd.hooks[i] == nil {
return 0, fmt.Errorf("db: uninitialized hook (forgotten import db/runtime?)")
}
mut = acd.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, acd.mutation); err != nil {
return 0, err
}
}
return affected, err
return withHooks[int, AuthCodeMutation](ctx, acd.sqlExec, acd.mutation, acd.hooks)
}
// ExecX is like Exec, but panics if an error occurs.
@@ -68,15 +40,7 @@ func (acd *AuthCodeDelete) ExecX(ctx context.Context) int {
}
func (acd *AuthCodeDelete) sqlExec(ctx context.Context) (int, error) {
_spec := &sqlgraph.DeleteSpec{
Node: &sqlgraph.NodeSpec{
Table: authcode.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeString,
Column: authcode.FieldID,
},
},
}
_spec := sqlgraph.NewDeleteSpec(authcode.Table, sqlgraph.NewFieldSpec(authcode.FieldID, field.TypeString))
if ps := acd.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
@@ -88,6 +52,7 @@ func (acd *AuthCodeDelete) sqlExec(ctx context.Context) (int, error) {
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
acd.mutation.done = true
return affected, err
}
@@ -96,6 +61,12 @@ type AuthCodeDeleteOne struct {
acd *AuthCodeDelete
}
// Where appends a list predicates to the AuthCodeDelete builder.
func (acdo *AuthCodeDeleteOne) Where(ps ...predicate.AuthCode) *AuthCodeDeleteOne {
acdo.acd.mutation.Where(ps...)
return acdo
}
// Exec executes the deletion query.
func (acdo *AuthCodeDeleteOne) Exec(ctx context.Context) error {
n, err := acdo.acd.Exec(ctx)
@@ -111,5 +82,7 @@ func (acdo *AuthCodeDeleteOne) Exec(ctx context.Context) error {
// ExecX is like Exec, but panics if an error occurs.
func (acdo *AuthCodeDeleteOne) ExecX(ctx context.Context) {
acdo.acd.ExecX(ctx)
if err := acdo.Exec(ctx); err != nil {
panic(err)
}
}
+120 -122
View File
@@ -17,11 +17,9 @@ import (
// AuthCodeQuery is the builder for querying AuthCode entities.
type AuthCodeQuery struct {
config
limit *int
offset *int
unique *bool
ctx *QueryContext
order []OrderFunc
fields []string
inters []Interceptor
predicates []predicate.AuthCode
// intermediate query (i.e. traversal path).
sql *sql.Selector
@@ -34,26 +32,26 @@ func (acq *AuthCodeQuery) Where(ps ...predicate.AuthCode) *AuthCodeQuery {
return acq
}
// Limit adds a limit step to the query.
// Limit the number of records to be returned by this query.
func (acq *AuthCodeQuery) Limit(limit int) *AuthCodeQuery {
acq.limit = &limit
acq.ctx.Limit = &limit
return acq
}
// Offset adds an offset step to the query.
// Offset to start from.
func (acq *AuthCodeQuery) Offset(offset int) *AuthCodeQuery {
acq.offset = &offset
acq.ctx.Offset = &offset
return acq
}
// Unique configures the query builder to filter duplicate records on query.
// By default, unique is set to true, and can be disabled using this method.
func (acq *AuthCodeQuery) Unique(unique bool) *AuthCodeQuery {
acq.unique = &unique
acq.ctx.Unique = &unique
return acq
}
// Order adds an order step to the query.
// Order specifies how the records should be ordered.
func (acq *AuthCodeQuery) Order(o ...OrderFunc) *AuthCodeQuery {
acq.order = append(acq.order, o...)
return acq
@@ -62,7 +60,7 @@ func (acq *AuthCodeQuery) Order(o ...OrderFunc) *AuthCodeQuery {
// First returns the first AuthCode entity from the query.
// Returns a *NotFoundError when no AuthCode was found.
func (acq *AuthCodeQuery) First(ctx context.Context) (*AuthCode, error) {
nodes, err := acq.Limit(1).All(ctx)
nodes, err := acq.Limit(1).All(setContextOp(ctx, acq.ctx, "First"))
if err != nil {
return nil, err
}
@@ -85,7 +83,7 @@ func (acq *AuthCodeQuery) FirstX(ctx context.Context) *AuthCode {
// Returns a *NotFoundError when no AuthCode ID was found.
func (acq *AuthCodeQuery) FirstID(ctx context.Context) (id string, err error) {
var ids []string
if ids, err = acq.Limit(1).IDs(ctx); err != nil {
if ids, err = acq.Limit(1).IDs(setContextOp(ctx, acq.ctx, "FirstID")); err != nil {
return
}
if len(ids) == 0 {
@@ -108,7 +106,7 @@ func (acq *AuthCodeQuery) FirstIDX(ctx context.Context) string {
// Returns a *NotSingularError when more than one AuthCode entity is found.
// Returns a *NotFoundError when no AuthCode entities are found.
func (acq *AuthCodeQuery) Only(ctx context.Context) (*AuthCode, error) {
nodes, err := acq.Limit(2).All(ctx)
nodes, err := acq.Limit(2).All(setContextOp(ctx, acq.ctx, "Only"))
if err != nil {
return nil, err
}
@@ -136,7 +134,7 @@ func (acq *AuthCodeQuery) OnlyX(ctx context.Context) *AuthCode {
// Returns a *NotFoundError when no entities are found.
func (acq *AuthCodeQuery) OnlyID(ctx context.Context) (id string, err error) {
var ids []string
if ids, err = acq.Limit(2).IDs(ctx); err != nil {
if ids, err = acq.Limit(2).IDs(setContextOp(ctx, acq.ctx, "OnlyID")); err != nil {
return
}
switch len(ids) {
@@ -161,10 +159,12 @@ func (acq *AuthCodeQuery) OnlyIDX(ctx context.Context) string {
// All executes the query and returns a list of AuthCodes.
func (acq *AuthCodeQuery) All(ctx context.Context) ([]*AuthCode, error) {
ctx = setContextOp(ctx, acq.ctx, "All")
if err := acq.prepareQuery(ctx); err != nil {
return nil, err
}
return acq.sqlAll(ctx)
qr := querierAll[[]*AuthCode, *AuthCodeQuery]()
return withInterceptors[[]*AuthCode](ctx, acq, qr, acq.inters)
}
// AllX is like All, but panics if an error occurs.
@@ -177,9 +177,12 @@ func (acq *AuthCodeQuery) AllX(ctx context.Context) []*AuthCode {
}
// IDs executes the query and returns a list of AuthCode IDs.
func (acq *AuthCodeQuery) IDs(ctx context.Context) ([]string, error) {
var ids []string
if err := acq.Select(authcode.FieldID).Scan(ctx, &ids); err != nil {
func (acq *AuthCodeQuery) IDs(ctx context.Context) (ids []string, err error) {
if acq.ctx.Unique == nil && acq.path != nil {
acq.Unique(true)
}
ctx = setContextOp(ctx, acq.ctx, "IDs")
if err = acq.Select(authcode.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
return ids, nil
@@ -196,10 +199,11 @@ func (acq *AuthCodeQuery) IDsX(ctx context.Context) []string {
// Count returns the count of the given query.
func (acq *AuthCodeQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, acq.ctx, "Count")
if err := acq.prepareQuery(ctx); err != nil {
return 0, err
}
return acq.sqlCount(ctx)
return withInterceptors[int](ctx, acq, querierCount[*AuthCodeQuery](), acq.inters)
}
// CountX is like Count, but panics if an error occurs.
@@ -213,10 +217,15 @@ func (acq *AuthCodeQuery) CountX(ctx context.Context) int {
// Exist returns true if the query has elements in the graph.
func (acq *AuthCodeQuery) Exist(ctx context.Context) (bool, error) {
if err := acq.prepareQuery(ctx); err != nil {
return false, err
ctx = setContextOp(ctx, acq.ctx, "Exist")
switch _, err := acq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("db: check existence: %w", err)
default:
return true, nil
}
return acq.sqlExist(ctx)
}
// ExistX is like Exist, but panics if an error occurs.
@@ -236,14 +245,13 @@ func (acq *AuthCodeQuery) Clone() *AuthCodeQuery {
}
return &AuthCodeQuery{
config: acq.config,
limit: acq.limit,
offset: acq.offset,
ctx: acq.ctx.Clone(),
order: append([]OrderFunc{}, acq.order...),
inters: append([]Interceptor{}, acq.inters...),
predicates: append([]predicate.AuthCode{}, acq.predicates...),
// clone intermediate query.
sql: acq.sql.Clone(),
path: acq.path,
unique: acq.unique,
sql: acq.sql.Clone(),
path: acq.path,
}
}
@@ -261,18 +269,12 @@ func (acq *AuthCodeQuery) Clone() *AuthCodeQuery {
// GroupBy(authcode.FieldClientID).
// Aggregate(db.Count()).
// Scan(ctx, &v)
//
func (acq *AuthCodeQuery) GroupBy(field string, fields ...string) *AuthCodeGroupBy {
grbuild := &AuthCodeGroupBy{config: acq.config}
grbuild.fields = append([]string{field}, fields...)
grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) {
if err := acq.prepareQuery(ctx); err != nil {
return nil, err
}
return acq.sqlQuery(ctx), nil
}
acq.ctx.Fields = append([]string{field}, fields...)
grbuild := &AuthCodeGroupBy{build: acq}
grbuild.flds = &acq.ctx.Fields
grbuild.label = authcode.Label
grbuild.flds, grbuild.scan = &grbuild.fields, grbuild.Scan
grbuild.scan = grbuild.Scan
return grbuild
}
@@ -288,17 +290,31 @@ func (acq *AuthCodeQuery) GroupBy(field string, fields ...string) *AuthCodeGroup
// client.AuthCode.Query().
// Select(authcode.FieldClientID).
// Scan(ctx, &v)
//
func (acq *AuthCodeQuery) Select(fields ...string) *AuthCodeSelect {
acq.fields = append(acq.fields, fields...)
selbuild := &AuthCodeSelect{AuthCodeQuery: acq}
selbuild.label = authcode.Label
selbuild.flds, selbuild.scan = &acq.fields, selbuild.Scan
return selbuild
acq.ctx.Fields = append(acq.ctx.Fields, fields...)
sbuild := &AuthCodeSelect{AuthCodeQuery: acq}
sbuild.label = authcode.Label
sbuild.flds, sbuild.scan = &acq.ctx.Fields, sbuild.Scan
return sbuild
}
// Aggregate returns a AuthCodeSelect configured with the given aggregations.
func (acq *AuthCodeQuery) Aggregate(fns ...AggregateFunc) *AuthCodeSelect {
return acq.Select().Aggregate(fns...)
}
func (acq *AuthCodeQuery) prepareQuery(ctx context.Context) error {
for _, f := range acq.fields {
for _, inter := range acq.inters {
if inter == nil {
return fmt.Errorf("db: uninitialized interceptor (forgotten import db/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, acq); err != nil {
return err
}
}
}
for _, f := range acq.ctx.Fields {
if !authcode.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)}
}
@@ -318,10 +334,10 @@ func (acq *AuthCodeQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Au
nodes = []*AuthCode{}
_spec = acq.querySpec()
)
_spec.ScanValues = func(columns []string) ([]interface{}, error) {
_spec.ScanValues = func(columns []string) ([]any, error) {
return (*AuthCode).scanValues(nil, columns)
}
_spec.Assign = func(columns []string, values []interface{}) error {
_spec.Assign = func(columns []string, values []any) error {
node := &AuthCode{config: acq.config}
nodes = append(nodes, node)
return node.assignValues(columns, values)
@@ -340,38 +356,22 @@ func (acq *AuthCodeQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Au
func (acq *AuthCodeQuery) sqlCount(ctx context.Context) (int, error) {
_spec := acq.querySpec()
_spec.Node.Columns = acq.fields
if len(acq.fields) > 0 {
_spec.Unique = acq.unique != nil && *acq.unique
_spec.Node.Columns = acq.ctx.Fields
if len(acq.ctx.Fields) > 0 {
_spec.Unique = acq.ctx.Unique != nil && *acq.ctx.Unique
}
return sqlgraph.CountNodes(ctx, acq.driver, _spec)
}
func (acq *AuthCodeQuery) sqlExist(ctx context.Context) (bool, error) {
n, err := acq.sqlCount(ctx)
if err != nil {
return false, fmt.Errorf("db: check existence: %w", err)
}
return n > 0, nil
}
func (acq *AuthCodeQuery) querySpec() *sqlgraph.QuerySpec {
_spec := &sqlgraph.QuerySpec{
Node: &sqlgraph.NodeSpec{
Table: authcode.Table,
Columns: authcode.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeString,
Column: authcode.FieldID,
},
},
From: acq.sql,
Unique: true,
}
if unique := acq.unique; unique != nil {
_spec := sqlgraph.NewQuerySpec(authcode.Table, authcode.Columns, sqlgraph.NewFieldSpec(authcode.FieldID, field.TypeString))
_spec.From = acq.sql
if unique := acq.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if acq.path != nil {
_spec.Unique = true
}
if fields := acq.fields; len(fields) > 0 {
if fields := acq.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, authcode.FieldID)
for i := range fields {
@@ -387,10 +387,10 @@ func (acq *AuthCodeQuery) querySpec() *sqlgraph.QuerySpec {
}
}
}
if limit := acq.limit; limit != nil {
if limit := acq.ctx.Limit; limit != nil {
_spec.Limit = *limit
}
if offset := acq.offset; offset != nil {
if offset := acq.ctx.Offset; offset != nil {
_spec.Offset = *offset
}
if ps := acq.order; len(ps) > 0 {
@@ -406,7 +406,7 @@ func (acq *AuthCodeQuery) querySpec() *sqlgraph.QuerySpec {
func (acq *AuthCodeQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(acq.driver.Dialect())
t1 := builder.Table(authcode.Table)
columns := acq.fields
columns := acq.ctx.Fields
if len(columns) == 0 {
columns = authcode.Columns
}
@@ -415,7 +415,7 @@ func (acq *AuthCodeQuery) sqlQuery(ctx context.Context) *sql.Selector {
selector = acq.sql
selector.Select(selector.Columns(columns...)...)
}
if acq.unique != nil && *acq.unique {
if acq.ctx.Unique != nil && *acq.ctx.Unique {
selector.Distinct()
}
for _, p := range acq.predicates {
@@ -424,12 +424,12 @@ func (acq *AuthCodeQuery) sqlQuery(ctx context.Context) *sql.Selector {
for _, p := range acq.order {
p(selector)
}
if offset := acq.offset; offset != nil {
if offset := acq.ctx.Offset; offset != nil {
// limit is mandatory for offset clause. We start
// with default value, and override it below if needed.
selector.Offset(*offset).Limit(math.MaxInt32)
}
if limit := acq.limit; limit != nil {
if limit := acq.ctx.Limit; limit != nil {
selector.Limit(*limit)
}
return selector
@@ -437,13 +437,8 @@ func (acq *AuthCodeQuery) sqlQuery(ctx context.Context) *sql.Selector {
// AuthCodeGroupBy is the group-by builder for AuthCode entities.
type AuthCodeGroupBy struct {
config
selector
fields []string
fns []AggregateFunc
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
build *AuthCodeQuery
}
// Aggregate adds the given aggregation functions to the group-by query.
@@ -452,74 +447,77 @@ func (acgb *AuthCodeGroupBy) Aggregate(fns ...AggregateFunc) *AuthCodeGroupBy {
return acgb
}
// Scan applies the group-by query and scans the result into the given value.
func (acgb *AuthCodeGroupBy) Scan(ctx context.Context, v interface{}) error {
query, err := acgb.path(ctx)
if err != nil {
// Scan applies the selector query and scans the result into the given value.
func (acgb *AuthCodeGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, acgb.build.ctx, "GroupBy")
if err := acgb.build.prepareQuery(ctx); err != nil {
return err
}
acgb.sql = query
return acgb.sqlScan(ctx, v)
return scanWithInterceptors[*AuthCodeQuery, *AuthCodeGroupBy](ctx, acgb.build, acgb, acgb.build.inters, v)
}
func (acgb *AuthCodeGroupBy) sqlScan(ctx context.Context, v interface{}) error {
for _, f := range acgb.fields {
if !authcode.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)}
}
}
selector := acgb.sqlQuery()
if err := selector.Err(); err != nil {
return err
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := acgb.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
func (acgb *AuthCodeGroupBy) sqlQuery() *sql.Selector {
selector := acgb.sql.Select()
func (acgb *AuthCodeGroupBy) sqlScan(ctx context.Context, root *AuthCodeQuery, v any) error {
selector := root.sqlQuery(ctx).Select()
aggregation := make([]string, 0, len(acgb.fns))
for _, fn := range acgb.fns {
aggregation = append(aggregation, fn(selector))
}
// If no columns were selected in a custom aggregation function, the default
// selection is the fields used for "group-by", and the aggregation functions.
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(acgb.fields)+len(acgb.fns))
for _, f := range acgb.fields {
columns := make([]string, 0, len(*acgb.flds)+len(acgb.fns))
for _, f := range *acgb.flds {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
return selector.GroupBy(selector.Columns(acgb.fields...)...)
selector.GroupBy(selector.Columns(*acgb.flds...)...)
if err := selector.Err(); err != nil {
return err
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := acgb.build.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
// AuthCodeSelect is the builder for selecting fields of AuthCode entities.
type AuthCodeSelect struct {
*AuthCodeQuery
selector
// intermediate query (i.e. traversal path).
sql *sql.Selector
}
// Aggregate adds the given aggregation functions to the selector query.
func (acs *AuthCodeSelect) Aggregate(fns ...AggregateFunc) *AuthCodeSelect {
acs.fns = append(acs.fns, fns...)
return acs
}
// Scan applies the selector query and scans the result into the given value.
func (acs *AuthCodeSelect) Scan(ctx context.Context, v interface{}) error {
func (acs *AuthCodeSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, acs.ctx, "Select")
if err := acs.prepareQuery(ctx); err != nil {
return err
}
acs.sql = acs.AuthCodeQuery.sqlQuery(ctx)
return acs.sqlScan(ctx, v)
return scanWithInterceptors[*AuthCodeQuery, *AuthCodeSelect](ctx, acs.AuthCodeQuery, acs, acs.inters, v)
}
func (acs *AuthCodeSelect) sqlScan(ctx context.Context, v interface{}) error {
func (acs *AuthCodeSelect) sqlScan(ctx context.Context, root *AuthCodeQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(acs.fns))
for _, fn := range acs.fns {
aggregation = append(aggregation, fn(selector))
}
switch n := len(*acs.selector.flds); {
case n == 0 && len(aggregation) > 0:
selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0:
selector.AppendSelect(aggregation...)
}
rows := &sql.Rows{}
query, args := acs.sql.Query()
query, args := selector.Query()
if err := acs.driver.Query(ctx, query, args, rows); err != nil {
return err
}
File diff suppressed because it is too large Load Diff
+6 -11
View File
@@ -60,8 +60,8 @@ type AuthRequest struct {
}
// scanValues returns the types for scanning values from sql.Rows.
func (*AuthRequest) scanValues(columns []string) ([]interface{}, error) {
values := make([]interface{}, len(columns))
func (*AuthRequest) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case authrequest.FieldScopes, authrequest.FieldResponseTypes, authrequest.FieldClaimsGroups, authrequest.FieldConnectorData, authrequest.FieldHmacKey:
@@ -81,7 +81,7 @@ func (*AuthRequest) scanValues(columns []string) ([]interface{}, error) {
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the AuthRequest fields.
func (ar *AuthRequest) assignValues(columns []string, values []interface{}) error {
func (ar *AuthRequest) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
@@ -228,7 +228,7 @@ func (ar *AuthRequest) assignValues(columns []string, values []interface{}) erro
// Note that you need to call AuthRequest.Unwrap() before calling this method if this AuthRequest
// was returned from a transaction, and the transaction was committed or rolled back.
func (ar *AuthRequest) Update() *AuthRequestUpdateOne {
return (&AuthRequestClient{config: ar.config}).UpdateOne(ar)
return NewAuthRequestClient(ar.config).UpdateOne(ar)
}
// Unwrap unwraps the AuthRequest entity that was returned from a transaction after it was closed,
@@ -305,7 +305,8 @@ func (ar *AuthRequest) String() string {
builder.WriteString(", ")
builder.WriteString("code_challenge_method=")
builder.WriteString(ar.CodeChallengeMethod)
builder.WriteString(", hmac_key=")
builder.WriteString(", ")
builder.WriteString("hmac_key=")
builder.WriteString(fmt.Sprintf("%v", ar.HmacKey))
builder.WriteByte(')')
return builder.String()
@@ -313,9 +314,3 @@ func (ar *AuthRequest) String() string {
// AuthRequests is a parsable slice of AuthRequest.
type AuthRequests []*AuthRequest
func (ar AuthRequests) config(cfg config) {
for _i := range ar {
ar[_i].config = cfg
}
}
File diff suppressed because it is too large Load Diff
+27 -150
View File
@@ -177,50 +177,8 @@ func (arc *AuthRequestCreate) Mutation() *AuthRequestMutation {
// Save creates the AuthRequest in the database.
func (arc *AuthRequestCreate) Save(ctx context.Context) (*AuthRequest, error) {
var (
err error
node *AuthRequest
)
arc.defaults()
if len(arc.hooks) == 0 {
if err = arc.check(); err != nil {
return nil, err
}
node, err = arc.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*AuthRequestMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err = arc.check(); err != nil {
return nil, err
}
arc.mutation = mutation
if node, err = arc.sqlSave(ctx); err != nil {
return nil, err
}
mutation.id = &node.ID
mutation.done = true
return node, err
})
for i := len(arc.hooks) - 1; i >= 0; i-- {
if arc.hooks[i] == nil {
return nil, fmt.Errorf("db: uninitialized hook (forgotten import db/runtime?)")
}
mut = arc.hooks[i](mut)
}
v, err := mut.Mutate(ctx, arc.mutation)
if err != nil {
return nil, err
}
nv, ok := v.(*AuthRequest)
if !ok {
return nil, fmt.Errorf("unexpected node type %T returned from AuthRequestMutation", v)
}
node = nv
}
return node, err
return withHooks[*AuthRequest, AuthRequestMutation](ctx, arc.sqlSave, arc.mutation, arc.hooks)
}
// SaveX calls Save and panics if Save returns an error.
@@ -320,6 +278,9 @@ func (arc *AuthRequestCreate) check() error {
}
func (arc *AuthRequestCreate) sqlSave(ctx context.Context) (*AuthRequest, error) {
if err := arc.check(); err != nil {
return nil, err
}
_node, _spec := arc.createSpec()
if err := sqlgraph.CreateNode(ctx, arc.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) {
@@ -334,182 +295,98 @@ func (arc *AuthRequestCreate) sqlSave(ctx context.Context) (*AuthRequest, error)
return nil, fmt.Errorf("unexpected AuthRequest.ID type: %T", _spec.ID.Value)
}
}
arc.mutation.id = &_node.ID
arc.mutation.done = true
return _node, nil
}
func (arc *AuthRequestCreate) createSpec() (*AuthRequest, *sqlgraph.CreateSpec) {
var (
_node = &AuthRequest{config: arc.config}
_spec = &sqlgraph.CreateSpec{
Table: authrequest.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeString,
Column: authrequest.FieldID,
},
}
_spec = sqlgraph.NewCreateSpec(authrequest.Table, sqlgraph.NewFieldSpec(authrequest.FieldID, field.TypeString))
)
if id, ok := arc.mutation.ID(); ok {
_node.ID = id
_spec.ID.Value = id
}
if value, ok := arc.mutation.ClientID(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: authrequest.FieldClientID,
})
_spec.SetField(authrequest.FieldClientID, field.TypeString, value)
_node.ClientID = value
}
if value, ok := arc.mutation.Scopes(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeJSON,
Value: value,
Column: authrequest.FieldScopes,
})
_spec.SetField(authrequest.FieldScopes, field.TypeJSON, value)
_node.Scopes = value
}
if value, ok := arc.mutation.ResponseTypes(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeJSON,
Value: value,
Column: authrequest.FieldResponseTypes,
})
_spec.SetField(authrequest.FieldResponseTypes, field.TypeJSON, value)
_node.ResponseTypes = value
}
if value, ok := arc.mutation.RedirectURI(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: authrequest.FieldRedirectURI,
})
_spec.SetField(authrequest.FieldRedirectURI, field.TypeString, value)
_node.RedirectURI = value
}
if value, ok := arc.mutation.Nonce(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: authrequest.FieldNonce,
})
_spec.SetField(authrequest.FieldNonce, field.TypeString, value)
_node.Nonce = value
}
if value, ok := arc.mutation.State(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: authrequest.FieldState,
})
_spec.SetField(authrequest.FieldState, field.TypeString, value)
_node.State = value
}
if value, ok := arc.mutation.ForceApprovalPrompt(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeBool,
Value: value,
Column: authrequest.FieldForceApprovalPrompt,
})
_spec.SetField(authrequest.FieldForceApprovalPrompt, field.TypeBool, value)
_node.ForceApprovalPrompt = value
}
if value, ok := arc.mutation.LoggedIn(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeBool,
Value: value,
Column: authrequest.FieldLoggedIn,
})
_spec.SetField(authrequest.FieldLoggedIn, field.TypeBool, value)
_node.LoggedIn = value
}
if value, ok := arc.mutation.ClaimsUserID(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: authrequest.FieldClaimsUserID,
})
_spec.SetField(authrequest.FieldClaimsUserID, field.TypeString, value)
_node.ClaimsUserID = value
}
if value, ok := arc.mutation.ClaimsUsername(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: authrequest.FieldClaimsUsername,
})
_spec.SetField(authrequest.FieldClaimsUsername, field.TypeString, value)
_node.ClaimsUsername = value
}
if value, ok := arc.mutation.ClaimsEmail(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: authrequest.FieldClaimsEmail,
})
_spec.SetField(authrequest.FieldClaimsEmail, field.TypeString, value)
_node.ClaimsEmail = value
}
if value, ok := arc.mutation.ClaimsEmailVerified(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeBool,
Value: value,
Column: authrequest.FieldClaimsEmailVerified,
})
_spec.SetField(authrequest.FieldClaimsEmailVerified, field.TypeBool, value)
_node.ClaimsEmailVerified = value
}
if value, ok := arc.mutation.ClaimsGroups(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeJSON,
Value: value,
Column: authrequest.FieldClaimsGroups,
})
_spec.SetField(authrequest.FieldClaimsGroups, field.TypeJSON, value)
_node.ClaimsGroups = value
}
if value, ok := arc.mutation.ClaimsPreferredUsername(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: authrequest.FieldClaimsPreferredUsername,
})
_spec.SetField(authrequest.FieldClaimsPreferredUsername, field.TypeString, value)
_node.ClaimsPreferredUsername = value
}
if value, ok := arc.mutation.ConnectorID(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: authrequest.FieldConnectorID,
})
_spec.SetField(authrequest.FieldConnectorID, field.TypeString, value)
_node.ConnectorID = value
}
if value, ok := arc.mutation.ConnectorData(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeBytes,
Value: value,
Column: authrequest.FieldConnectorData,
})
_spec.SetField(authrequest.FieldConnectorData, field.TypeBytes, value)
_node.ConnectorData = &value
}
if value, ok := arc.mutation.Expiry(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeTime,
Value: value,
Column: authrequest.FieldExpiry,
})
_spec.SetField(authrequest.FieldExpiry, field.TypeTime, value)
_node.Expiry = value
}
if value, ok := arc.mutation.CodeChallenge(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: authrequest.FieldCodeChallenge,
})
_spec.SetField(authrequest.FieldCodeChallenge, field.TypeString, value)
_node.CodeChallenge = value
}
if value, ok := arc.mutation.CodeChallengeMethod(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: authrequest.FieldCodeChallengeMethod,
})
_spec.SetField(authrequest.FieldCodeChallengeMethod, field.TypeString, value)
_node.CodeChallengeMethod = value
}
if value, ok := arc.mutation.HmacKey(); ok {
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
Type: field.TypeBytes,
Value: value,
Column: authrequest.FieldHmacKey,
})
_spec.SetField(authrequest.FieldHmacKey, field.TypeBytes, value)
_node.HmacKey = value
}
return _node, _spec
+12 -39
View File
@@ -4,7 +4,6 @@ package db
import (
"context"
"fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
@@ -28,34 +27,7 @@ func (ard *AuthRequestDelete) Where(ps ...predicate.AuthRequest) *AuthRequestDel
// Exec executes the deletion query and returns how many vertices were deleted.
func (ard *AuthRequestDelete) Exec(ctx context.Context) (int, error) {
var (
err error
affected int
)
if len(ard.hooks) == 0 {
affected, err = ard.sqlExec(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*AuthRequestMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
ard.mutation = mutation
affected, err = ard.sqlExec(ctx)
mutation.done = true
return affected, err
})
for i := len(ard.hooks) - 1; i >= 0; i-- {
if ard.hooks[i] == nil {
return 0, fmt.Errorf("db: uninitialized hook (forgotten import db/runtime?)")
}
mut = ard.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, ard.mutation); err != nil {
return 0, err
}
}
return affected, err
return withHooks[int, AuthRequestMutation](ctx, ard.sqlExec, ard.mutation, ard.hooks)
}
// ExecX is like Exec, but panics if an error occurs.
@@ -68,15 +40,7 @@ func (ard *AuthRequestDelete) ExecX(ctx context.Context) int {
}
func (ard *AuthRequestDelete) sqlExec(ctx context.Context) (int, error) {
_spec := &sqlgraph.DeleteSpec{
Node: &sqlgraph.NodeSpec{
Table: authrequest.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeString,
Column: authrequest.FieldID,
},
},
}
_spec := sqlgraph.NewDeleteSpec(authrequest.Table, sqlgraph.NewFieldSpec(authrequest.FieldID, field.TypeString))
if ps := ard.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
@@ -88,6 +52,7 @@ func (ard *AuthRequestDelete) sqlExec(ctx context.Context) (int, error) {
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
ard.mutation.done = true
return affected, err
}
@@ -96,6 +61,12 @@ type AuthRequestDeleteOne struct {
ard *AuthRequestDelete
}
// Where appends a list predicates to the AuthRequestDelete builder.
func (ardo *AuthRequestDeleteOne) Where(ps ...predicate.AuthRequest) *AuthRequestDeleteOne {
ardo.ard.mutation.Where(ps...)
return ardo
}
// Exec executes the deletion query.
func (ardo *AuthRequestDeleteOne) Exec(ctx context.Context) error {
n, err := ardo.ard.Exec(ctx)
@@ -111,5 +82,7 @@ func (ardo *AuthRequestDeleteOne) Exec(ctx context.Context) error {
// ExecX is like Exec, but panics if an error occurs.
func (ardo *AuthRequestDeleteOne) ExecX(ctx context.Context) {
ardo.ard.ExecX(ctx)
if err := ardo.Exec(ctx); err != nil {
panic(err)
}
}
+120 -122
View File
@@ -17,11 +17,9 @@ import (
// AuthRequestQuery is the builder for querying AuthRequest entities.
type AuthRequestQuery struct {
config
limit *int
offset *int
unique *bool
ctx *QueryContext
order []OrderFunc
fields []string
inters []Interceptor
predicates []predicate.AuthRequest
// intermediate query (i.e. traversal path).
sql *sql.Selector
@@ -34,26 +32,26 @@ func (arq *AuthRequestQuery) Where(ps ...predicate.AuthRequest) *AuthRequestQuer
return arq
}
// Limit adds a limit step to the query.
// Limit the number of records to be returned by this query.
func (arq *AuthRequestQuery) Limit(limit int) *AuthRequestQuery {
arq.limit = &limit
arq.ctx.Limit = &limit
return arq
}
// Offset adds an offset step to the query.
// Offset to start from.
func (arq *AuthRequestQuery) Offset(offset int) *AuthRequestQuery {
arq.offset = &offset
arq.ctx.Offset = &offset
return arq
}
// Unique configures the query builder to filter duplicate records on query.
// By default, unique is set to true, and can be disabled using this method.
func (arq *AuthRequestQuery) Unique(unique bool) *AuthRequestQuery {
arq.unique = &unique
arq.ctx.Unique = &unique
return arq
}
// Order adds an order step to the query.
// Order specifies how the records should be ordered.
func (arq *AuthRequestQuery) Order(o ...OrderFunc) *AuthRequestQuery {
arq.order = append(arq.order, o...)
return arq
@@ -62,7 +60,7 @@ func (arq *AuthRequestQuery) Order(o ...OrderFunc) *AuthRequestQuery {
// First returns the first AuthRequest entity from the query.
// Returns a *NotFoundError when no AuthRequest was found.
func (arq *AuthRequestQuery) First(ctx context.Context) (*AuthRequest, error) {
nodes, err := arq.Limit(1).All(ctx)
nodes, err := arq.Limit(1).All(setContextOp(ctx, arq.ctx, "First"))
if err != nil {
return nil, err
}
@@ -85,7 +83,7 @@ func (arq *AuthRequestQuery) FirstX(ctx context.Context) *AuthRequest {
// Returns a *NotFoundError when no AuthRequest ID was found.
func (arq *AuthRequestQuery) FirstID(ctx context.Context) (id string, err error) {
var ids []string
if ids, err = arq.Limit(1).IDs(ctx); err != nil {
if ids, err = arq.Limit(1).IDs(setContextOp(ctx, arq.ctx, "FirstID")); err != nil {
return
}
if len(ids) == 0 {
@@ -108,7 +106,7 @@ func (arq *AuthRequestQuery) FirstIDX(ctx context.Context) string {
// Returns a *NotSingularError when more than one AuthRequest entity is found.
// Returns a *NotFoundError when no AuthRequest entities are found.
func (arq *AuthRequestQuery) Only(ctx context.Context) (*AuthRequest, error) {
nodes, err := arq.Limit(2).All(ctx)
nodes, err := arq.Limit(2).All(setContextOp(ctx, arq.ctx, "Only"))
if err != nil {
return nil, err
}
@@ -136,7 +134,7 @@ func (arq *AuthRequestQuery) OnlyX(ctx context.Context) *AuthRequest {
// Returns a *NotFoundError when no entities are found.
func (arq *AuthRequestQuery) OnlyID(ctx context.Context) (id string, err error) {
var ids []string
if ids, err = arq.Limit(2).IDs(ctx); err != nil {
if ids, err = arq.Limit(2).IDs(setContextOp(ctx, arq.ctx, "OnlyID")); err != nil {
return
}
switch len(ids) {
@@ -161,10 +159,12 @@ func (arq *AuthRequestQuery) OnlyIDX(ctx context.Context) string {
// All executes the query and returns a list of AuthRequests.
func (arq *AuthRequestQuery) All(ctx context.Context) ([]*AuthRequest, error) {
ctx = setContextOp(ctx, arq.ctx, "All")
if err := arq.prepareQuery(ctx); err != nil {
return nil, err
}
return arq.sqlAll(ctx)
qr := querierAll[[]*AuthRequest, *AuthRequestQuery]()
return withInterceptors[[]*AuthRequest](ctx, arq, qr, arq.inters)
}
// AllX is like All, but panics if an error occurs.
@@ -177,9 +177,12 @@ func (arq *AuthRequestQuery) AllX(ctx context.Context) []*AuthRequest {
}
// IDs executes the query and returns a list of AuthRequest IDs.
func (arq *AuthRequestQuery) IDs(ctx context.Context) ([]string, error) {
var ids []string
if err := arq.Select(authrequest.FieldID).Scan(ctx, &ids); err != nil {
func (arq *AuthRequestQuery) IDs(ctx context.Context) (ids []string, err error) {
if arq.ctx.Unique == nil && arq.path != nil {
arq.Unique(true)
}
ctx = setContextOp(ctx, arq.ctx, "IDs")
if err = arq.Select(authrequest.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
return ids, nil
@@ -196,10 +199,11 @@ func (arq *AuthRequestQuery) IDsX(ctx context.Context) []string {
// Count returns the count of the given query.
func (arq *AuthRequestQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, arq.ctx, "Count")
if err := arq.prepareQuery(ctx); err != nil {
return 0, err
}
return arq.sqlCount(ctx)
return withInterceptors[int](ctx, arq, querierCount[*AuthRequestQuery](), arq.inters)
}
// CountX is like Count, but panics if an error occurs.
@@ -213,10 +217,15 @@ func (arq *AuthRequestQuery) CountX(ctx context.Context) int {
// Exist returns true if the query has elements in the graph.
func (arq *AuthRequestQuery) Exist(ctx context.Context) (bool, error) {
if err := arq.prepareQuery(ctx); err != nil {
return false, err
ctx = setContextOp(ctx, arq.ctx, "Exist")
switch _, err := arq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("db: check existence: %w", err)
default:
return true, nil
}
return arq.sqlExist(ctx)
}
// ExistX is like Exist, but panics if an error occurs.
@@ -236,14 +245,13 @@ func (arq *AuthRequestQuery) Clone() *AuthRequestQuery {
}
return &AuthRequestQuery{
config: arq.config,
limit: arq.limit,
offset: arq.offset,
ctx: arq.ctx.Clone(),
order: append([]OrderFunc{}, arq.order...),
inters: append([]Interceptor{}, arq.inters...),
predicates: append([]predicate.AuthRequest{}, arq.predicates...),
// clone intermediate query.
sql: arq.sql.Clone(),
path: arq.path,
unique: arq.unique,
sql: arq.sql.Clone(),
path: arq.path,
}
}
@@ -261,18 +269,12 @@ func (arq *AuthRequestQuery) Clone() *AuthRequestQuery {
// GroupBy(authrequest.FieldClientID).
// Aggregate(db.Count()).
// Scan(ctx, &v)
//
func (arq *AuthRequestQuery) GroupBy(field string, fields ...string) *AuthRequestGroupBy {
grbuild := &AuthRequestGroupBy{config: arq.config}
grbuild.fields = append([]string{field}, fields...)
grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) {
if err := arq.prepareQuery(ctx); err != nil {
return nil, err
}
return arq.sqlQuery(ctx), nil
}
arq.ctx.Fields = append([]string{field}, fields...)
grbuild := &AuthRequestGroupBy{build: arq}
grbuild.flds = &arq.ctx.Fields
grbuild.label = authrequest.Label
grbuild.flds, grbuild.scan = &grbuild.fields, grbuild.Scan
grbuild.scan = grbuild.Scan
return grbuild
}
@@ -288,17 +290,31 @@ func (arq *AuthRequestQuery) GroupBy(field string, fields ...string) *AuthReques
// client.AuthRequest.Query().
// Select(authrequest.FieldClientID).
// Scan(ctx, &v)
//
func (arq *AuthRequestQuery) Select(fields ...string) *AuthRequestSelect {
arq.fields = append(arq.fields, fields...)
selbuild := &AuthRequestSelect{AuthRequestQuery: arq}
selbuild.label = authrequest.Label
selbuild.flds, selbuild.scan = &arq.fields, selbuild.Scan
return selbuild
arq.ctx.Fields = append(arq.ctx.Fields, fields...)
sbuild := &AuthRequestSelect{AuthRequestQuery: arq}
sbuild.label = authrequest.Label
sbuild.flds, sbuild.scan = &arq.ctx.Fields, sbuild.Scan
return sbuild
}
// Aggregate returns a AuthRequestSelect configured with the given aggregations.
func (arq *AuthRequestQuery) Aggregate(fns ...AggregateFunc) *AuthRequestSelect {
return arq.Select().Aggregate(fns...)
}
func (arq *AuthRequestQuery) prepareQuery(ctx context.Context) error {
for _, f := range arq.fields {
for _, inter := range arq.inters {
if inter == nil {
return fmt.Errorf("db: uninitialized interceptor (forgotten import db/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, arq); err != nil {
return err
}
}
}
for _, f := range arq.ctx.Fields {
if !authrequest.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)}
}
@@ -318,10 +334,10 @@ func (arq *AuthRequestQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]
nodes = []*AuthRequest{}
_spec = arq.querySpec()
)
_spec.ScanValues = func(columns []string) ([]interface{}, error) {
_spec.ScanValues = func(columns []string) ([]any, error) {
return (*AuthRequest).scanValues(nil, columns)
}
_spec.Assign = func(columns []string, values []interface{}) error {
_spec.Assign = func(columns []string, values []any) error {
node := &AuthRequest{config: arq.config}
nodes = append(nodes, node)
return node.assignValues(columns, values)
@@ -340,38 +356,22 @@ func (arq *AuthRequestQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]
func (arq *AuthRequestQuery) sqlCount(ctx context.Context) (int, error) {
_spec := arq.querySpec()
_spec.Node.Columns = arq.fields
if len(arq.fields) > 0 {
_spec.Unique = arq.unique != nil && *arq.unique
_spec.Node.Columns = arq.ctx.Fields
if len(arq.ctx.Fields) > 0 {
_spec.Unique = arq.ctx.Unique != nil && *arq.ctx.Unique
}
return sqlgraph.CountNodes(ctx, arq.driver, _spec)
}
func (arq *AuthRequestQuery) sqlExist(ctx context.Context) (bool, error) {
n, err := arq.sqlCount(ctx)
if err != nil {
return false, fmt.Errorf("db: check existence: %w", err)
}
return n > 0, nil
}
func (arq *AuthRequestQuery) querySpec() *sqlgraph.QuerySpec {
_spec := &sqlgraph.QuerySpec{
Node: &sqlgraph.NodeSpec{
Table: authrequest.Table,
Columns: authrequest.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeString,
Column: authrequest.FieldID,
},
},
From: arq.sql,
Unique: true,
}
if unique := arq.unique; unique != nil {
_spec := sqlgraph.NewQuerySpec(authrequest.Table, authrequest.Columns, sqlgraph.NewFieldSpec(authrequest.FieldID, field.TypeString))
_spec.From = arq.sql
if unique := arq.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if arq.path != nil {
_spec.Unique = true
}
if fields := arq.fields; len(fields) > 0 {
if fields := arq.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, authrequest.FieldID)
for i := range fields {
@@ -387,10 +387,10 @@ func (arq *AuthRequestQuery) querySpec() *sqlgraph.QuerySpec {
}
}
}
if limit := arq.limit; limit != nil {
if limit := arq.ctx.Limit; limit != nil {
_spec.Limit = *limit
}
if offset := arq.offset; offset != nil {
if offset := arq.ctx.Offset; offset != nil {
_spec.Offset = *offset
}
if ps := arq.order; len(ps) > 0 {
@@ -406,7 +406,7 @@ func (arq *AuthRequestQuery) querySpec() *sqlgraph.QuerySpec {
func (arq *AuthRequestQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(arq.driver.Dialect())
t1 := builder.Table(authrequest.Table)
columns := arq.fields
columns := arq.ctx.Fields
if len(columns) == 0 {
columns = authrequest.Columns
}
@@ -415,7 +415,7 @@ func (arq *AuthRequestQuery) sqlQuery(ctx context.Context) *sql.Selector {
selector = arq.sql
selector.Select(selector.Columns(columns...)...)
}
if arq.unique != nil && *arq.unique {
if arq.ctx.Unique != nil && *arq.ctx.Unique {
selector.Distinct()
}
for _, p := range arq.predicates {
@@ -424,12 +424,12 @@ func (arq *AuthRequestQuery) sqlQuery(ctx context.Context) *sql.Selector {
for _, p := range arq.order {
p(selector)
}
if offset := arq.offset; offset != nil {
if offset := arq.ctx.Offset; offset != nil {
// limit is mandatory for offset clause. We start
// with default value, and override it below if needed.
selector.Offset(*offset).Limit(math.MaxInt32)
}
if limit := arq.limit; limit != nil {
if limit := arq.ctx.Limit; limit != nil {
selector.Limit(*limit)
}
return selector
@@ -437,13 +437,8 @@ func (arq *AuthRequestQuery) sqlQuery(ctx context.Context) *sql.Selector {
// AuthRequestGroupBy is the group-by builder for AuthRequest entities.
type AuthRequestGroupBy struct {
config
selector
fields []string
fns []AggregateFunc
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
build *AuthRequestQuery
}
// Aggregate adds the given aggregation functions to the group-by query.
@@ -452,74 +447,77 @@ func (argb *AuthRequestGroupBy) Aggregate(fns ...AggregateFunc) *AuthRequestGrou
return argb
}
// Scan applies the group-by query and scans the result into the given value.
func (argb *AuthRequestGroupBy) Scan(ctx context.Context, v interface{}) error {
query, err := argb.path(ctx)
if err != nil {
// Scan applies the selector query and scans the result into the given value.
func (argb *AuthRequestGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, argb.build.ctx, "GroupBy")
if err := argb.build.prepareQuery(ctx); err != nil {
return err
}
argb.sql = query
return argb.sqlScan(ctx, v)
return scanWithInterceptors[*AuthRequestQuery, *AuthRequestGroupBy](ctx, argb.build, argb, argb.build.inters, v)
}
func (argb *AuthRequestGroupBy) sqlScan(ctx context.Context, v interface{}) error {
for _, f := range argb.fields {
if !authrequest.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)}
}
}
selector := argb.sqlQuery()
if err := selector.Err(); err != nil {
return err
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := argb.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
func (argb *AuthRequestGroupBy) sqlQuery() *sql.Selector {
selector := argb.sql.Select()
func (argb *AuthRequestGroupBy) sqlScan(ctx context.Context, root *AuthRequestQuery, v any) error {
selector := root.sqlQuery(ctx).Select()
aggregation := make([]string, 0, len(argb.fns))
for _, fn := range argb.fns {
aggregation = append(aggregation, fn(selector))
}
// If no columns were selected in a custom aggregation function, the default
// selection is the fields used for "group-by", and the aggregation functions.
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(argb.fields)+len(argb.fns))
for _, f := range argb.fields {
columns := make([]string, 0, len(*argb.flds)+len(argb.fns))
for _, f := range *argb.flds {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
return selector.GroupBy(selector.Columns(argb.fields...)...)
selector.GroupBy(selector.Columns(*argb.flds...)...)
if err := selector.Err(); err != nil {
return err
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := argb.build.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
// AuthRequestSelect is the builder for selecting fields of AuthRequest entities.
type AuthRequestSelect struct {
*AuthRequestQuery
selector
// intermediate query (i.e. traversal path).
sql *sql.Selector
}
// Aggregate adds the given aggregation functions to the selector query.
func (ars *AuthRequestSelect) Aggregate(fns ...AggregateFunc) *AuthRequestSelect {
ars.fns = append(ars.fns, fns...)
return ars
}
// Scan applies the selector query and scans the result into the given value.
func (ars *AuthRequestSelect) Scan(ctx context.Context, v interface{}) error {
func (ars *AuthRequestSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, ars.ctx, "Select")
if err := ars.prepareQuery(ctx); err != nil {
return err
}
ars.sql = ars.AuthRequestQuery.sqlQuery(ctx)
return ars.sqlScan(ctx, v)
return scanWithInterceptors[*AuthRequestQuery, *AuthRequestSelect](ctx, ars.AuthRequestQuery, ars, ars.inters, v)
}
func (ars *AuthRequestSelect) sqlScan(ctx context.Context, v interface{}) error {
func (ars *AuthRequestSelect) sqlScan(ctx context.Context, root *AuthRequestQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(ars.fns))
for _, fn := range ars.fns {
aggregation = append(aggregation, fn(selector))
}
switch n := len(*ars.selector.flds); {
case n == 0 && len(aggregation) > 0:
selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0:
selector.AppendSelect(aggregation...)
}
rows := &sql.Rows{}
query, args := ars.sql.Query()
query, args := selector.Query()
if err := ars.driver.Query(ctx, query, args, rows); err != nil {
return err
}
File diff suppressed because it is too large Load Diff
+334 -12
View File
File diff suppressed because it is too large Load Diff
+31 -15
View File
@@ -17,24 +17,40 @@ type config struct {
// debug enable a debug logging.
debug bool
// log used for logging on debug mode.
log func(...interface{})
log func(...any)
// hooks to execute on mutations.
hooks *hooks
// interceptors to execute on queries.
inters *inters
}
// hooks per client, for fast access.
type hooks struct {
AuthCode []ent.Hook
AuthRequest []ent.Hook
Connector []ent.Hook
DeviceRequest []ent.Hook
DeviceToken []ent.Hook
Keys []ent.Hook
OAuth2Client []ent.Hook
OfflineSession []ent.Hook
Password []ent.Hook
RefreshToken []ent.Hook
}
// hooks and interceptors per client, for fast access.
type (
hooks struct {
AuthCode []ent.Hook
AuthRequest []ent.Hook
Connector []ent.Hook
DeviceRequest []ent.Hook
DeviceToken []ent.Hook
Keys []ent.Hook
OAuth2Client []ent.Hook
OfflineSession []ent.Hook
Password []ent.Hook
RefreshToken []ent.Hook
}
inters struct {
AuthCode []ent.Interceptor
AuthRequest []ent.Interceptor
Connector []ent.Interceptor
DeviceRequest []ent.Interceptor
DeviceToken []ent.Interceptor
Keys []ent.Interceptor
OAuth2Client []ent.Interceptor
OfflineSession []ent.Interceptor
Password []ent.Interceptor
RefreshToken []ent.Interceptor
}
)
// Options applies the options on the config object.
func (c *config) options(opts ...Option) {
@@ -54,7 +70,7 @@ func Debug() Option {
}
// Log sets the logging function for debug mode.
func Log(fn func(...interface{})) Option {
func Log(fn func(...any)) Option {
return func(c *config) {
c.log = fn
}
+4 -10
View File
@@ -26,8 +26,8 @@ type Connector struct {
}
// scanValues returns the types for scanning values from sql.Rows.
func (*Connector) scanValues(columns []string) ([]interface{}, error) {
values := make([]interface{}, len(columns))
func (*Connector) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case connector.FieldConfig:
@@ -43,7 +43,7 @@ func (*Connector) scanValues(columns []string) ([]interface{}, error) {
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the Connector fields.
func (c *Connector) assignValues(columns []string, values []interface{}) error {
func (c *Connector) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
@@ -88,7 +88,7 @@ func (c *Connector) assignValues(columns []string, values []interface{}) error {
// Note that you need to call Connector.Unwrap() before calling this method if this Connector
// was returned from a transaction, and the transaction was committed or rolled back.
func (c *Connector) Update() *ConnectorUpdateOne {
return (&ConnectorClient{config: c.config}).UpdateOne(c)
return NewConnectorClient(c.config).UpdateOne(c)
}
// Unwrap unwraps the Connector entity that was returned from a transaction after it was closed,
@@ -124,9 +124,3 @@ func (c *Connector) String() string {
// Connectors is a parsable slice of Connector.
type Connectors []*Connector
func (c Connectors) config(cfg config) {
for _i := range c {
c[_i].config = cfg
}
}
File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More