mirror of https://github.com/dexidp/dex.git
Browse Source
Signed-off-by: maksim.nabokikh <max.nabokih@gmail.com> Signed-off-by: Maksim Nabokikh <max.nabokih@gmail.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>pull/4632/merge
30 changed files with 4754 additions and 19 deletions
@ -0,0 +1,130 @@ |
|||||||
|
package client |
||||||
|
|
||||||
|
import ( |
||||||
|
"context" |
||||||
|
"encoding/json" |
||||||
|
"fmt" |
||||||
|
|
||||||
|
"github.com/dexidp/dex/storage" |
||||||
|
) |
||||||
|
|
||||||
|
// CreateUserIdentity saves provided user identity into the database.
|
||||||
|
func (d *Database) CreateUserIdentity(ctx context.Context, identity storage.UserIdentity) error { |
||||||
|
if identity.Consents == nil { |
||||||
|
identity.Consents = make(map[string][]string) |
||||||
|
} |
||||||
|
encodedConsents, err := json.Marshal(identity.Consents) |
||||||
|
if err != nil { |
||||||
|
return fmt.Errorf("encode consents user identity: %w", err) |
||||||
|
} |
||||||
|
|
||||||
|
id := compositeKeyID(identity.UserID, identity.ConnectorID, d.hasher) |
||||||
|
_, err = d.client.UserIdentity.Create(). |
||||||
|
SetID(id). |
||||||
|
SetUserID(identity.UserID). |
||||||
|
SetConnectorID(identity.ConnectorID). |
||||||
|
SetClaimsUserID(identity.Claims.UserID). |
||||||
|
SetClaimsUsername(identity.Claims.Username). |
||||||
|
SetClaimsPreferredUsername(identity.Claims.PreferredUsername). |
||||||
|
SetClaimsEmail(identity.Claims.Email). |
||||||
|
SetClaimsEmailVerified(identity.Claims.EmailVerified). |
||||||
|
SetClaimsGroups(identity.Claims.Groups). |
||||||
|
SetConsents(encodedConsents). |
||||||
|
SetCreatedAt(identity.CreatedAt). |
||||||
|
SetLastLogin(identity.LastLogin). |
||||||
|
SetBlockedUntil(identity.BlockedUntil). |
||||||
|
Save(ctx) |
||||||
|
if err != nil { |
||||||
|
return convertDBError("create user identity: %w", err) |
||||||
|
} |
||||||
|
return nil |
||||||
|
} |
||||||
|
|
||||||
|
// GetUserIdentity extracts a user identity from the database by user id and connector id.
|
||||||
|
func (d *Database) GetUserIdentity(ctx context.Context, userID, connectorID string) (storage.UserIdentity, error) { |
||||||
|
id := compositeKeyID(userID, connectorID, d.hasher) |
||||||
|
|
||||||
|
userIdentity, err := d.client.UserIdentity.Get(ctx, id) |
||||||
|
if err != nil { |
||||||
|
return storage.UserIdentity{}, convertDBError("get user identity: %w", err) |
||||||
|
} |
||||||
|
return toStorageUserIdentity(userIdentity), nil |
||||||
|
} |
||||||
|
|
||||||
|
// DeleteUserIdentity deletes a user identity from the database by user id and connector id.
|
||||||
|
func (d *Database) DeleteUserIdentity(ctx context.Context, userID, connectorID string) error { |
||||||
|
id := compositeKeyID(userID, connectorID, d.hasher) |
||||||
|
|
||||||
|
err := d.client.UserIdentity.DeleteOneID(id).Exec(ctx) |
||||||
|
if err != nil { |
||||||
|
return convertDBError("delete user identity: %w", err) |
||||||
|
} |
||||||
|
return nil |
||||||
|
} |
||||||
|
|
||||||
|
// UpdateUserIdentity changes a user identity by user id and connector id using an updater function.
|
||||||
|
func (d *Database) UpdateUserIdentity(ctx context.Context, userID string, connectorID string, updater func(u storage.UserIdentity) (storage.UserIdentity, error)) error { |
||||||
|
id := compositeKeyID(userID, connectorID, d.hasher) |
||||||
|
|
||||||
|
tx, err := d.BeginTx(ctx) |
||||||
|
if err != nil { |
||||||
|
return convertDBError("update user identity tx: %w", err) |
||||||
|
} |
||||||
|
|
||||||
|
userIdentity, err := tx.UserIdentity.Get(ctx, id) |
||||||
|
if err != nil { |
||||||
|
return rollback(tx, "update user identity database: %w", err) |
||||||
|
} |
||||||
|
|
||||||
|
newUserIdentity, err := updater(toStorageUserIdentity(userIdentity)) |
||||||
|
if err != nil { |
||||||
|
return rollback(tx, "update user identity updating: %w", err) |
||||||
|
} |
||||||
|
|
||||||
|
if newUserIdentity.Consents == nil { |
||||||
|
newUserIdentity.Consents = make(map[string][]string) |
||||||
|
} |
||||||
|
|
||||||
|
encodedConsents, err := json.Marshal(newUserIdentity.Consents) |
||||||
|
if err != nil { |
||||||
|
return rollback(tx, "encode consents user identity: %w", err) |
||||||
|
} |
||||||
|
|
||||||
|
_, err = tx.UserIdentity.UpdateOneID(id). |
||||||
|
SetUserID(newUserIdentity.UserID). |
||||||
|
SetConnectorID(newUserIdentity.ConnectorID). |
||||||
|
SetClaimsUserID(newUserIdentity.Claims.UserID). |
||||||
|
SetClaimsUsername(newUserIdentity.Claims.Username). |
||||||
|
SetClaimsPreferredUsername(newUserIdentity.Claims.PreferredUsername). |
||||||
|
SetClaimsEmail(newUserIdentity.Claims.Email). |
||||||
|
SetClaimsEmailVerified(newUserIdentity.Claims.EmailVerified). |
||||||
|
SetClaimsGroups(newUserIdentity.Claims.Groups). |
||||||
|
SetConsents(encodedConsents). |
||||||
|
SetCreatedAt(newUserIdentity.CreatedAt). |
||||||
|
SetLastLogin(newUserIdentity.LastLogin). |
||||||
|
SetBlockedUntil(newUserIdentity.BlockedUntil). |
||||||
|
Save(ctx) |
||||||
|
if err != nil { |
||||||
|
return rollback(tx, "update user identity uploading: %w", err) |
||||||
|
} |
||||||
|
|
||||||
|
if err = tx.Commit(); err != nil { |
||||||
|
return rollback(tx, "update user identity commit: %w", err) |
||||||
|
} |
||||||
|
|
||||||
|
return nil |
||||||
|
} |
||||||
|
|
||||||
|
// ListUserIdentities lists all user identities in the database.
|
||||||
|
func (d *Database) ListUserIdentities(ctx context.Context) ([]storage.UserIdentity, error) { |
||||||
|
userIdentities, err := d.client.UserIdentity.Query().All(ctx) |
||||||
|
if err != nil { |
||||||
|
return nil, convertDBError("list user identities: %w", err) |
||||||
|
} |
||||||
|
|
||||||
|
storageUserIdentities := make([]storage.UserIdentity, 0, len(userIdentities)) |
||||||
|
for _, u := range userIdentities { |
||||||
|
storageUserIdentities = append(storageUserIdentities, toStorageUserIdentity(u)) |
||||||
|
} |
||||||
|
return storageUserIdentities, nil |
||||||
|
} |
||||||
@ -0,0 +1,232 @@ |
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package db |
||||||
|
|
||||||
|
import ( |
||||||
|
"encoding/json" |
||||||
|
"fmt" |
||||||
|
"strings" |
||||||
|
"time" |
||||||
|
|
||||||
|
"entgo.io/ent" |
||||||
|
"entgo.io/ent/dialect/sql" |
||||||
|
"github.com/dexidp/dex/storage/ent/db/useridentity" |
||||||
|
) |
||||||
|
|
||||||
|
// UserIdentity is the model entity for the UserIdentity schema.
|
||||||
|
type UserIdentity struct { |
||||||
|
config `json:"-"` |
||||||
|
// ID of the ent.
|
||||||
|
ID string `json:"id,omitempty"` |
||||||
|
// UserID holds the value of the "user_id" field.
|
||||||
|
UserID string `json:"user_id,omitempty"` |
||||||
|
// ConnectorID holds the value of the "connector_id" field.
|
||||||
|
ConnectorID string `json:"connector_id,omitempty"` |
||||||
|
// ClaimsUserID holds the value of the "claims_user_id" field.
|
||||||
|
ClaimsUserID string `json:"claims_user_id,omitempty"` |
||||||
|
// ClaimsUsername holds the value of the "claims_username" field.
|
||||||
|
ClaimsUsername string `json:"claims_username,omitempty"` |
||||||
|
// ClaimsPreferredUsername holds the value of the "claims_preferred_username" field.
|
||||||
|
ClaimsPreferredUsername string `json:"claims_preferred_username,omitempty"` |
||||||
|
// ClaimsEmail holds the value of the "claims_email" field.
|
||||||
|
ClaimsEmail string `json:"claims_email,omitempty"` |
||||||
|
// ClaimsEmailVerified holds the value of the "claims_email_verified" field.
|
||||||
|
ClaimsEmailVerified bool `json:"claims_email_verified,omitempty"` |
||||||
|
// ClaimsGroups holds the value of the "claims_groups" field.
|
||||||
|
ClaimsGroups []string `json:"claims_groups,omitempty"` |
||||||
|
// Consents holds the value of the "consents" field.
|
||||||
|
Consents []byte `json:"consents,omitempty"` |
||||||
|
// CreatedAt holds the value of the "created_at" field.
|
||||||
|
CreatedAt time.Time `json:"created_at,omitempty"` |
||||||
|
// LastLogin holds the value of the "last_login" field.
|
||||||
|
LastLogin time.Time `json:"last_login,omitempty"` |
||||||
|
// BlockedUntil holds the value of the "blocked_until" field.
|
||||||
|
BlockedUntil time.Time `json:"blocked_until,omitempty"` |
||||||
|
selectValues sql.SelectValues |
||||||
|
} |
||||||
|
|
||||||
|
// scanValues returns the types for scanning values from sql.Rows.
|
||||||
|
func (*UserIdentity) scanValues(columns []string) ([]any, error) { |
||||||
|
values := make([]any, len(columns)) |
||||||
|
for i := range columns { |
||||||
|
switch columns[i] { |
||||||
|
case useridentity.FieldClaimsGroups, useridentity.FieldConsents: |
||||||
|
values[i] = new([]byte) |
||||||
|
case useridentity.FieldClaimsEmailVerified: |
||||||
|
values[i] = new(sql.NullBool) |
||||||
|
case useridentity.FieldID, useridentity.FieldUserID, useridentity.FieldConnectorID, useridentity.FieldClaimsUserID, useridentity.FieldClaimsUsername, useridentity.FieldClaimsPreferredUsername, useridentity.FieldClaimsEmail: |
||||||
|
values[i] = new(sql.NullString) |
||||||
|
case useridentity.FieldCreatedAt, useridentity.FieldLastLogin, useridentity.FieldBlockedUntil: |
||||||
|
values[i] = new(sql.NullTime) |
||||||
|
default: |
||||||
|
values[i] = new(sql.UnknownType) |
||||||
|
} |
||||||
|
} |
||||||
|
return values, nil |
||||||
|
} |
||||||
|
|
||||||
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||||
|
// to the UserIdentity fields.
|
||||||
|
func (_m *UserIdentity) 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) |
||||||
|
} |
||||||
|
for i := range columns { |
||||||
|
switch columns[i] { |
||||||
|
case useridentity.FieldID: |
||||||
|
if value, ok := values[i].(*sql.NullString); !ok { |
||||||
|
return fmt.Errorf("unexpected type %T for field id", values[i]) |
||||||
|
} else if value.Valid { |
||||||
|
_m.ID = value.String |
||||||
|
} |
||||||
|
case useridentity.FieldUserID: |
||||||
|
if value, ok := values[i].(*sql.NullString); !ok { |
||||||
|
return fmt.Errorf("unexpected type %T for field user_id", values[i]) |
||||||
|
} else if value.Valid { |
||||||
|
_m.UserID = value.String |
||||||
|
} |
||||||
|
case useridentity.FieldConnectorID: |
||||||
|
if value, ok := values[i].(*sql.NullString); !ok { |
||||||
|
return fmt.Errorf("unexpected type %T for field connector_id", values[i]) |
||||||
|
} else if value.Valid { |
||||||
|
_m.ConnectorID = value.String |
||||||
|
} |
||||||
|
case useridentity.FieldClaimsUserID: |
||||||
|
if value, ok := values[i].(*sql.NullString); !ok { |
||||||
|
return fmt.Errorf("unexpected type %T for field claims_user_id", values[i]) |
||||||
|
} else if value.Valid { |
||||||
|
_m.ClaimsUserID = value.String |
||||||
|
} |
||||||
|
case useridentity.FieldClaimsUsername: |
||||||
|
if value, ok := values[i].(*sql.NullString); !ok { |
||||||
|
return fmt.Errorf("unexpected type %T for field claims_username", values[i]) |
||||||
|
} else if value.Valid { |
||||||
|
_m.ClaimsUsername = value.String |
||||||
|
} |
||||||
|
case useridentity.FieldClaimsPreferredUsername: |
||||||
|
if value, ok := values[i].(*sql.NullString); !ok { |
||||||
|
return fmt.Errorf("unexpected type %T for field claims_preferred_username", values[i]) |
||||||
|
} else if value.Valid { |
||||||
|
_m.ClaimsPreferredUsername = value.String |
||||||
|
} |
||||||
|
case useridentity.FieldClaimsEmail: |
||||||
|
if value, ok := values[i].(*sql.NullString); !ok { |
||||||
|
return fmt.Errorf("unexpected type %T for field claims_email", values[i]) |
||||||
|
} else if value.Valid { |
||||||
|
_m.ClaimsEmail = value.String |
||||||
|
} |
||||||
|
case useridentity.FieldClaimsEmailVerified: |
||||||
|
if value, ok := values[i].(*sql.NullBool); !ok { |
||||||
|
return fmt.Errorf("unexpected type %T for field claims_email_verified", values[i]) |
||||||
|
} else if value.Valid { |
||||||
|
_m.ClaimsEmailVerified = value.Bool |
||||||
|
} |
||||||
|
case useridentity.FieldClaimsGroups: |
||||||
|
if value, ok := values[i].(*[]byte); !ok { |
||||||
|
return fmt.Errorf("unexpected type %T for field claims_groups", values[i]) |
||||||
|
} else if value != nil && len(*value) > 0 { |
||||||
|
if err := json.Unmarshal(*value, &_m.ClaimsGroups); err != nil { |
||||||
|
return fmt.Errorf("unmarshal field claims_groups: %w", err) |
||||||
|
} |
||||||
|
} |
||||||
|
case useridentity.FieldConsents: |
||||||
|
if value, ok := values[i].(*[]byte); !ok { |
||||||
|
return fmt.Errorf("unexpected type %T for field consents", values[i]) |
||||||
|
} else if value != nil { |
||||||
|
_m.Consents = *value |
||||||
|
} |
||||||
|
case useridentity.FieldCreatedAt: |
||||||
|
if value, ok := values[i].(*sql.NullTime); !ok { |
||||||
|
return fmt.Errorf("unexpected type %T for field created_at", values[i]) |
||||||
|
} else if value.Valid { |
||||||
|
_m.CreatedAt = value.Time |
||||||
|
} |
||||||
|
case useridentity.FieldLastLogin: |
||||||
|
if value, ok := values[i].(*sql.NullTime); !ok { |
||||||
|
return fmt.Errorf("unexpected type %T for field last_login", values[i]) |
||||||
|
} else if value.Valid { |
||||||
|
_m.LastLogin = value.Time |
||||||
|
} |
||||||
|
case useridentity.FieldBlockedUntil: |
||||||
|
if value, ok := values[i].(*sql.NullTime); !ok { |
||||||
|
return fmt.Errorf("unexpected type %T for field blocked_until", values[i]) |
||||||
|
} else if value.Valid { |
||||||
|
_m.BlockedUntil = value.Time |
||||||
|
} |
||||||
|
default: |
||||||
|
_m.selectValues.Set(columns[i], values[i]) |
||||||
|
} |
||||||
|
} |
||||||
|
return nil |
||||||
|
} |
||||||
|
|
||||||
|
// Value returns the ent.Value that was dynamically selected and assigned to the UserIdentity.
|
||||||
|
// This includes values selected through modifiers, order, etc.
|
||||||
|
func (_m *UserIdentity) Value(name string) (ent.Value, error) { |
||||||
|
return _m.selectValues.Get(name) |
||||||
|
} |
||||||
|
|
||||||
|
// Update returns a builder for updating this UserIdentity.
|
||||||
|
// Note that you need to call UserIdentity.Unwrap() before calling this method if this UserIdentity
|
||||||
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||||
|
func (_m *UserIdentity) Update() *UserIdentityUpdateOne { |
||||||
|
return NewUserIdentityClient(_m.config).UpdateOne(_m) |
||||||
|
} |
||||||
|
|
||||||
|
// Unwrap unwraps the UserIdentity entity that was returned from a transaction after it was closed,
|
||||||
|
// so that all future queries will be executed through the driver which created the transaction.
|
||||||
|
func (_m *UserIdentity) Unwrap() *UserIdentity { |
||||||
|
_tx, ok := _m.config.driver.(*txDriver) |
||||||
|
if !ok { |
||||||
|
panic("db: UserIdentity is not a transactional entity") |
||||||
|
} |
||||||
|
_m.config.driver = _tx.drv |
||||||
|
return _m |
||||||
|
} |
||||||
|
|
||||||
|
// String implements the fmt.Stringer.
|
||||||
|
func (_m *UserIdentity) String() string { |
||||||
|
var builder strings.Builder |
||||||
|
builder.WriteString("UserIdentity(") |
||||||
|
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) |
||||||
|
builder.WriteString("user_id=") |
||||||
|
builder.WriteString(_m.UserID) |
||||||
|
builder.WriteString(", ") |
||||||
|
builder.WriteString("connector_id=") |
||||||
|
builder.WriteString(_m.ConnectorID) |
||||||
|
builder.WriteString(", ") |
||||||
|
builder.WriteString("claims_user_id=") |
||||||
|
builder.WriteString(_m.ClaimsUserID) |
||||||
|
builder.WriteString(", ") |
||||||
|
builder.WriteString("claims_username=") |
||||||
|
builder.WriteString(_m.ClaimsUsername) |
||||||
|
builder.WriteString(", ") |
||||||
|
builder.WriteString("claims_preferred_username=") |
||||||
|
builder.WriteString(_m.ClaimsPreferredUsername) |
||||||
|
builder.WriteString(", ") |
||||||
|
builder.WriteString("claims_email=") |
||||||
|
builder.WriteString(_m.ClaimsEmail) |
||||||
|
builder.WriteString(", ") |
||||||
|
builder.WriteString("claims_email_verified=") |
||||||
|
builder.WriteString(fmt.Sprintf("%v", _m.ClaimsEmailVerified)) |
||||||
|
builder.WriteString(", ") |
||||||
|
builder.WriteString("claims_groups=") |
||||||
|
builder.WriteString(fmt.Sprintf("%v", _m.ClaimsGroups)) |
||||||
|
builder.WriteString(", ") |
||||||
|
builder.WriteString("consents=") |
||||||
|
builder.WriteString(fmt.Sprintf("%v", _m.Consents)) |
||||||
|
builder.WriteString(", ") |
||||||
|
builder.WriteString("created_at=") |
||||||
|
builder.WriteString(_m.CreatedAt.Format(time.ANSIC)) |
||||||
|
builder.WriteString(", ") |
||||||
|
builder.WriteString("last_login=") |
||||||
|
builder.WriteString(_m.LastLogin.Format(time.ANSIC)) |
||||||
|
builder.WriteString(", ") |
||||||
|
builder.WriteString("blocked_until=") |
||||||
|
builder.WriteString(_m.BlockedUntil.Format(time.ANSIC)) |
||||||
|
builder.WriteByte(')') |
||||||
|
return builder.String() |
||||||
|
} |
||||||
|
|
||||||
|
// UserIdentities is a parsable slice of UserIdentity.
|
||||||
|
type UserIdentities []*UserIdentity |
||||||
@ -0,0 +1,144 @@ |
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package useridentity |
||||||
|
|
||||||
|
import ( |
||||||
|
"entgo.io/ent/dialect/sql" |
||||||
|
) |
||||||
|
|
||||||
|
const ( |
||||||
|
// Label holds the string label denoting the useridentity type in the database.
|
||||||
|
Label = "user_identity" |
||||||
|
// FieldID holds the string denoting the id field in the database.
|
||||||
|
FieldID = "id" |
||||||
|
// FieldUserID holds the string denoting the user_id field in the database.
|
||||||
|
FieldUserID = "user_id" |
||||||
|
// FieldConnectorID holds the string denoting the connector_id field in the database.
|
||||||
|
FieldConnectorID = "connector_id" |
||||||
|
// FieldClaimsUserID holds the string denoting the claims_user_id field in the database.
|
||||||
|
FieldClaimsUserID = "claims_user_id" |
||||||
|
// FieldClaimsUsername holds the string denoting the claims_username field in the database.
|
||||||
|
FieldClaimsUsername = "claims_username" |
||||||
|
// FieldClaimsPreferredUsername holds the string denoting the claims_preferred_username field in the database.
|
||||||
|
FieldClaimsPreferredUsername = "claims_preferred_username" |
||||||
|
// FieldClaimsEmail holds the string denoting the claims_email field in the database.
|
||||||
|
FieldClaimsEmail = "claims_email" |
||||||
|
// FieldClaimsEmailVerified holds the string denoting the claims_email_verified field in the database.
|
||||||
|
FieldClaimsEmailVerified = "claims_email_verified" |
||||||
|
// FieldClaimsGroups holds the string denoting the claims_groups field in the database.
|
||||||
|
FieldClaimsGroups = "claims_groups" |
||||||
|
// FieldConsents holds the string denoting the consents field in the database.
|
||||||
|
FieldConsents = "consents" |
||||||
|
// FieldCreatedAt holds the string denoting the created_at field in the database.
|
||||||
|
FieldCreatedAt = "created_at" |
||||||
|
// FieldLastLogin holds the string denoting the last_login field in the database.
|
||||||
|
FieldLastLogin = "last_login" |
||||||
|
// FieldBlockedUntil holds the string denoting the blocked_until field in the database.
|
||||||
|
FieldBlockedUntil = "blocked_until" |
||||||
|
// Table holds the table name of the useridentity in the database.
|
||||||
|
Table = "user_identities" |
||||||
|
) |
||||||
|
|
||||||
|
// Columns holds all SQL columns for useridentity fields.
|
||||||
|
var Columns = []string{ |
||||||
|
FieldID, |
||||||
|
FieldUserID, |
||||||
|
FieldConnectorID, |
||||||
|
FieldClaimsUserID, |
||||||
|
FieldClaimsUsername, |
||||||
|
FieldClaimsPreferredUsername, |
||||||
|
FieldClaimsEmail, |
||||||
|
FieldClaimsEmailVerified, |
||||||
|
FieldClaimsGroups, |
||||||
|
FieldConsents, |
||||||
|
FieldCreatedAt, |
||||||
|
FieldLastLogin, |
||||||
|
FieldBlockedUntil, |
||||||
|
} |
||||||
|
|
||||||
|
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||||
|
func ValidColumn(column string) bool { |
||||||
|
for i := range Columns { |
||||||
|
if column == Columns[i] { |
||||||
|
return true |
||||||
|
} |
||||||
|
} |
||||||
|
return false |
||||||
|
} |
||||||
|
|
||||||
|
var ( |
||||||
|
// UserIDValidator is a validator for the "user_id" field. It is called by the builders before save.
|
||||||
|
UserIDValidator func(string) error |
||||||
|
// ConnectorIDValidator is a validator for the "connector_id" field. It is called by the builders before save.
|
||||||
|
ConnectorIDValidator func(string) error |
||||||
|
// DefaultClaimsUserID holds the default value on creation for the "claims_user_id" field.
|
||||||
|
DefaultClaimsUserID string |
||||||
|
// DefaultClaimsUsername holds the default value on creation for the "claims_username" field.
|
||||||
|
DefaultClaimsUsername string |
||||||
|
// DefaultClaimsPreferredUsername holds the default value on creation for the "claims_preferred_username" field.
|
||||||
|
DefaultClaimsPreferredUsername string |
||||||
|
// DefaultClaimsEmail holds the default value on creation for the "claims_email" field.
|
||||||
|
DefaultClaimsEmail string |
||||||
|
// DefaultClaimsEmailVerified holds the default value on creation for the "claims_email_verified" field.
|
||||||
|
DefaultClaimsEmailVerified bool |
||||||
|
// IDValidator is a validator for the "id" field. It is called by the builders before save.
|
||||||
|
IDValidator func(string) error |
||||||
|
) |
||||||
|
|
||||||
|
// OrderOption defines the ordering options for the UserIdentity queries.
|
||||||
|
type OrderOption func(*sql.Selector) |
||||||
|
|
||||||
|
// ByID orders the results by the id field.
|
||||||
|
func ByID(opts ...sql.OrderTermOption) OrderOption { |
||||||
|
return sql.OrderByField(FieldID, opts...).ToFunc() |
||||||
|
} |
||||||
|
|
||||||
|
// ByUserID orders the results by the user_id field.
|
||||||
|
func ByUserID(opts ...sql.OrderTermOption) OrderOption { |
||||||
|
return sql.OrderByField(FieldUserID, opts...).ToFunc() |
||||||
|
} |
||||||
|
|
||||||
|
// ByConnectorID orders the results by the connector_id field.
|
||||||
|
func ByConnectorID(opts ...sql.OrderTermOption) OrderOption { |
||||||
|
return sql.OrderByField(FieldConnectorID, opts...).ToFunc() |
||||||
|
} |
||||||
|
|
||||||
|
// ByClaimsUserID orders the results by the claims_user_id field.
|
||||||
|
func ByClaimsUserID(opts ...sql.OrderTermOption) OrderOption { |
||||||
|
return sql.OrderByField(FieldClaimsUserID, opts...).ToFunc() |
||||||
|
} |
||||||
|
|
||||||
|
// ByClaimsUsername orders the results by the claims_username field.
|
||||||
|
func ByClaimsUsername(opts ...sql.OrderTermOption) OrderOption { |
||||||
|
return sql.OrderByField(FieldClaimsUsername, opts...).ToFunc() |
||||||
|
} |
||||||
|
|
||||||
|
// ByClaimsPreferredUsername orders the results by the claims_preferred_username field.
|
||||||
|
func ByClaimsPreferredUsername(opts ...sql.OrderTermOption) OrderOption { |
||||||
|
return sql.OrderByField(FieldClaimsPreferredUsername, opts...).ToFunc() |
||||||
|
} |
||||||
|
|
||||||
|
// ByClaimsEmail orders the results by the claims_email field.
|
||||||
|
func ByClaimsEmail(opts ...sql.OrderTermOption) OrderOption { |
||||||
|
return sql.OrderByField(FieldClaimsEmail, opts...).ToFunc() |
||||||
|
} |
||||||
|
|
||||||
|
// ByClaimsEmailVerified orders the results by the claims_email_verified field.
|
||||||
|
func ByClaimsEmailVerified(opts ...sql.OrderTermOption) OrderOption { |
||||||
|
return sql.OrderByField(FieldClaimsEmailVerified, opts...).ToFunc() |
||||||
|
} |
||||||
|
|
||||||
|
// ByCreatedAt orders the results by the created_at field.
|
||||||
|
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { |
||||||
|
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() |
||||||
|
} |
||||||
|
|
||||||
|
// ByLastLogin orders the results by the last_login field.
|
||||||
|
func ByLastLogin(opts ...sql.OrderTermOption) OrderOption { |
||||||
|
return sql.OrderByField(FieldLastLogin, opts...).ToFunc() |
||||||
|
} |
||||||
|
|
||||||
|
// ByBlockedUntil orders the results by the blocked_until field.
|
||||||
|
func ByBlockedUntil(opts ...sql.OrderTermOption) OrderOption { |
||||||
|
return sql.OrderByField(FieldBlockedUntil, opts...).ToFunc() |
||||||
|
} |
||||||
@ -0,0 +1,705 @@ |
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package useridentity |
||||||
|
|
||||||
|
import ( |
||||||
|
"time" |
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql" |
||||||
|
"github.com/dexidp/dex/storage/ent/db/predicate" |
||||||
|
) |
||||||
|
|
||||||
|
// ID filters vertices based on their ID field.
|
||||||
|
func ID(id string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldEQ(FieldID, id)) |
||||||
|
} |
||||||
|
|
||||||
|
// IDEQ applies the EQ predicate on the ID field.
|
||||||
|
func IDEQ(id string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldEQ(FieldID, id)) |
||||||
|
} |
||||||
|
|
||||||
|
// IDNEQ applies the NEQ predicate on the ID field.
|
||||||
|
func IDNEQ(id string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldNEQ(FieldID, id)) |
||||||
|
} |
||||||
|
|
||||||
|
// IDIn applies the In predicate on the ID field.
|
||||||
|
func IDIn(ids ...string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldIn(FieldID, ids...)) |
||||||
|
} |
||||||
|
|
||||||
|
// IDNotIn applies the NotIn predicate on the ID field.
|
||||||
|
func IDNotIn(ids ...string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldNotIn(FieldID, ids...)) |
||||||
|
} |
||||||
|
|
||||||
|
// IDGT applies the GT predicate on the ID field.
|
||||||
|
func IDGT(id string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldGT(FieldID, id)) |
||||||
|
} |
||||||
|
|
||||||
|
// IDGTE applies the GTE predicate on the ID field.
|
||||||
|
func IDGTE(id string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldGTE(FieldID, id)) |
||||||
|
} |
||||||
|
|
||||||
|
// IDLT applies the LT predicate on the ID field.
|
||||||
|
func IDLT(id string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldLT(FieldID, id)) |
||||||
|
} |
||||||
|
|
||||||
|
// IDLTE applies the LTE predicate on the ID field.
|
||||||
|
func IDLTE(id string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldLTE(FieldID, id)) |
||||||
|
} |
||||||
|
|
||||||
|
// IDEqualFold applies the EqualFold predicate on the ID field.
|
||||||
|
func IDEqualFold(id string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldEqualFold(FieldID, id)) |
||||||
|
} |
||||||
|
|
||||||
|
// IDContainsFold applies the ContainsFold predicate on the ID field.
|
||||||
|
func IDContainsFold(id string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldContainsFold(FieldID, id)) |
||||||
|
} |
||||||
|
|
||||||
|
// UserID applies equality check predicate on the "user_id" field. It's identical to UserIDEQ.
|
||||||
|
func UserID(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldEQ(FieldUserID, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ConnectorID applies equality check predicate on the "connector_id" field. It's identical to ConnectorIDEQ.
|
||||||
|
func ConnectorID(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldEQ(FieldConnectorID, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsUserID applies equality check predicate on the "claims_user_id" field. It's identical to ClaimsUserIDEQ.
|
||||||
|
func ClaimsUserID(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldEQ(FieldClaimsUserID, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsUsername applies equality check predicate on the "claims_username" field. It's identical to ClaimsUsernameEQ.
|
||||||
|
func ClaimsUsername(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldEQ(FieldClaimsUsername, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsPreferredUsername applies equality check predicate on the "claims_preferred_username" field. It's identical to ClaimsPreferredUsernameEQ.
|
||||||
|
func ClaimsPreferredUsername(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldEQ(FieldClaimsPreferredUsername, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsEmail applies equality check predicate on the "claims_email" field. It's identical to ClaimsEmailEQ.
|
||||||
|
func ClaimsEmail(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldEQ(FieldClaimsEmail, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsEmailVerified applies equality check predicate on the "claims_email_verified" field. It's identical to ClaimsEmailVerifiedEQ.
|
||||||
|
func ClaimsEmailVerified(v bool) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldEQ(FieldClaimsEmailVerified, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// Consents applies equality check predicate on the "consents" field. It's identical to ConsentsEQ.
|
||||||
|
func Consents(v []byte) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldEQ(FieldConsents, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
|
||||||
|
func CreatedAt(v time.Time) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldEQ(FieldCreatedAt, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// LastLogin applies equality check predicate on the "last_login" field. It's identical to LastLoginEQ.
|
||||||
|
func LastLogin(v time.Time) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldEQ(FieldLastLogin, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// BlockedUntil applies equality check predicate on the "blocked_until" field. It's identical to BlockedUntilEQ.
|
||||||
|
func BlockedUntil(v time.Time) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldEQ(FieldBlockedUntil, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// UserIDEQ applies the EQ predicate on the "user_id" field.
|
||||||
|
func UserIDEQ(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldEQ(FieldUserID, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// UserIDNEQ applies the NEQ predicate on the "user_id" field.
|
||||||
|
func UserIDNEQ(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldNEQ(FieldUserID, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// UserIDIn applies the In predicate on the "user_id" field.
|
||||||
|
func UserIDIn(vs ...string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldIn(FieldUserID, vs...)) |
||||||
|
} |
||||||
|
|
||||||
|
// UserIDNotIn applies the NotIn predicate on the "user_id" field.
|
||||||
|
func UserIDNotIn(vs ...string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldNotIn(FieldUserID, vs...)) |
||||||
|
} |
||||||
|
|
||||||
|
// UserIDGT applies the GT predicate on the "user_id" field.
|
||||||
|
func UserIDGT(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldGT(FieldUserID, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// UserIDGTE applies the GTE predicate on the "user_id" field.
|
||||||
|
func UserIDGTE(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldGTE(FieldUserID, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// UserIDLT applies the LT predicate on the "user_id" field.
|
||||||
|
func UserIDLT(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldLT(FieldUserID, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// UserIDLTE applies the LTE predicate on the "user_id" field.
|
||||||
|
func UserIDLTE(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldLTE(FieldUserID, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// UserIDContains applies the Contains predicate on the "user_id" field.
|
||||||
|
func UserIDContains(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldContains(FieldUserID, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// UserIDHasPrefix applies the HasPrefix predicate on the "user_id" field.
|
||||||
|
func UserIDHasPrefix(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldHasPrefix(FieldUserID, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// UserIDHasSuffix applies the HasSuffix predicate on the "user_id" field.
|
||||||
|
func UserIDHasSuffix(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldHasSuffix(FieldUserID, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// UserIDEqualFold applies the EqualFold predicate on the "user_id" field.
|
||||||
|
func UserIDEqualFold(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldEqualFold(FieldUserID, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// UserIDContainsFold applies the ContainsFold predicate on the "user_id" field.
|
||||||
|
func UserIDContainsFold(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldContainsFold(FieldUserID, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ConnectorIDEQ applies the EQ predicate on the "connector_id" field.
|
||||||
|
func ConnectorIDEQ(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldEQ(FieldConnectorID, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ConnectorIDNEQ applies the NEQ predicate on the "connector_id" field.
|
||||||
|
func ConnectorIDNEQ(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldNEQ(FieldConnectorID, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ConnectorIDIn applies the In predicate on the "connector_id" field.
|
||||||
|
func ConnectorIDIn(vs ...string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldIn(FieldConnectorID, vs...)) |
||||||
|
} |
||||||
|
|
||||||
|
// ConnectorIDNotIn applies the NotIn predicate on the "connector_id" field.
|
||||||
|
func ConnectorIDNotIn(vs ...string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldNotIn(FieldConnectorID, vs...)) |
||||||
|
} |
||||||
|
|
||||||
|
// ConnectorIDGT applies the GT predicate on the "connector_id" field.
|
||||||
|
func ConnectorIDGT(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldGT(FieldConnectorID, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ConnectorIDGTE applies the GTE predicate on the "connector_id" field.
|
||||||
|
func ConnectorIDGTE(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldGTE(FieldConnectorID, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ConnectorIDLT applies the LT predicate on the "connector_id" field.
|
||||||
|
func ConnectorIDLT(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldLT(FieldConnectorID, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ConnectorIDLTE applies the LTE predicate on the "connector_id" field.
|
||||||
|
func ConnectorIDLTE(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldLTE(FieldConnectorID, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ConnectorIDContains applies the Contains predicate on the "connector_id" field.
|
||||||
|
func ConnectorIDContains(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldContains(FieldConnectorID, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ConnectorIDHasPrefix applies the HasPrefix predicate on the "connector_id" field.
|
||||||
|
func ConnectorIDHasPrefix(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldHasPrefix(FieldConnectorID, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ConnectorIDHasSuffix applies the HasSuffix predicate on the "connector_id" field.
|
||||||
|
func ConnectorIDHasSuffix(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldHasSuffix(FieldConnectorID, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ConnectorIDEqualFold applies the EqualFold predicate on the "connector_id" field.
|
||||||
|
func ConnectorIDEqualFold(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldEqualFold(FieldConnectorID, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ConnectorIDContainsFold applies the ContainsFold predicate on the "connector_id" field.
|
||||||
|
func ConnectorIDContainsFold(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldContainsFold(FieldConnectorID, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsUserIDEQ applies the EQ predicate on the "claims_user_id" field.
|
||||||
|
func ClaimsUserIDEQ(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldEQ(FieldClaimsUserID, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsUserIDNEQ applies the NEQ predicate on the "claims_user_id" field.
|
||||||
|
func ClaimsUserIDNEQ(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldNEQ(FieldClaimsUserID, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsUserIDIn applies the In predicate on the "claims_user_id" field.
|
||||||
|
func ClaimsUserIDIn(vs ...string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldIn(FieldClaimsUserID, vs...)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsUserIDNotIn applies the NotIn predicate on the "claims_user_id" field.
|
||||||
|
func ClaimsUserIDNotIn(vs ...string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldNotIn(FieldClaimsUserID, vs...)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsUserIDGT applies the GT predicate on the "claims_user_id" field.
|
||||||
|
func ClaimsUserIDGT(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldGT(FieldClaimsUserID, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsUserIDGTE applies the GTE predicate on the "claims_user_id" field.
|
||||||
|
func ClaimsUserIDGTE(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldGTE(FieldClaimsUserID, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsUserIDLT applies the LT predicate on the "claims_user_id" field.
|
||||||
|
func ClaimsUserIDLT(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldLT(FieldClaimsUserID, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsUserIDLTE applies the LTE predicate on the "claims_user_id" field.
|
||||||
|
func ClaimsUserIDLTE(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldLTE(FieldClaimsUserID, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsUserIDContains applies the Contains predicate on the "claims_user_id" field.
|
||||||
|
func ClaimsUserIDContains(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldContains(FieldClaimsUserID, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsUserIDHasPrefix applies the HasPrefix predicate on the "claims_user_id" field.
|
||||||
|
func ClaimsUserIDHasPrefix(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldHasPrefix(FieldClaimsUserID, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsUserIDHasSuffix applies the HasSuffix predicate on the "claims_user_id" field.
|
||||||
|
func ClaimsUserIDHasSuffix(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldHasSuffix(FieldClaimsUserID, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsUserIDEqualFold applies the EqualFold predicate on the "claims_user_id" field.
|
||||||
|
func ClaimsUserIDEqualFold(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldEqualFold(FieldClaimsUserID, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsUserIDContainsFold applies the ContainsFold predicate on the "claims_user_id" field.
|
||||||
|
func ClaimsUserIDContainsFold(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldContainsFold(FieldClaimsUserID, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsUsernameEQ applies the EQ predicate on the "claims_username" field.
|
||||||
|
func ClaimsUsernameEQ(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldEQ(FieldClaimsUsername, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsUsernameNEQ applies the NEQ predicate on the "claims_username" field.
|
||||||
|
func ClaimsUsernameNEQ(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldNEQ(FieldClaimsUsername, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsUsernameIn applies the In predicate on the "claims_username" field.
|
||||||
|
func ClaimsUsernameIn(vs ...string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldIn(FieldClaimsUsername, vs...)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsUsernameNotIn applies the NotIn predicate on the "claims_username" field.
|
||||||
|
func ClaimsUsernameNotIn(vs ...string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldNotIn(FieldClaimsUsername, vs...)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsUsernameGT applies the GT predicate on the "claims_username" field.
|
||||||
|
func ClaimsUsernameGT(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldGT(FieldClaimsUsername, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsUsernameGTE applies the GTE predicate on the "claims_username" field.
|
||||||
|
func ClaimsUsernameGTE(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldGTE(FieldClaimsUsername, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsUsernameLT applies the LT predicate on the "claims_username" field.
|
||||||
|
func ClaimsUsernameLT(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldLT(FieldClaimsUsername, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsUsernameLTE applies the LTE predicate on the "claims_username" field.
|
||||||
|
func ClaimsUsernameLTE(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldLTE(FieldClaimsUsername, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsUsernameContains applies the Contains predicate on the "claims_username" field.
|
||||||
|
func ClaimsUsernameContains(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldContains(FieldClaimsUsername, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsUsernameHasPrefix applies the HasPrefix predicate on the "claims_username" field.
|
||||||
|
func ClaimsUsernameHasPrefix(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldHasPrefix(FieldClaimsUsername, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsUsernameHasSuffix applies the HasSuffix predicate on the "claims_username" field.
|
||||||
|
func ClaimsUsernameHasSuffix(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldHasSuffix(FieldClaimsUsername, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsUsernameEqualFold applies the EqualFold predicate on the "claims_username" field.
|
||||||
|
func ClaimsUsernameEqualFold(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldEqualFold(FieldClaimsUsername, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsUsernameContainsFold applies the ContainsFold predicate on the "claims_username" field.
|
||||||
|
func ClaimsUsernameContainsFold(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldContainsFold(FieldClaimsUsername, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsPreferredUsernameEQ applies the EQ predicate on the "claims_preferred_username" field.
|
||||||
|
func ClaimsPreferredUsernameEQ(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldEQ(FieldClaimsPreferredUsername, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsPreferredUsernameNEQ applies the NEQ predicate on the "claims_preferred_username" field.
|
||||||
|
func ClaimsPreferredUsernameNEQ(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldNEQ(FieldClaimsPreferredUsername, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsPreferredUsernameIn applies the In predicate on the "claims_preferred_username" field.
|
||||||
|
func ClaimsPreferredUsernameIn(vs ...string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldIn(FieldClaimsPreferredUsername, vs...)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsPreferredUsernameNotIn applies the NotIn predicate on the "claims_preferred_username" field.
|
||||||
|
func ClaimsPreferredUsernameNotIn(vs ...string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldNotIn(FieldClaimsPreferredUsername, vs...)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsPreferredUsernameGT applies the GT predicate on the "claims_preferred_username" field.
|
||||||
|
func ClaimsPreferredUsernameGT(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldGT(FieldClaimsPreferredUsername, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsPreferredUsernameGTE applies the GTE predicate on the "claims_preferred_username" field.
|
||||||
|
func ClaimsPreferredUsernameGTE(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldGTE(FieldClaimsPreferredUsername, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsPreferredUsernameLT applies the LT predicate on the "claims_preferred_username" field.
|
||||||
|
func ClaimsPreferredUsernameLT(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldLT(FieldClaimsPreferredUsername, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsPreferredUsernameLTE applies the LTE predicate on the "claims_preferred_username" field.
|
||||||
|
func ClaimsPreferredUsernameLTE(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldLTE(FieldClaimsPreferredUsername, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsPreferredUsernameContains applies the Contains predicate on the "claims_preferred_username" field.
|
||||||
|
func ClaimsPreferredUsernameContains(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldContains(FieldClaimsPreferredUsername, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsPreferredUsernameHasPrefix applies the HasPrefix predicate on the "claims_preferred_username" field.
|
||||||
|
func ClaimsPreferredUsernameHasPrefix(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldHasPrefix(FieldClaimsPreferredUsername, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsPreferredUsernameHasSuffix applies the HasSuffix predicate on the "claims_preferred_username" field.
|
||||||
|
func ClaimsPreferredUsernameHasSuffix(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldHasSuffix(FieldClaimsPreferredUsername, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsPreferredUsernameEqualFold applies the EqualFold predicate on the "claims_preferred_username" field.
|
||||||
|
func ClaimsPreferredUsernameEqualFold(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldEqualFold(FieldClaimsPreferredUsername, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsPreferredUsernameContainsFold applies the ContainsFold predicate on the "claims_preferred_username" field.
|
||||||
|
func ClaimsPreferredUsernameContainsFold(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldContainsFold(FieldClaimsPreferredUsername, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsEmailEQ applies the EQ predicate on the "claims_email" field.
|
||||||
|
func ClaimsEmailEQ(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldEQ(FieldClaimsEmail, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsEmailNEQ applies the NEQ predicate on the "claims_email" field.
|
||||||
|
func ClaimsEmailNEQ(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldNEQ(FieldClaimsEmail, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsEmailIn applies the In predicate on the "claims_email" field.
|
||||||
|
func ClaimsEmailIn(vs ...string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldIn(FieldClaimsEmail, vs...)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsEmailNotIn applies the NotIn predicate on the "claims_email" field.
|
||||||
|
func ClaimsEmailNotIn(vs ...string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldNotIn(FieldClaimsEmail, vs...)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsEmailGT applies the GT predicate on the "claims_email" field.
|
||||||
|
func ClaimsEmailGT(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldGT(FieldClaimsEmail, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsEmailGTE applies the GTE predicate on the "claims_email" field.
|
||||||
|
func ClaimsEmailGTE(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldGTE(FieldClaimsEmail, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsEmailLT applies the LT predicate on the "claims_email" field.
|
||||||
|
func ClaimsEmailLT(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldLT(FieldClaimsEmail, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsEmailLTE applies the LTE predicate on the "claims_email" field.
|
||||||
|
func ClaimsEmailLTE(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldLTE(FieldClaimsEmail, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsEmailContains applies the Contains predicate on the "claims_email" field.
|
||||||
|
func ClaimsEmailContains(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldContains(FieldClaimsEmail, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsEmailHasPrefix applies the HasPrefix predicate on the "claims_email" field.
|
||||||
|
func ClaimsEmailHasPrefix(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldHasPrefix(FieldClaimsEmail, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsEmailHasSuffix applies the HasSuffix predicate on the "claims_email" field.
|
||||||
|
func ClaimsEmailHasSuffix(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldHasSuffix(FieldClaimsEmail, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsEmailEqualFold applies the EqualFold predicate on the "claims_email" field.
|
||||||
|
func ClaimsEmailEqualFold(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldEqualFold(FieldClaimsEmail, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsEmailContainsFold applies the ContainsFold predicate on the "claims_email" field.
|
||||||
|
func ClaimsEmailContainsFold(v string) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldContainsFold(FieldClaimsEmail, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsEmailVerifiedEQ applies the EQ predicate on the "claims_email_verified" field.
|
||||||
|
func ClaimsEmailVerifiedEQ(v bool) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldEQ(FieldClaimsEmailVerified, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsEmailVerifiedNEQ applies the NEQ predicate on the "claims_email_verified" field.
|
||||||
|
func ClaimsEmailVerifiedNEQ(v bool) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldNEQ(FieldClaimsEmailVerified, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsGroupsIsNil applies the IsNil predicate on the "claims_groups" field.
|
||||||
|
func ClaimsGroupsIsNil() predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldIsNull(FieldClaimsGroups)) |
||||||
|
} |
||||||
|
|
||||||
|
// ClaimsGroupsNotNil applies the NotNil predicate on the "claims_groups" field.
|
||||||
|
func ClaimsGroupsNotNil() predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldNotNull(FieldClaimsGroups)) |
||||||
|
} |
||||||
|
|
||||||
|
// ConsentsEQ applies the EQ predicate on the "consents" field.
|
||||||
|
func ConsentsEQ(v []byte) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldEQ(FieldConsents, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ConsentsNEQ applies the NEQ predicate on the "consents" field.
|
||||||
|
func ConsentsNEQ(v []byte) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldNEQ(FieldConsents, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ConsentsIn applies the In predicate on the "consents" field.
|
||||||
|
func ConsentsIn(vs ...[]byte) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldIn(FieldConsents, vs...)) |
||||||
|
} |
||||||
|
|
||||||
|
// ConsentsNotIn applies the NotIn predicate on the "consents" field.
|
||||||
|
func ConsentsNotIn(vs ...[]byte) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldNotIn(FieldConsents, vs...)) |
||||||
|
} |
||||||
|
|
||||||
|
// ConsentsGT applies the GT predicate on the "consents" field.
|
||||||
|
func ConsentsGT(v []byte) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldGT(FieldConsents, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ConsentsGTE applies the GTE predicate on the "consents" field.
|
||||||
|
func ConsentsGTE(v []byte) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldGTE(FieldConsents, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ConsentsLT applies the LT predicate on the "consents" field.
|
||||||
|
func ConsentsLT(v []byte) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldLT(FieldConsents, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// ConsentsLTE applies the LTE predicate on the "consents" field.
|
||||||
|
func ConsentsLTE(v []byte) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldLTE(FieldConsents, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
|
||||||
|
func CreatedAtEQ(v time.Time) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldEQ(FieldCreatedAt, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
|
||||||
|
func CreatedAtNEQ(v time.Time) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldNEQ(FieldCreatedAt, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// CreatedAtIn applies the In predicate on the "created_at" field.
|
||||||
|
func CreatedAtIn(vs ...time.Time) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldIn(FieldCreatedAt, vs...)) |
||||||
|
} |
||||||
|
|
||||||
|
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
|
||||||
|
func CreatedAtNotIn(vs ...time.Time) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldNotIn(FieldCreatedAt, vs...)) |
||||||
|
} |
||||||
|
|
||||||
|
// CreatedAtGT applies the GT predicate on the "created_at" field.
|
||||||
|
func CreatedAtGT(v time.Time) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldGT(FieldCreatedAt, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
|
||||||
|
func CreatedAtGTE(v time.Time) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldGTE(FieldCreatedAt, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// CreatedAtLT applies the LT predicate on the "created_at" field.
|
||||||
|
func CreatedAtLT(v time.Time) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldLT(FieldCreatedAt, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
|
||||||
|
func CreatedAtLTE(v time.Time) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldLTE(FieldCreatedAt, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// LastLoginEQ applies the EQ predicate on the "last_login" field.
|
||||||
|
func LastLoginEQ(v time.Time) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldEQ(FieldLastLogin, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// LastLoginNEQ applies the NEQ predicate on the "last_login" field.
|
||||||
|
func LastLoginNEQ(v time.Time) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldNEQ(FieldLastLogin, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// LastLoginIn applies the In predicate on the "last_login" field.
|
||||||
|
func LastLoginIn(vs ...time.Time) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldIn(FieldLastLogin, vs...)) |
||||||
|
} |
||||||
|
|
||||||
|
// LastLoginNotIn applies the NotIn predicate on the "last_login" field.
|
||||||
|
func LastLoginNotIn(vs ...time.Time) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldNotIn(FieldLastLogin, vs...)) |
||||||
|
} |
||||||
|
|
||||||
|
// LastLoginGT applies the GT predicate on the "last_login" field.
|
||||||
|
func LastLoginGT(v time.Time) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldGT(FieldLastLogin, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// LastLoginGTE applies the GTE predicate on the "last_login" field.
|
||||||
|
func LastLoginGTE(v time.Time) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldGTE(FieldLastLogin, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// LastLoginLT applies the LT predicate on the "last_login" field.
|
||||||
|
func LastLoginLT(v time.Time) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldLT(FieldLastLogin, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// LastLoginLTE applies the LTE predicate on the "last_login" field.
|
||||||
|
func LastLoginLTE(v time.Time) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldLTE(FieldLastLogin, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// BlockedUntilEQ applies the EQ predicate on the "blocked_until" field.
|
||||||
|
func BlockedUntilEQ(v time.Time) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldEQ(FieldBlockedUntil, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// BlockedUntilNEQ applies the NEQ predicate on the "blocked_until" field.
|
||||||
|
func BlockedUntilNEQ(v time.Time) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldNEQ(FieldBlockedUntil, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// BlockedUntilIn applies the In predicate on the "blocked_until" field.
|
||||||
|
func BlockedUntilIn(vs ...time.Time) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldIn(FieldBlockedUntil, vs...)) |
||||||
|
} |
||||||
|
|
||||||
|
// BlockedUntilNotIn applies the NotIn predicate on the "blocked_until" field.
|
||||||
|
func BlockedUntilNotIn(vs ...time.Time) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldNotIn(FieldBlockedUntil, vs...)) |
||||||
|
} |
||||||
|
|
||||||
|
// BlockedUntilGT applies the GT predicate on the "blocked_until" field.
|
||||||
|
func BlockedUntilGT(v time.Time) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldGT(FieldBlockedUntil, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// BlockedUntilGTE applies the GTE predicate on the "blocked_until" field.
|
||||||
|
func BlockedUntilGTE(v time.Time) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldGTE(FieldBlockedUntil, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// BlockedUntilLT applies the LT predicate on the "blocked_until" field.
|
||||||
|
func BlockedUntilLT(v time.Time) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldLT(FieldBlockedUntil, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// BlockedUntilLTE applies the LTE predicate on the "blocked_until" field.
|
||||||
|
func BlockedUntilLTE(v time.Time) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.FieldLTE(FieldBlockedUntil, v)) |
||||||
|
} |
||||||
|
|
||||||
|
// And groups predicates with the AND operator between them.
|
||||||
|
func And(predicates ...predicate.UserIdentity) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.AndPredicates(predicates...)) |
||||||
|
} |
||||||
|
|
||||||
|
// Or groups predicates with the OR operator between them.
|
||||||
|
func Or(predicates ...predicate.UserIdentity) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.OrPredicates(predicates...)) |
||||||
|
} |
||||||
|
|
||||||
|
// Not applies the not operator on the given predicate.
|
||||||
|
func Not(p predicate.UserIdentity) predicate.UserIdentity { |
||||||
|
return predicate.UserIdentity(sql.NotPredicates(p)) |
||||||
|
} |
||||||
@ -0,0 +1,416 @@ |
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package db |
||||||
|
|
||||||
|
import ( |
||||||
|
"context" |
||||||
|
"errors" |
||||||
|
"fmt" |
||||||
|
"time" |
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph" |
||||||
|
"entgo.io/ent/schema/field" |
||||||
|
"github.com/dexidp/dex/storage/ent/db/useridentity" |
||||||
|
) |
||||||
|
|
||||||
|
// UserIdentityCreate is the builder for creating a UserIdentity entity.
|
||||||
|
type UserIdentityCreate struct { |
||||||
|
config |
||||||
|
mutation *UserIdentityMutation |
||||||
|
hooks []Hook |
||||||
|
} |
||||||
|
|
||||||
|
// SetUserID sets the "user_id" field.
|
||||||
|
func (_c *UserIdentityCreate) SetUserID(v string) *UserIdentityCreate { |
||||||
|
_c.mutation.SetUserID(v) |
||||||
|
return _c |
||||||
|
} |
||||||
|
|
||||||
|
// SetConnectorID sets the "connector_id" field.
|
||||||
|
func (_c *UserIdentityCreate) SetConnectorID(v string) *UserIdentityCreate { |
||||||
|
_c.mutation.SetConnectorID(v) |
||||||
|
return _c |
||||||
|
} |
||||||
|
|
||||||
|
// SetClaimsUserID sets the "claims_user_id" field.
|
||||||
|
func (_c *UserIdentityCreate) SetClaimsUserID(v string) *UserIdentityCreate { |
||||||
|
_c.mutation.SetClaimsUserID(v) |
||||||
|
return _c |
||||||
|
} |
||||||
|
|
||||||
|
// SetNillableClaimsUserID sets the "claims_user_id" field if the given value is not nil.
|
||||||
|
func (_c *UserIdentityCreate) SetNillableClaimsUserID(v *string) *UserIdentityCreate { |
||||||
|
if v != nil { |
||||||
|
_c.SetClaimsUserID(*v) |
||||||
|
} |
||||||
|
return _c |
||||||
|
} |
||||||
|
|
||||||
|
// SetClaimsUsername sets the "claims_username" field.
|
||||||
|
func (_c *UserIdentityCreate) SetClaimsUsername(v string) *UserIdentityCreate { |
||||||
|
_c.mutation.SetClaimsUsername(v) |
||||||
|
return _c |
||||||
|
} |
||||||
|
|
||||||
|
// SetNillableClaimsUsername sets the "claims_username" field if the given value is not nil.
|
||||||
|
func (_c *UserIdentityCreate) SetNillableClaimsUsername(v *string) *UserIdentityCreate { |
||||||
|
if v != nil { |
||||||
|
_c.SetClaimsUsername(*v) |
||||||
|
} |
||||||
|
return _c |
||||||
|
} |
||||||
|
|
||||||
|
// SetClaimsPreferredUsername sets the "claims_preferred_username" field.
|
||||||
|
func (_c *UserIdentityCreate) SetClaimsPreferredUsername(v string) *UserIdentityCreate { |
||||||
|
_c.mutation.SetClaimsPreferredUsername(v) |
||||||
|
return _c |
||||||
|
} |
||||||
|
|
||||||
|
// SetNillableClaimsPreferredUsername sets the "claims_preferred_username" field if the given value is not nil.
|
||||||
|
func (_c *UserIdentityCreate) SetNillableClaimsPreferredUsername(v *string) *UserIdentityCreate { |
||||||
|
if v != nil { |
||||||
|
_c.SetClaimsPreferredUsername(*v) |
||||||
|
} |
||||||
|
return _c |
||||||
|
} |
||||||
|
|
||||||
|
// SetClaimsEmail sets the "claims_email" field.
|
||||||
|
func (_c *UserIdentityCreate) SetClaimsEmail(v string) *UserIdentityCreate { |
||||||
|
_c.mutation.SetClaimsEmail(v) |
||||||
|
return _c |
||||||
|
} |
||||||
|
|
||||||
|
// SetNillableClaimsEmail sets the "claims_email" field if the given value is not nil.
|
||||||
|
func (_c *UserIdentityCreate) SetNillableClaimsEmail(v *string) *UserIdentityCreate { |
||||||
|
if v != nil { |
||||||
|
_c.SetClaimsEmail(*v) |
||||||
|
} |
||||||
|
return _c |
||||||
|
} |
||||||
|
|
||||||
|
// SetClaimsEmailVerified sets the "claims_email_verified" field.
|
||||||
|
func (_c *UserIdentityCreate) SetClaimsEmailVerified(v bool) *UserIdentityCreate { |
||||||
|
_c.mutation.SetClaimsEmailVerified(v) |
||||||
|
return _c |
||||||
|
} |
||||||
|
|
||||||
|
// SetNillableClaimsEmailVerified sets the "claims_email_verified" field if the given value is not nil.
|
||||||
|
func (_c *UserIdentityCreate) SetNillableClaimsEmailVerified(v *bool) *UserIdentityCreate { |
||||||
|
if v != nil { |
||||||
|
_c.SetClaimsEmailVerified(*v) |
||||||
|
} |
||||||
|
return _c |
||||||
|
} |
||||||
|
|
||||||
|
// SetClaimsGroups sets the "claims_groups" field.
|
||||||
|
func (_c *UserIdentityCreate) SetClaimsGroups(v []string) *UserIdentityCreate { |
||||||
|
_c.mutation.SetClaimsGroups(v) |
||||||
|
return _c |
||||||
|
} |
||||||
|
|
||||||
|
// SetConsents sets the "consents" field.
|
||||||
|
func (_c *UserIdentityCreate) SetConsents(v []byte) *UserIdentityCreate { |
||||||
|
_c.mutation.SetConsents(v) |
||||||
|
return _c |
||||||
|
} |
||||||
|
|
||||||
|
// SetCreatedAt sets the "created_at" field.
|
||||||
|
func (_c *UserIdentityCreate) SetCreatedAt(v time.Time) *UserIdentityCreate { |
||||||
|
_c.mutation.SetCreatedAt(v) |
||||||
|
return _c |
||||||
|
} |
||||||
|
|
||||||
|
// SetLastLogin sets the "last_login" field.
|
||||||
|
func (_c *UserIdentityCreate) SetLastLogin(v time.Time) *UserIdentityCreate { |
||||||
|
_c.mutation.SetLastLogin(v) |
||||||
|
return _c |
||||||
|
} |
||||||
|
|
||||||
|
// SetBlockedUntil sets the "blocked_until" field.
|
||||||
|
func (_c *UserIdentityCreate) SetBlockedUntil(v time.Time) *UserIdentityCreate { |
||||||
|
_c.mutation.SetBlockedUntil(v) |
||||||
|
return _c |
||||||
|
} |
||||||
|
|
||||||
|
// SetID sets the "id" field.
|
||||||
|
func (_c *UserIdentityCreate) SetID(v string) *UserIdentityCreate { |
||||||
|
_c.mutation.SetID(v) |
||||||
|
return _c |
||||||
|
} |
||||||
|
|
||||||
|
// Mutation returns the UserIdentityMutation object of the builder.
|
||||||
|
func (_c *UserIdentityCreate) Mutation() *UserIdentityMutation { |
||||||
|
return _c.mutation |
||||||
|
} |
||||||
|
|
||||||
|
// Save creates the UserIdentity in the database.
|
||||||
|
func (_c *UserIdentityCreate) Save(ctx context.Context) (*UserIdentity, error) { |
||||||
|
_c.defaults() |
||||||
|
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) |
||||||
|
} |
||||||
|
|
||||||
|
// SaveX calls Save and panics if Save returns an error.
|
||||||
|
func (_c *UserIdentityCreate) SaveX(ctx context.Context) *UserIdentity { |
||||||
|
v, err := _c.Save(ctx) |
||||||
|
if err != nil { |
||||||
|
panic(err) |
||||||
|
} |
||||||
|
return v |
||||||
|
} |
||||||
|
|
||||||
|
// Exec executes the query.
|
||||||
|
func (_c *UserIdentityCreate) Exec(ctx context.Context) error { |
||||||
|
_, err := _c.Save(ctx) |
||||||
|
return err |
||||||
|
} |
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (_c *UserIdentityCreate) ExecX(ctx context.Context) { |
||||||
|
if err := _c.Exec(ctx); err != nil { |
||||||
|
panic(err) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// defaults sets the default values of the builder before save.
|
||||||
|
func (_c *UserIdentityCreate) defaults() { |
||||||
|
if _, ok := _c.mutation.ClaimsUserID(); !ok { |
||||||
|
v := useridentity.DefaultClaimsUserID |
||||||
|
_c.mutation.SetClaimsUserID(v) |
||||||
|
} |
||||||
|
if _, ok := _c.mutation.ClaimsUsername(); !ok { |
||||||
|
v := useridentity.DefaultClaimsUsername |
||||||
|
_c.mutation.SetClaimsUsername(v) |
||||||
|
} |
||||||
|
if _, ok := _c.mutation.ClaimsPreferredUsername(); !ok { |
||||||
|
v := useridentity.DefaultClaimsPreferredUsername |
||||||
|
_c.mutation.SetClaimsPreferredUsername(v) |
||||||
|
} |
||||||
|
if _, ok := _c.mutation.ClaimsEmail(); !ok { |
||||||
|
v := useridentity.DefaultClaimsEmail |
||||||
|
_c.mutation.SetClaimsEmail(v) |
||||||
|
} |
||||||
|
if _, ok := _c.mutation.ClaimsEmailVerified(); !ok { |
||||||
|
v := useridentity.DefaultClaimsEmailVerified |
||||||
|
_c.mutation.SetClaimsEmailVerified(v) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// check runs all checks and user-defined validators on the builder.
|
||||||
|
func (_c *UserIdentityCreate) check() error { |
||||||
|
if _, ok := _c.mutation.UserID(); !ok { |
||||||
|
return &ValidationError{Name: "user_id", err: errors.New(`db: missing required field "UserIdentity.user_id"`)} |
||||||
|
} |
||||||
|
if v, ok := _c.mutation.UserID(); ok { |
||||||
|
if err := useridentity.UserIDValidator(v); err != nil { |
||||||
|
return &ValidationError{Name: "user_id", err: fmt.Errorf(`db: validator failed for field "UserIdentity.user_id": %w`, err)} |
||||||
|
} |
||||||
|
} |
||||||
|
if _, ok := _c.mutation.ConnectorID(); !ok { |
||||||
|
return &ValidationError{Name: "connector_id", err: errors.New(`db: missing required field "UserIdentity.connector_id"`)} |
||||||
|
} |
||||||
|
if v, ok := _c.mutation.ConnectorID(); ok { |
||||||
|
if err := useridentity.ConnectorIDValidator(v); err != nil { |
||||||
|
return &ValidationError{Name: "connector_id", err: fmt.Errorf(`db: validator failed for field "UserIdentity.connector_id": %w`, err)} |
||||||
|
} |
||||||
|
} |
||||||
|
if _, ok := _c.mutation.ClaimsUserID(); !ok { |
||||||
|
return &ValidationError{Name: "claims_user_id", err: errors.New(`db: missing required field "UserIdentity.claims_user_id"`)} |
||||||
|
} |
||||||
|
if _, ok := _c.mutation.ClaimsUsername(); !ok { |
||||||
|
return &ValidationError{Name: "claims_username", err: errors.New(`db: missing required field "UserIdentity.claims_username"`)} |
||||||
|
} |
||||||
|
if _, ok := _c.mutation.ClaimsPreferredUsername(); !ok { |
||||||
|
return &ValidationError{Name: "claims_preferred_username", err: errors.New(`db: missing required field "UserIdentity.claims_preferred_username"`)} |
||||||
|
} |
||||||
|
if _, ok := _c.mutation.ClaimsEmail(); !ok { |
||||||
|
return &ValidationError{Name: "claims_email", err: errors.New(`db: missing required field "UserIdentity.claims_email"`)} |
||||||
|
} |
||||||
|
if _, ok := _c.mutation.ClaimsEmailVerified(); !ok { |
||||||
|
return &ValidationError{Name: "claims_email_verified", err: errors.New(`db: missing required field "UserIdentity.claims_email_verified"`)} |
||||||
|
} |
||||||
|
if _, ok := _c.mutation.Consents(); !ok { |
||||||
|
return &ValidationError{Name: "consents", err: errors.New(`db: missing required field "UserIdentity.consents"`)} |
||||||
|
} |
||||||
|
if _, ok := _c.mutation.CreatedAt(); !ok { |
||||||
|
return &ValidationError{Name: "created_at", err: errors.New(`db: missing required field "UserIdentity.created_at"`)} |
||||||
|
} |
||||||
|
if _, ok := _c.mutation.LastLogin(); !ok { |
||||||
|
return &ValidationError{Name: "last_login", err: errors.New(`db: missing required field "UserIdentity.last_login"`)} |
||||||
|
} |
||||||
|
if _, ok := _c.mutation.BlockedUntil(); !ok { |
||||||
|
return &ValidationError{Name: "blocked_until", err: errors.New(`db: missing required field "UserIdentity.blocked_until"`)} |
||||||
|
} |
||||||
|
if v, ok := _c.mutation.ID(); ok { |
||||||
|
if err := useridentity.IDValidator(v); err != nil { |
||||||
|
return &ValidationError{Name: "id", err: fmt.Errorf(`db: validator failed for field "UserIdentity.id": %w`, err)} |
||||||
|
} |
||||||
|
} |
||||||
|
return nil |
||||||
|
} |
||||||
|
|
||||||
|
func (_c *UserIdentityCreate) sqlSave(ctx context.Context) (*UserIdentity, error) { |
||||||
|
if err := _c.check(); err != nil { |
||||||
|
return nil, err |
||||||
|
} |
||||||
|
_node, _spec := _c.createSpec() |
||||||
|
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { |
||||||
|
if sqlgraph.IsConstraintError(err) { |
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err} |
||||||
|
} |
||||||
|
return nil, err |
||||||
|
} |
||||||
|
if _spec.ID.Value != nil { |
||||||
|
if id, ok := _spec.ID.Value.(string); ok { |
||||||
|
_node.ID = id |
||||||
|
} else { |
||||||
|
return nil, fmt.Errorf("unexpected UserIdentity.ID type: %T", _spec.ID.Value) |
||||||
|
} |
||||||
|
} |
||||||
|
_c.mutation.id = &_node.ID |
||||||
|
_c.mutation.done = true |
||||||
|
return _node, nil |
||||||
|
} |
||||||
|
|
||||||
|
func (_c *UserIdentityCreate) createSpec() (*UserIdentity, *sqlgraph.CreateSpec) { |
||||||
|
var ( |
||||||
|
_node = &UserIdentity{config: _c.config} |
||||||
|
_spec = sqlgraph.NewCreateSpec(useridentity.Table, sqlgraph.NewFieldSpec(useridentity.FieldID, field.TypeString)) |
||||||
|
) |
||||||
|
if id, ok := _c.mutation.ID(); ok { |
||||||
|
_node.ID = id |
||||||
|
_spec.ID.Value = id |
||||||
|
} |
||||||
|
if value, ok := _c.mutation.UserID(); ok { |
||||||
|
_spec.SetField(useridentity.FieldUserID, field.TypeString, value) |
||||||
|
_node.UserID = value |
||||||
|
} |
||||||
|
if value, ok := _c.mutation.ConnectorID(); ok { |
||||||
|
_spec.SetField(useridentity.FieldConnectorID, field.TypeString, value) |
||||||
|
_node.ConnectorID = value |
||||||
|
} |
||||||
|
if value, ok := _c.mutation.ClaimsUserID(); ok { |
||||||
|
_spec.SetField(useridentity.FieldClaimsUserID, field.TypeString, value) |
||||||
|
_node.ClaimsUserID = value |
||||||
|
} |
||||||
|
if value, ok := _c.mutation.ClaimsUsername(); ok { |
||||||
|
_spec.SetField(useridentity.FieldClaimsUsername, field.TypeString, value) |
||||||
|
_node.ClaimsUsername = value |
||||||
|
} |
||||||
|
if value, ok := _c.mutation.ClaimsPreferredUsername(); ok { |
||||||
|
_spec.SetField(useridentity.FieldClaimsPreferredUsername, field.TypeString, value) |
||||||
|
_node.ClaimsPreferredUsername = value |
||||||
|
} |
||||||
|
if value, ok := _c.mutation.ClaimsEmail(); ok { |
||||||
|
_spec.SetField(useridentity.FieldClaimsEmail, field.TypeString, value) |
||||||
|
_node.ClaimsEmail = value |
||||||
|
} |
||||||
|
if value, ok := _c.mutation.ClaimsEmailVerified(); ok { |
||||||
|
_spec.SetField(useridentity.FieldClaimsEmailVerified, field.TypeBool, value) |
||||||
|
_node.ClaimsEmailVerified = value |
||||||
|
} |
||||||
|
if value, ok := _c.mutation.ClaimsGroups(); ok { |
||||||
|
_spec.SetField(useridentity.FieldClaimsGroups, field.TypeJSON, value) |
||||||
|
_node.ClaimsGroups = value |
||||||
|
} |
||||||
|
if value, ok := _c.mutation.Consents(); ok { |
||||||
|
_spec.SetField(useridentity.FieldConsents, field.TypeBytes, value) |
||||||
|
_node.Consents = value |
||||||
|
} |
||||||
|
if value, ok := _c.mutation.CreatedAt(); ok { |
||||||
|
_spec.SetField(useridentity.FieldCreatedAt, field.TypeTime, value) |
||||||
|
_node.CreatedAt = value |
||||||
|
} |
||||||
|
if value, ok := _c.mutation.LastLogin(); ok { |
||||||
|
_spec.SetField(useridentity.FieldLastLogin, field.TypeTime, value) |
||||||
|
_node.LastLogin = value |
||||||
|
} |
||||||
|
if value, ok := _c.mutation.BlockedUntil(); ok { |
||||||
|
_spec.SetField(useridentity.FieldBlockedUntil, field.TypeTime, value) |
||||||
|
_node.BlockedUntil = value |
||||||
|
} |
||||||
|
return _node, _spec |
||||||
|
} |
||||||
|
|
||||||
|
// UserIdentityCreateBulk is the builder for creating many UserIdentity entities in bulk.
|
||||||
|
type UserIdentityCreateBulk struct { |
||||||
|
config |
||||||
|
err error |
||||||
|
builders []*UserIdentityCreate |
||||||
|
} |
||||||
|
|
||||||
|
// Save creates the UserIdentity entities in the database.
|
||||||
|
func (_c *UserIdentityCreateBulk) Save(ctx context.Context) ([]*UserIdentity, error) { |
||||||
|
if _c.err != nil { |
||||||
|
return nil, _c.err |
||||||
|
} |
||||||
|
specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) |
||||||
|
nodes := make([]*UserIdentity, len(_c.builders)) |
||||||
|
mutators := make([]Mutator, len(_c.builders)) |
||||||
|
for i := range _c.builders { |
||||||
|
func(i int, root context.Context) { |
||||||
|
builder := _c.builders[i] |
||||||
|
builder.defaults() |
||||||
|
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { |
||||||
|
mutation, ok := m.(*UserIdentityMutation) |
||||||
|
if !ok { |
||||||
|
return nil, fmt.Errorf("unexpected mutation type %T", m) |
||||||
|
} |
||||||
|
if err := builder.check(); err != nil { |
||||||
|
return nil, err |
||||||
|
} |
||||||
|
builder.mutation = mutation |
||||||
|
var err error |
||||||
|
nodes[i], specs[i] = builder.createSpec() |
||||||
|
if i < len(mutators)-1 { |
||||||
|
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) |
||||||
|
} else { |
||||||
|
spec := &sqlgraph.BatchCreateSpec{Nodes: specs} |
||||||
|
// Invoke the actual operation on the latest mutation in the chain.
|
||||||
|
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { |
||||||
|
if sqlgraph.IsConstraintError(err) { |
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
if err != nil { |
||||||
|
return nil, err |
||||||
|
} |
||||||
|
mutation.id = &nodes[i].ID |
||||||
|
mutation.done = true |
||||||
|
return nodes[i], nil |
||||||
|
}) |
||||||
|
for i := len(builder.hooks) - 1; i >= 0; i-- { |
||||||
|
mut = builder.hooks[i](mut) |
||||||
|
} |
||||||
|
mutators[i] = mut |
||||||
|
}(i, ctx) |
||||||
|
} |
||||||
|
if len(mutators) > 0 { |
||||||
|
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { |
||||||
|
return nil, err |
||||||
|
} |
||||||
|
} |
||||||
|
return nodes, nil |
||||||
|
} |
||||||
|
|
||||||
|
// SaveX is like Save, but panics if an error occurs.
|
||||||
|
func (_c *UserIdentityCreateBulk) SaveX(ctx context.Context) []*UserIdentity { |
||||||
|
v, err := _c.Save(ctx) |
||||||
|
if err != nil { |
||||||
|
panic(err) |
||||||
|
} |
||||||
|
return v |
||||||
|
} |
||||||
|
|
||||||
|
// Exec executes the query.
|
||||||
|
func (_c *UserIdentityCreateBulk) Exec(ctx context.Context) error { |
||||||
|
_, err := _c.Save(ctx) |
||||||
|
return err |
||||||
|
} |
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (_c *UserIdentityCreateBulk) ExecX(ctx context.Context) { |
||||||
|
if err := _c.Exec(ctx); err != nil { |
||||||
|
panic(err) |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,88 @@ |
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package db |
||||||
|
|
||||||
|
import ( |
||||||
|
"context" |
||||||
|
|
||||||
|
"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/useridentity" |
||||||
|
) |
||||||
|
|
||||||
|
// UserIdentityDelete is the builder for deleting a UserIdentity entity.
|
||||||
|
type UserIdentityDelete struct { |
||||||
|
config |
||||||
|
hooks []Hook |
||||||
|
mutation *UserIdentityMutation |
||||||
|
} |
||||||
|
|
||||||
|
// Where appends a list predicates to the UserIdentityDelete builder.
|
||||||
|
func (_d *UserIdentityDelete) Where(ps ...predicate.UserIdentity) *UserIdentityDelete { |
||||||
|
_d.mutation.Where(ps...) |
||||||
|
return _d |
||||||
|
} |
||||||
|
|
||||||
|
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||||
|
func (_d *UserIdentityDelete) Exec(ctx context.Context) (int, error) { |
||||||
|
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) |
||||||
|
} |
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (_d *UserIdentityDelete) ExecX(ctx context.Context) int { |
||||||
|
n, err := _d.Exec(ctx) |
||||||
|
if err != nil { |
||||||
|
panic(err) |
||||||
|
} |
||||||
|
return n |
||||||
|
} |
||||||
|
|
||||||
|
func (_d *UserIdentityDelete) sqlExec(ctx context.Context) (int, error) { |
||||||
|
_spec := sqlgraph.NewDeleteSpec(useridentity.Table, sqlgraph.NewFieldSpec(useridentity.FieldID, field.TypeString)) |
||||||
|
if ps := _d.mutation.predicates; len(ps) > 0 { |
||||||
|
_spec.Predicate = func(selector *sql.Selector) { |
||||||
|
for i := range ps { |
||||||
|
ps[i](selector) |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) |
||||||
|
if err != nil && sqlgraph.IsConstraintError(err) { |
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err} |
||||||
|
} |
||||||
|
_d.mutation.done = true |
||||||
|
return affected, err |
||||||
|
} |
||||||
|
|
||||||
|
// UserIdentityDeleteOne is the builder for deleting a single UserIdentity entity.
|
||||||
|
type UserIdentityDeleteOne struct { |
||||||
|
_d *UserIdentityDelete |
||||||
|
} |
||||||
|
|
||||||
|
// Where appends a list predicates to the UserIdentityDelete builder.
|
||||||
|
func (_d *UserIdentityDeleteOne) Where(ps ...predicate.UserIdentity) *UserIdentityDeleteOne { |
||||||
|
_d._d.mutation.Where(ps...) |
||||||
|
return _d |
||||||
|
} |
||||||
|
|
||||||
|
// Exec executes the deletion query.
|
||||||
|
func (_d *UserIdentityDeleteOne) Exec(ctx context.Context) error { |
||||||
|
n, err := _d._d.Exec(ctx) |
||||||
|
switch { |
||||||
|
case err != nil: |
||||||
|
return err |
||||||
|
case n == 0: |
||||||
|
return &NotFoundError{useridentity.Label} |
||||||
|
default: |
||||||
|
return nil |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (_d *UserIdentityDeleteOne) ExecX(ctx context.Context) { |
||||||
|
if err := _d.Exec(ctx); err != nil { |
||||||
|
panic(err) |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,527 @@ |
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package db |
||||||
|
|
||||||
|
import ( |
||||||
|
"context" |
||||||
|
"fmt" |
||||||
|
"math" |
||||||
|
|
||||||
|
"entgo.io/ent" |
||||||
|
"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/useridentity" |
||||||
|
) |
||||||
|
|
||||||
|
// UserIdentityQuery is the builder for querying UserIdentity entities.
|
||||||
|
type UserIdentityQuery struct { |
||||||
|
config |
||||||
|
ctx *QueryContext |
||||||
|
order []useridentity.OrderOption |
||||||
|
inters []Interceptor |
||||||
|
predicates []predicate.UserIdentity |
||||||
|
// intermediate query (i.e. traversal path).
|
||||||
|
sql *sql.Selector |
||||||
|
path func(context.Context) (*sql.Selector, error) |
||||||
|
} |
||||||
|
|
||||||
|
// Where adds a new predicate for the UserIdentityQuery builder.
|
||||||
|
func (_q *UserIdentityQuery) Where(ps ...predicate.UserIdentity) *UserIdentityQuery { |
||||||
|
_q.predicates = append(_q.predicates, ps...) |
||||||
|
return _q |
||||||
|
} |
||||||
|
|
||||||
|
// Limit the number of records to be returned by this query.
|
||||||
|
func (_q *UserIdentityQuery) Limit(limit int) *UserIdentityQuery { |
||||||
|
_q.ctx.Limit = &limit |
||||||
|
return _q |
||||||
|
} |
||||||
|
|
||||||
|
// Offset to start from.
|
||||||
|
func (_q *UserIdentityQuery) Offset(offset int) *UserIdentityQuery { |
||||||
|
_q.ctx.Offset = &offset |
||||||
|
return _q |
||||||
|
} |
||||||
|
|
||||||
|
// 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 (_q *UserIdentityQuery) Unique(unique bool) *UserIdentityQuery { |
||||||
|
_q.ctx.Unique = &unique |
||||||
|
return _q |
||||||
|
} |
||||||
|
|
||||||
|
// Order specifies how the records should be ordered.
|
||||||
|
func (_q *UserIdentityQuery) Order(o ...useridentity.OrderOption) *UserIdentityQuery { |
||||||
|
_q.order = append(_q.order, o...) |
||||||
|
return _q |
||||||
|
} |
||||||
|
|
||||||
|
// First returns the first UserIdentity entity from the query.
|
||||||
|
// Returns a *NotFoundError when no UserIdentity was found.
|
||||||
|
func (_q *UserIdentityQuery) First(ctx context.Context) (*UserIdentity, error) { |
||||||
|
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) |
||||||
|
if err != nil { |
||||||
|
return nil, err |
||||||
|
} |
||||||
|
if len(nodes) == 0 { |
||||||
|
return nil, &NotFoundError{useridentity.Label} |
||||||
|
} |
||||||
|
return nodes[0], nil |
||||||
|
} |
||||||
|
|
||||||
|
// FirstX is like First, but panics if an error occurs.
|
||||||
|
func (_q *UserIdentityQuery) FirstX(ctx context.Context) *UserIdentity { |
||||||
|
node, err := _q.First(ctx) |
||||||
|
if err != nil && !IsNotFound(err) { |
||||||
|
panic(err) |
||||||
|
} |
||||||
|
return node |
||||||
|
} |
||||||
|
|
||||||
|
// FirstID returns the first UserIdentity ID from the query.
|
||||||
|
// Returns a *NotFoundError when no UserIdentity ID was found.
|
||||||
|
func (_q *UserIdentityQuery) FirstID(ctx context.Context) (id string, err error) { |
||||||
|
var ids []string |
||||||
|
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { |
||||||
|
return |
||||||
|
} |
||||||
|
if len(ids) == 0 { |
||||||
|
err = &NotFoundError{useridentity.Label} |
||||||
|
return |
||||||
|
} |
||||||
|
return ids[0], nil |
||||||
|
} |
||||||
|
|
||||||
|
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||||
|
func (_q *UserIdentityQuery) FirstIDX(ctx context.Context) string { |
||||||
|
id, err := _q.FirstID(ctx) |
||||||
|
if err != nil && !IsNotFound(err) { |
||||||
|
panic(err) |
||||||
|
} |
||||||
|
return id |
||||||
|
} |
||||||
|
|
||||||
|
// Only returns a single UserIdentity entity found by the query, ensuring it only returns one.
|
||||||
|
// Returns a *NotSingularError when more than one UserIdentity entity is found.
|
||||||
|
// Returns a *NotFoundError when no UserIdentity entities are found.
|
||||||
|
func (_q *UserIdentityQuery) Only(ctx context.Context) (*UserIdentity, error) { |
||||||
|
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) |
||||||
|
if err != nil { |
||||||
|
return nil, err |
||||||
|
} |
||||||
|
switch len(nodes) { |
||||||
|
case 1: |
||||||
|
return nodes[0], nil |
||||||
|
case 0: |
||||||
|
return nil, &NotFoundError{useridentity.Label} |
||||||
|
default: |
||||||
|
return nil, &NotSingularError{useridentity.Label} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// OnlyX is like Only, but panics if an error occurs.
|
||||||
|
func (_q *UserIdentityQuery) OnlyX(ctx context.Context) *UserIdentity { |
||||||
|
node, err := _q.Only(ctx) |
||||||
|
if err != nil { |
||||||
|
panic(err) |
||||||
|
} |
||||||
|
return node |
||||||
|
} |
||||||
|
|
||||||
|
// OnlyID is like Only, but returns the only UserIdentity ID in the query.
|
||||||
|
// Returns a *NotSingularError when more than one UserIdentity ID is found.
|
||||||
|
// Returns a *NotFoundError when no entities are found.
|
||||||
|
func (_q *UserIdentityQuery) OnlyID(ctx context.Context) (id string, err error) { |
||||||
|
var ids []string |
||||||
|
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { |
||||||
|
return |
||||||
|
} |
||||||
|
switch len(ids) { |
||||||
|
case 1: |
||||||
|
id = ids[0] |
||||||
|
case 0: |
||||||
|
err = &NotFoundError{useridentity.Label} |
||||||
|
default: |
||||||
|
err = &NotSingularError{useridentity.Label} |
||||||
|
} |
||||||
|
return |
||||||
|
} |
||||||
|
|
||||||
|
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||||
|
func (_q *UserIdentityQuery) OnlyIDX(ctx context.Context) string { |
||||||
|
id, err := _q.OnlyID(ctx) |
||||||
|
if err != nil { |
||||||
|
panic(err) |
||||||
|
} |
||||||
|
return id |
||||||
|
} |
||||||
|
|
||||||
|
// All executes the query and returns a list of UserIdentities.
|
||||||
|
func (_q *UserIdentityQuery) All(ctx context.Context) ([]*UserIdentity, error) { |
||||||
|
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) |
||||||
|
if err := _q.prepareQuery(ctx); err != nil { |
||||||
|
return nil, err |
||||||
|
} |
||||||
|
qr := querierAll[[]*UserIdentity, *UserIdentityQuery]() |
||||||
|
return withInterceptors[[]*UserIdentity](ctx, _q, qr, _q.inters) |
||||||
|
} |
||||||
|
|
||||||
|
// AllX is like All, but panics if an error occurs.
|
||||||
|
func (_q *UserIdentityQuery) AllX(ctx context.Context) []*UserIdentity { |
||||||
|
nodes, err := _q.All(ctx) |
||||||
|
if err != nil { |
||||||
|
panic(err) |
||||||
|
} |
||||||
|
return nodes |
||||||
|
} |
||||||
|
|
||||||
|
// IDs executes the query and returns a list of UserIdentity IDs.
|
||||||
|
func (_q *UserIdentityQuery) IDs(ctx context.Context) (ids []string, err error) { |
||||||
|
if _q.ctx.Unique == nil && _q.path != nil { |
||||||
|
_q.Unique(true) |
||||||
|
} |
||||||
|
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) |
||||||
|
if err = _q.Select(useridentity.FieldID).Scan(ctx, &ids); err != nil { |
||||||
|
return nil, err |
||||||
|
} |
||||||
|
return ids, nil |
||||||
|
} |
||||||
|
|
||||||
|
// IDsX is like IDs, but panics if an error occurs.
|
||||||
|
func (_q *UserIdentityQuery) IDsX(ctx context.Context) []string { |
||||||
|
ids, err := _q.IDs(ctx) |
||||||
|
if err != nil { |
||||||
|
panic(err) |
||||||
|
} |
||||||
|
return ids |
||||||
|
} |
||||||
|
|
||||||
|
// Count returns the count of the given query.
|
||||||
|
func (_q *UserIdentityQuery) Count(ctx context.Context) (int, error) { |
||||||
|
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) |
||||||
|
if err := _q.prepareQuery(ctx); err != nil { |
||||||
|
return 0, err |
||||||
|
} |
||||||
|
return withInterceptors[int](ctx, _q, querierCount[*UserIdentityQuery](), _q.inters) |
||||||
|
} |
||||||
|
|
||||||
|
// CountX is like Count, but panics if an error occurs.
|
||||||
|
func (_q *UserIdentityQuery) CountX(ctx context.Context) int { |
||||||
|
count, err := _q.Count(ctx) |
||||||
|
if err != nil { |
||||||
|
panic(err) |
||||||
|
} |
||||||
|
return count |
||||||
|
} |
||||||
|
|
||||||
|
// Exist returns true if the query has elements in the graph.
|
||||||
|
func (_q *UserIdentityQuery) Exist(ctx context.Context) (bool, error) { |
||||||
|
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) |
||||||
|
switch _, err := _q.FirstID(ctx); { |
||||||
|
case IsNotFound(err): |
||||||
|
return false, nil |
||||||
|
case err != nil: |
||||||
|
return false, fmt.Errorf("db: check existence: %w", err) |
||||||
|
default: |
||||||
|
return true, nil |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// ExistX is like Exist, but panics if an error occurs.
|
||||||
|
func (_q *UserIdentityQuery) ExistX(ctx context.Context) bool { |
||||||
|
exist, err := _q.Exist(ctx) |
||||||
|
if err != nil { |
||||||
|
panic(err) |
||||||
|
} |
||||||
|
return exist |
||||||
|
} |
||||||
|
|
||||||
|
// Clone returns a duplicate of the UserIdentityQuery builder, including all associated steps. It can be
|
||||||
|
// used to prepare common query builders and use them differently after the clone is made.
|
||||||
|
func (_q *UserIdentityQuery) Clone() *UserIdentityQuery { |
||||||
|
if _q == nil { |
||||||
|
return nil |
||||||
|
} |
||||||
|
return &UserIdentityQuery{ |
||||||
|
config: _q.config, |
||||||
|
ctx: _q.ctx.Clone(), |
||||||
|
order: append([]useridentity.OrderOption{}, _q.order...), |
||||||
|
inters: append([]Interceptor{}, _q.inters...), |
||||||
|
predicates: append([]predicate.UserIdentity{}, _q.predicates...), |
||||||
|
// clone intermediate query.
|
||||||
|
sql: _q.sql.Clone(), |
||||||
|
path: _q.path, |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// GroupBy is used to group vertices by one or more fields/columns.
|
||||||
|
// It is often used with aggregate functions, like: count, max, mean, min, sum.
|
||||||
|
//
|
||||||
|
// Example:
|
||||||
|
//
|
||||||
|
// var v []struct {
|
||||||
|
// UserID string `json:"user_id,omitempty"`
|
||||||
|
// Count int `json:"count,omitempty"`
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// client.UserIdentity.Query().
|
||||||
|
// GroupBy(useridentity.FieldUserID).
|
||||||
|
// Aggregate(db.Count()).
|
||||||
|
// Scan(ctx, &v)
|
||||||
|
func (_q *UserIdentityQuery) GroupBy(field string, fields ...string) *UserIdentityGroupBy { |
||||||
|
_q.ctx.Fields = append([]string{field}, fields...) |
||||||
|
grbuild := &UserIdentityGroupBy{build: _q} |
||||||
|
grbuild.flds = &_q.ctx.Fields |
||||||
|
grbuild.label = useridentity.Label |
||||||
|
grbuild.scan = grbuild.Scan |
||||||
|
return grbuild |
||||||
|
} |
||||||
|
|
||||||
|
// Select allows the selection one or more fields/columns for the given query,
|
||||||
|
// instead of selecting all fields in the entity.
|
||||||
|
//
|
||||||
|
// Example:
|
||||||
|
//
|
||||||
|
// var v []struct {
|
||||||
|
// UserID string `json:"user_id,omitempty"`
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// client.UserIdentity.Query().
|
||||||
|
// Select(useridentity.FieldUserID).
|
||||||
|
// Scan(ctx, &v)
|
||||||
|
func (_q *UserIdentityQuery) Select(fields ...string) *UserIdentitySelect { |
||||||
|
_q.ctx.Fields = append(_q.ctx.Fields, fields...) |
||||||
|
sbuild := &UserIdentitySelect{UserIdentityQuery: _q} |
||||||
|
sbuild.label = useridentity.Label |
||||||
|
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan |
||||||
|
return sbuild |
||||||
|
} |
||||||
|
|
||||||
|
// Aggregate returns a UserIdentitySelect configured with the given aggregations.
|
||||||
|
func (_q *UserIdentityQuery) Aggregate(fns ...AggregateFunc) *UserIdentitySelect { |
||||||
|
return _q.Select().Aggregate(fns...) |
||||||
|
} |
||||||
|
|
||||||
|
func (_q *UserIdentityQuery) prepareQuery(ctx context.Context) error { |
||||||
|
for _, inter := range _q.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, _q); err != nil { |
||||||
|
return err |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
for _, f := range _q.ctx.Fields { |
||||||
|
if !useridentity.ValidColumn(f) { |
||||||
|
return &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)} |
||||||
|
} |
||||||
|
} |
||||||
|
if _q.path != nil { |
||||||
|
prev, err := _q.path(ctx) |
||||||
|
if err != nil { |
||||||
|
return err |
||||||
|
} |
||||||
|
_q.sql = prev |
||||||
|
} |
||||||
|
return nil |
||||||
|
} |
||||||
|
|
||||||
|
func (_q *UserIdentityQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*UserIdentity, error) { |
||||||
|
var ( |
||||||
|
nodes = []*UserIdentity{} |
||||||
|
_spec = _q.querySpec() |
||||||
|
) |
||||||
|
_spec.ScanValues = func(columns []string) ([]any, error) { |
||||||
|
return (*UserIdentity).scanValues(nil, columns) |
||||||
|
} |
||||||
|
_spec.Assign = func(columns []string, values []any) error { |
||||||
|
node := &UserIdentity{config: _q.config} |
||||||
|
nodes = append(nodes, node) |
||||||
|
return node.assignValues(columns, values) |
||||||
|
} |
||||||
|
for i := range hooks { |
||||||
|
hooks[i](ctx, _spec) |
||||||
|
} |
||||||
|
if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { |
||||||
|
return nil, err |
||||||
|
} |
||||||
|
if len(nodes) == 0 { |
||||||
|
return nodes, nil |
||||||
|
} |
||||||
|
return nodes, nil |
||||||
|
} |
||||||
|
|
||||||
|
func (_q *UserIdentityQuery) sqlCount(ctx context.Context) (int, error) { |
||||||
|
_spec := _q.querySpec() |
||||||
|
_spec.Node.Columns = _q.ctx.Fields |
||||||
|
if len(_q.ctx.Fields) > 0 { |
||||||
|
_spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique |
||||||
|
} |
||||||
|
return sqlgraph.CountNodes(ctx, _q.driver, _spec) |
||||||
|
} |
||||||
|
|
||||||
|
func (_q *UserIdentityQuery) querySpec() *sqlgraph.QuerySpec { |
||||||
|
_spec := sqlgraph.NewQuerySpec(useridentity.Table, useridentity.Columns, sqlgraph.NewFieldSpec(useridentity.FieldID, field.TypeString)) |
||||||
|
_spec.From = _q.sql |
||||||
|
if unique := _q.ctx.Unique; unique != nil { |
||||||
|
_spec.Unique = *unique |
||||||
|
} else if _q.path != nil { |
||||||
|
_spec.Unique = true |
||||||
|
} |
||||||
|
if fields := _q.ctx.Fields; len(fields) > 0 { |
||||||
|
_spec.Node.Columns = make([]string, 0, len(fields)) |
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, useridentity.FieldID) |
||||||
|
for i := range fields { |
||||||
|
if fields[i] != useridentity.FieldID { |
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, fields[i]) |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
if ps := _q.predicates; len(ps) > 0 { |
||||||
|
_spec.Predicate = func(selector *sql.Selector) { |
||||||
|
for i := range ps { |
||||||
|
ps[i](selector) |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
if limit := _q.ctx.Limit; limit != nil { |
||||||
|
_spec.Limit = *limit |
||||||
|
} |
||||||
|
if offset := _q.ctx.Offset; offset != nil { |
||||||
|
_spec.Offset = *offset |
||||||
|
} |
||||||
|
if ps := _q.order; len(ps) > 0 { |
||||||
|
_spec.Order = func(selector *sql.Selector) { |
||||||
|
for i := range ps { |
||||||
|
ps[i](selector) |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
return _spec |
||||||
|
} |
||||||
|
|
||||||
|
func (_q *UserIdentityQuery) sqlQuery(ctx context.Context) *sql.Selector { |
||||||
|
builder := sql.Dialect(_q.driver.Dialect()) |
||||||
|
t1 := builder.Table(useridentity.Table) |
||||||
|
columns := _q.ctx.Fields |
||||||
|
if len(columns) == 0 { |
||||||
|
columns = useridentity.Columns |
||||||
|
} |
||||||
|
selector := builder.Select(t1.Columns(columns...)...).From(t1) |
||||||
|
if _q.sql != nil { |
||||||
|
selector = _q.sql |
||||||
|
selector.Select(selector.Columns(columns...)...) |
||||||
|
} |
||||||
|
if _q.ctx.Unique != nil && *_q.ctx.Unique { |
||||||
|
selector.Distinct() |
||||||
|
} |
||||||
|
for _, p := range _q.predicates { |
||||||
|
p(selector) |
||||||
|
} |
||||||
|
for _, p := range _q.order { |
||||||
|
p(selector) |
||||||
|
} |
||||||
|
if offset := _q.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 := _q.ctx.Limit; limit != nil { |
||||||
|
selector.Limit(*limit) |
||||||
|
} |
||||||
|
return selector |
||||||
|
} |
||||||
|
|
||||||
|
// UserIdentityGroupBy is the group-by builder for UserIdentity entities.
|
||||||
|
type UserIdentityGroupBy struct { |
||||||
|
selector |
||||||
|
build *UserIdentityQuery |
||||||
|
} |
||||||
|
|
||||||
|
// Aggregate adds the given aggregation functions to the group-by query.
|
||||||
|
func (_g *UserIdentityGroupBy) Aggregate(fns ...AggregateFunc) *UserIdentityGroupBy { |
||||||
|
_g.fns = append(_g.fns, fns...) |
||||||
|
return _g |
||||||
|
} |
||||||
|
|
||||||
|
// Scan applies the selector query and scans the result into the given value.
|
||||||
|
func (_g *UserIdentityGroupBy) Scan(ctx context.Context, v any) error { |
||||||
|
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) |
||||||
|
if err := _g.build.prepareQuery(ctx); err != nil { |
||||||
|
return err |
||||||
|
} |
||||||
|
return scanWithInterceptors[*UserIdentityQuery, *UserIdentityGroupBy](ctx, _g.build, _g, _g.build.inters, v) |
||||||
|
} |
||||||
|
|
||||||
|
func (_g *UserIdentityGroupBy) sqlScan(ctx context.Context, root *UserIdentityQuery, v any) error { |
||||||
|
selector := root.sqlQuery(ctx).Select() |
||||||
|
aggregation := make([]string, 0, len(_g.fns)) |
||||||
|
for _, fn := range _g.fns { |
||||||
|
aggregation = append(aggregation, fn(selector)) |
||||||
|
} |
||||||
|
if len(selector.SelectedColumns()) == 0 { |
||||||
|
columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) |
||||||
|
for _, f := range *_g.flds { |
||||||
|
columns = append(columns, selector.C(f)) |
||||||
|
} |
||||||
|
columns = append(columns, aggregation...) |
||||||
|
selector.Select(columns...) |
||||||
|
} |
||||||
|
selector.GroupBy(selector.Columns(*_g.flds...)...) |
||||||
|
if err := selector.Err(); err != nil { |
||||||
|
return err |
||||||
|
} |
||||||
|
rows := &sql.Rows{} |
||||||
|
query, args := selector.Query() |
||||||
|
if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { |
||||||
|
return err |
||||||
|
} |
||||||
|
defer rows.Close() |
||||||
|
return sql.ScanSlice(rows, v) |
||||||
|
} |
||||||
|
|
||||||
|
// UserIdentitySelect is the builder for selecting fields of UserIdentity entities.
|
||||||
|
type UserIdentitySelect struct { |
||||||
|
*UserIdentityQuery |
||||||
|
selector |
||||||
|
} |
||||||
|
|
||||||
|
// Aggregate adds the given aggregation functions to the selector query.
|
||||||
|
func (_s *UserIdentitySelect) Aggregate(fns ...AggregateFunc) *UserIdentitySelect { |
||||||
|
_s.fns = append(_s.fns, fns...) |
||||||
|
return _s |
||||||
|
} |
||||||
|
|
||||||
|
// Scan applies the selector query and scans the result into the given value.
|
||||||
|
func (_s *UserIdentitySelect) Scan(ctx context.Context, v any) error { |
||||||
|
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) |
||||||
|
if err := _s.prepareQuery(ctx); err != nil { |
||||||
|
return err |
||||||
|
} |
||||||
|
return scanWithInterceptors[*UserIdentityQuery, *UserIdentitySelect](ctx, _s.UserIdentityQuery, _s, _s.inters, v) |
||||||
|
} |
||||||
|
|
||||||
|
func (_s *UserIdentitySelect) sqlScan(ctx context.Context, root *UserIdentityQuery, v any) error { |
||||||
|
selector := root.sqlQuery(ctx) |
||||||
|
aggregation := make([]string, 0, len(_s.fns)) |
||||||
|
for _, fn := range _s.fns { |
||||||
|
aggregation = append(aggregation, fn(selector)) |
||||||
|
} |
||||||
|
switch n := len(*_s.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 := selector.Query() |
||||||
|
if err := _s.driver.Query(ctx, query, args, rows); err != nil { |
||||||
|
return err |
||||||
|
} |
||||||
|
defer rows.Close() |
||||||
|
return sql.ScanSlice(rows, v) |
||||||
|
} |
||||||
@ -0,0 +1,629 @@ |
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package db |
||||||
|
|
||||||
|
import ( |
||||||
|
"context" |
||||||
|
"errors" |
||||||
|
"fmt" |
||||||
|
"time" |
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql" |
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph" |
||||||
|
"entgo.io/ent/dialect/sql/sqljson" |
||||||
|
"entgo.io/ent/schema/field" |
||||||
|
"github.com/dexidp/dex/storage/ent/db/predicate" |
||||||
|
"github.com/dexidp/dex/storage/ent/db/useridentity" |
||||||
|
) |
||||||
|
|
||||||
|
// UserIdentityUpdate is the builder for updating UserIdentity entities.
|
||||||
|
type UserIdentityUpdate struct { |
||||||
|
config |
||||||
|
hooks []Hook |
||||||
|
mutation *UserIdentityMutation |
||||||
|
} |
||||||
|
|
||||||
|
// Where appends a list predicates to the UserIdentityUpdate builder.
|
||||||
|
func (_u *UserIdentityUpdate) Where(ps ...predicate.UserIdentity) *UserIdentityUpdate { |
||||||
|
_u.mutation.Where(ps...) |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// SetUserID sets the "user_id" field.
|
||||||
|
func (_u *UserIdentityUpdate) SetUserID(v string) *UserIdentityUpdate { |
||||||
|
_u.mutation.SetUserID(v) |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// SetNillableUserID sets the "user_id" field if the given value is not nil.
|
||||||
|
func (_u *UserIdentityUpdate) SetNillableUserID(v *string) *UserIdentityUpdate { |
||||||
|
if v != nil { |
||||||
|
_u.SetUserID(*v) |
||||||
|
} |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// SetConnectorID sets the "connector_id" field.
|
||||||
|
func (_u *UserIdentityUpdate) SetConnectorID(v string) *UserIdentityUpdate { |
||||||
|
_u.mutation.SetConnectorID(v) |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// SetNillableConnectorID sets the "connector_id" field if the given value is not nil.
|
||||||
|
func (_u *UserIdentityUpdate) SetNillableConnectorID(v *string) *UserIdentityUpdate { |
||||||
|
if v != nil { |
||||||
|
_u.SetConnectorID(*v) |
||||||
|
} |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// SetClaimsUserID sets the "claims_user_id" field.
|
||||||
|
func (_u *UserIdentityUpdate) SetClaimsUserID(v string) *UserIdentityUpdate { |
||||||
|
_u.mutation.SetClaimsUserID(v) |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// SetNillableClaimsUserID sets the "claims_user_id" field if the given value is not nil.
|
||||||
|
func (_u *UserIdentityUpdate) SetNillableClaimsUserID(v *string) *UserIdentityUpdate { |
||||||
|
if v != nil { |
||||||
|
_u.SetClaimsUserID(*v) |
||||||
|
} |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// SetClaimsUsername sets the "claims_username" field.
|
||||||
|
func (_u *UserIdentityUpdate) SetClaimsUsername(v string) *UserIdentityUpdate { |
||||||
|
_u.mutation.SetClaimsUsername(v) |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// SetNillableClaimsUsername sets the "claims_username" field if the given value is not nil.
|
||||||
|
func (_u *UserIdentityUpdate) SetNillableClaimsUsername(v *string) *UserIdentityUpdate { |
||||||
|
if v != nil { |
||||||
|
_u.SetClaimsUsername(*v) |
||||||
|
} |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// SetClaimsPreferredUsername sets the "claims_preferred_username" field.
|
||||||
|
func (_u *UserIdentityUpdate) SetClaimsPreferredUsername(v string) *UserIdentityUpdate { |
||||||
|
_u.mutation.SetClaimsPreferredUsername(v) |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// SetNillableClaimsPreferredUsername sets the "claims_preferred_username" field if the given value is not nil.
|
||||||
|
func (_u *UserIdentityUpdate) SetNillableClaimsPreferredUsername(v *string) *UserIdentityUpdate { |
||||||
|
if v != nil { |
||||||
|
_u.SetClaimsPreferredUsername(*v) |
||||||
|
} |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// SetClaimsEmail sets the "claims_email" field.
|
||||||
|
func (_u *UserIdentityUpdate) SetClaimsEmail(v string) *UserIdentityUpdate { |
||||||
|
_u.mutation.SetClaimsEmail(v) |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// SetNillableClaimsEmail sets the "claims_email" field if the given value is not nil.
|
||||||
|
func (_u *UserIdentityUpdate) SetNillableClaimsEmail(v *string) *UserIdentityUpdate { |
||||||
|
if v != nil { |
||||||
|
_u.SetClaimsEmail(*v) |
||||||
|
} |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// SetClaimsEmailVerified sets the "claims_email_verified" field.
|
||||||
|
func (_u *UserIdentityUpdate) SetClaimsEmailVerified(v bool) *UserIdentityUpdate { |
||||||
|
_u.mutation.SetClaimsEmailVerified(v) |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// SetNillableClaimsEmailVerified sets the "claims_email_verified" field if the given value is not nil.
|
||||||
|
func (_u *UserIdentityUpdate) SetNillableClaimsEmailVerified(v *bool) *UserIdentityUpdate { |
||||||
|
if v != nil { |
||||||
|
_u.SetClaimsEmailVerified(*v) |
||||||
|
} |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// SetClaimsGroups sets the "claims_groups" field.
|
||||||
|
func (_u *UserIdentityUpdate) SetClaimsGroups(v []string) *UserIdentityUpdate { |
||||||
|
_u.mutation.SetClaimsGroups(v) |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// AppendClaimsGroups appends value to the "claims_groups" field.
|
||||||
|
func (_u *UserIdentityUpdate) AppendClaimsGroups(v []string) *UserIdentityUpdate { |
||||||
|
_u.mutation.AppendClaimsGroups(v) |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// ClearClaimsGroups clears the value of the "claims_groups" field.
|
||||||
|
func (_u *UserIdentityUpdate) ClearClaimsGroups() *UserIdentityUpdate { |
||||||
|
_u.mutation.ClearClaimsGroups() |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// SetConsents sets the "consents" field.
|
||||||
|
func (_u *UserIdentityUpdate) SetConsents(v []byte) *UserIdentityUpdate { |
||||||
|
_u.mutation.SetConsents(v) |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// SetCreatedAt sets the "created_at" field.
|
||||||
|
func (_u *UserIdentityUpdate) SetCreatedAt(v time.Time) *UserIdentityUpdate { |
||||||
|
_u.mutation.SetCreatedAt(v) |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||||
|
func (_u *UserIdentityUpdate) SetNillableCreatedAt(v *time.Time) *UserIdentityUpdate { |
||||||
|
if v != nil { |
||||||
|
_u.SetCreatedAt(*v) |
||||||
|
} |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// SetLastLogin sets the "last_login" field.
|
||||||
|
func (_u *UserIdentityUpdate) SetLastLogin(v time.Time) *UserIdentityUpdate { |
||||||
|
_u.mutation.SetLastLogin(v) |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// SetNillableLastLogin sets the "last_login" field if the given value is not nil.
|
||||||
|
func (_u *UserIdentityUpdate) SetNillableLastLogin(v *time.Time) *UserIdentityUpdate { |
||||||
|
if v != nil { |
||||||
|
_u.SetLastLogin(*v) |
||||||
|
} |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// SetBlockedUntil sets the "blocked_until" field.
|
||||||
|
func (_u *UserIdentityUpdate) SetBlockedUntil(v time.Time) *UserIdentityUpdate { |
||||||
|
_u.mutation.SetBlockedUntil(v) |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// SetNillableBlockedUntil sets the "blocked_until" field if the given value is not nil.
|
||||||
|
func (_u *UserIdentityUpdate) SetNillableBlockedUntil(v *time.Time) *UserIdentityUpdate { |
||||||
|
if v != nil { |
||||||
|
_u.SetBlockedUntil(*v) |
||||||
|
} |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// Mutation returns the UserIdentityMutation object of the builder.
|
||||||
|
func (_u *UserIdentityUpdate) Mutation() *UserIdentityMutation { |
||||||
|
return _u.mutation |
||||||
|
} |
||||||
|
|
||||||
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||||
|
func (_u *UserIdentityUpdate) Save(ctx context.Context) (int, error) { |
||||||
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) |
||||||
|
} |
||||||
|
|
||||||
|
// SaveX is like Save, but panics if an error occurs.
|
||||||
|
func (_u *UserIdentityUpdate) SaveX(ctx context.Context) int { |
||||||
|
affected, err := _u.Save(ctx) |
||||||
|
if err != nil { |
||||||
|
panic(err) |
||||||
|
} |
||||||
|
return affected |
||||||
|
} |
||||||
|
|
||||||
|
// Exec executes the query.
|
||||||
|
func (_u *UserIdentityUpdate) Exec(ctx context.Context) error { |
||||||
|
_, err := _u.Save(ctx) |
||||||
|
return err |
||||||
|
} |
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (_u *UserIdentityUpdate) ExecX(ctx context.Context) { |
||||||
|
if err := _u.Exec(ctx); err != nil { |
||||||
|
panic(err) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// check runs all checks and user-defined validators on the builder.
|
||||||
|
func (_u *UserIdentityUpdate) check() error { |
||||||
|
if v, ok := _u.mutation.UserID(); ok { |
||||||
|
if err := useridentity.UserIDValidator(v); err != nil { |
||||||
|
return &ValidationError{Name: "user_id", err: fmt.Errorf(`db: validator failed for field "UserIdentity.user_id": %w`, err)} |
||||||
|
} |
||||||
|
} |
||||||
|
if v, ok := _u.mutation.ConnectorID(); ok { |
||||||
|
if err := useridentity.ConnectorIDValidator(v); err != nil { |
||||||
|
return &ValidationError{Name: "connector_id", err: fmt.Errorf(`db: validator failed for field "UserIdentity.connector_id": %w`, err)} |
||||||
|
} |
||||||
|
} |
||||||
|
return nil |
||||||
|
} |
||||||
|
|
||||||
|
func (_u *UserIdentityUpdate) sqlSave(ctx context.Context) (_node int, err error) { |
||||||
|
if err := _u.check(); err != nil { |
||||||
|
return _node, err |
||||||
|
} |
||||||
|
_spec := sqlgraph.NewUpdateSpec(useridentity.Table, useridentity.Columns, sqlgraph.NewFieldSpec(useridentity.FieldID, field.TypeString)) |
||||||
|
if ps := _u.mutation.predicates; len(ps) > 0 { |
||||||
|
_spec.Predicate = func(selector *sql.Selector) { |
||||||
|
for i := range ps { |
||||||
|
ps[i](selector) |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
if value, ok := _u.mutation.UserID(); ok { |
||||||
|
_spec.SetField(useridentity.FieldUserID, field.TypeString, value) |
||||||
|
} |
||||||
|
if value, ok := _u.mutation.ConnectorID(); ok { |
||||||
|
_spec.SetField(useridentity.FieldConnectorID, field.TypeString, value) |
||||||
|
} |
||||||
|
if value, ok := _u.mutation.ClaimsUserID(); ok { |
||||||
|
_spec.SetField(useridentity.FieldClaimsUserID, field.TypeString, value) |
||||||
|
} |
||||||
|
if value, ok := _u.mutation.ClaimsUsername(); ok { |
||||||
|
_spec.SetField(useridentity.FieldClaimsUsername, field.TypeString, value) |
||||||
|
} |
||||||
|
if value, ok := _u.mutation.ClaimsPreferredUsername(); ok { |
||||||
|
_spec.SetField(useridentity.FieldClaimsPreferredUsername, field.TypeString, value) |
||||||
|
} |
||||||
|
if value, ok := _u.mutation.ClaimsEmail(); ok { |
||||||
|
_spec.SetField(useridentity.FieldClaimsEmail, field.TypeString, value) |
||||||
|
} |
||||||
|
if value, ok := _u.mutation.ClaimsEmailVerified(); ok { |
||||||
|
_spec.SetField(useridentity.FieldClaimsEmailVerified, field.TypeBool, value) |
||||||
|
} |
||||||
|
if value, ok := _u.mutation.ClaimsGroups(); ok { |
||||||
|
_spec.SetField(useridentity.FieldClaimsGroups, field.TypeJSON, value) |
||||||
|
} |
||||||
|
if value, ok := _u.mutation.AppendedClaimsGroups(); ok { |
||||||
|
_spec.AddModifier(func(u *sql.UpdateBuilder) { |
||||||
|
sqljson.Append(u, useridentity.FieldClaimsGroups, value) |
||||||
|
}) |
||||||
|
} |
||||||
|
if _u.mutation.ClaimsGroupsCleared() { |
||||||
|
_spec.ClearField(useridentity.FieldClaimsGroups, field.TypeJSON) |
||||||
|
} |
||||||
|
if value, ok := _u.mutation.Consents(); ok { |
||||||
|
_spec.SetField(useridentity.FieldConsents, field.TypeBytes, value) |
||||||
|
} |
||||||
|
if value, ok := _u.mutation.CreatedAt(); ok { |
||||||
|
_spec.SetField(useridentity.FieldCreatedAt, field.TypeTime, value) |
||||||
|
} |
||||||
|
if value, ok := _u.mutation.LastLogin(); ok { |
||||||
|
_spec.SetField(useridentity.FieldLastLogin, field.TypeTime, value) |
||||||
|
} |
||||||
|
if value, ok := _u.mutation.BlockedUntil(); ok { |
||||||
|
_spec.SetField(useridentity.FieldBlockedUntil, field.TypeTime, value) |
||||||
|
} |
||||||
|
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { |
||||||
|
if _, ok := err.(*sqlgraph.NotFoundError); ok { |
||||||
|
err = &NotFoundError{useridentity.Label} |
||||||
|
} else if sqlgraph.IsConstraintError(err) { |
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err} |
||||||
|
} |
||||||
|
return 0, err |
||||||
|
} |
||||||
|
_u.mutation.done = true |
||||||
|
return _node, nil |
||||||
|
} |
||||||
|
|
||||||
|
// UserIdentityUpdateOne is the builder for updating a single UserIdentity entity.
|
||||||
|
type UserIdentityUpdateOne struct { |
||||||
|
config |
||||||
|
fields []string |
||||||
|
hooks []Hook |
||||||
|
mutation *UserIdentityMutation |
||||||
|
} |
||||||
|
|
||||||
|
// SetUserID sets the "user_id" field.
|
||||||
|
func (_u *UserIdentityUpdateOne) SetUserID(v string) *UserIdentityUpdateOne { |
||||||
|
_u.mutation.SetUserID(v) |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// SetNillableUserID sets the "user_id" field if the given value is not nil.
|
||||||
|
func (_u *UserIdentityUpdateOne) SetNillableUserID(v *string) *UserIdentityUpdateOne { |
||||||
|
if v != nil { |
||||||
|
_u.SetUserID(*v) |
||||||
|
} |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// SetConnectorID sets the "connector_id" field.
|
||||||
|
func (_u *UserIdentityUpdateOne) SetConnectorID(v string) *UserIdentityUpdateOne { |
||||||
|
_u.mutation.SetConnectorID(v) |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// SetNillableConnectorID sets the "connector_id" field if the given value is not nil.
|
||||||
|
func (_u *UserIdentityUpdateOne) SetNillableConnectorID(v *string) *UserIdentityUpdateOne { |
||||||
|
if v != nil { |
||||||
|
_u.SetConnectorID(*v) |
||||||
|
} |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// SetClaimsUserID sets the "claims_user_id" field.
|
||||||
|
func (_u *UserIdentityUpdateOne) SetClaimsUserID(v string) *UserIdentityUpdateOne { |
||||||
|
_u.mutation.SetClaimsUserID(v) |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// SetNillableClaimsUserID sets the "claims_user_id" field if the given value is not nil.
|
||||||
|
func (_u *UserIdentityUpdateOne) SetNillableClaimsUserID(v *string) *UserIdentityUpdateOne { |
||||||
|
if v != nil { |
||||||
|
_u.SetClaimsUserID(*v) |
||||||
|
} |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// SetClaimsUsername sets the "claims_username" field.
|
||||||
|
func (_u *UserIdentityUpdateOne) SetClaimsUsername(v string) *UserIdentityUpdateOne { |
||||||
|
_u.mutation.SetClaimsUsername(v) |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// SetNillableClaimsUsername sets the "claims_username" field if the given value is not nil.
|
||||||
|
func (_u *UserIdentityUpdateOne) SetNillableClaimsUsername(v *string) *UserIdentityUpdateOne { |
||||||
|
if v != nil { |
||||||
|
_u.SetClaimsUsername(*v) |
||||||
|
} |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// SetClaimsPreferredUsername sets the "claims_preferred_username" field.
|
||||||
|
func (_u *UserIdentityUpdateOne) SetClaimsPreferredUsername(v string) *UserIdentityUpdateOne { |
||||||
|
_u.mutation.SetClaimsPreferredUsername(v) |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// SetNillableClaimsPreferredUsername sets the "claims_preferred_username" field if the given value is not nil.
|
||||||
|
func (_u *UserIdentityUpdateOne) SetNillableClaimsPreferredUsername(v *string) *UserIdentityUpdateOne { |
||||||
|
if v != nil { |
||||||
|
_u.SetClaimsPreferredUsername(*v) |
||||||
|
} |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// SetClaimsEmail sets the "claims_email" field.
|
||||||
|
func (_u *UserIdentityUpdateOne) SetClaimsEmail(v string) *UserIdentityUpdateOne { |
||||||
|
_u.mutation.SetClaimsEmail(v) |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// SetNillableClaimsEmail sets the "claims_email" field if the given value is not nil.
|
||||||
|
func (_u *UserIdentityUpdateOne) SetNillableClaimsEmail(v *string) *UserIdentityUpdateOne { |
||||||
|
if v != nil { |
||||||
|
_u.SetClaimsEmail(*v) |
||||||
|
} |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// SetClaimsEmailVerified sets the "claims_email_verified" field.
|
||||||
|
func (_u *UserIdentityUpdateOne) SetClaimsEmailVerified(v bool) *UserIdentityUpdateOne { |
||||||
|
_u.mutation.SetClaimsEmailVerified(v) |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// SetNillableClaimsEmailVerified sets the "claims_email_verified" field if the given value is not nil.
|
||||||
|
func (_u *UserIdentityUpdateOne) SetNillableClaimsEmailVerified(v *bool) *UserIdentityUpdateOne { |
||||||
|
if v != nil { |
||||||
|
_u.SetClaimsEmailVerified(*v) |
||||||
|
} |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// SetClaimsGroups sets the "claims_groups" field.
|
||||||
|
func (_u *UserIdentityUpdateOne) SetClaimsGroups(v []string) *UserIdentityUpdateOne { |
||||||
|
_u.mutation.SetClaimsGroups(v) |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// AppendClaimsGroups appends value to the "claims_groups" field.
|
||||||
|
func (_u *UserIdentityUpdateOne) AppendClaimsGroups(v []string) *UserIdentityUpdateOne { |
||||||
|
_u.mutation.AppendClaimsGroups(v) |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// ClearClaimsGroups clears the value of the "claims_groups" field.
|
||||||
|
func (_u *UserIdentityUpdateOne) ClearClaimsGroups() *UserIdentityUpdateOne { |
||||||
|
_u.mutation.ClearClaimsGroups() |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// SetConsents sets the "consents" field.
|
||||||
|
func (_u *UserIdentityUpdateOne) SetConsents(v []byte) *UserIdentityUpdateOne { |
||||||
|
_u.mutation.SetConsents(v) |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// SetCreatedAt sets the "created_at" field.
|
||||||
|
func (_u *UserIdentityUpdateOne) SetCreatedAt(v time.Time) *UserIdentityUpdateOne { |
||||||
|
_u.mutation.SetCreatedAt(v) |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||||
|
func (_u *UserIdentityUpdateOne) SetNillableCreatedAt(v *time.Time) *UserIdentityUpdateOne { |
||||||
|
if v != nil { |
||||||
|
_u.SetCreatedAt(*v) |
||||||
|
} |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// SetLastLogin sets the "last_login" field.
|
||||||
|
func (_u *UserIdentityUpdateOne) SetLastLogin(v time.Time) *UserIdentityUpdateOne { |
||||||
|
_u.mutation.SetLastLogin(v) |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// SetNillableLastLogin sets the "last_login" field if the given value is not nil.
|
||||||
|
func (_u *UserIdentityUpdateOne) SetNillableLastLogin(v *time.Time) *UserIdentityUpdateOne { |
||||||
|
if v != nil { |
||||||
|
_u.SetLastLogin(*v) |
||||||
|
} |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// SetBlockedUntil sets the "blocked_until" field.
|
||||||
|
func (_u *UserIdentityUpdateOne) SetBlockedUntil(v time.Time) *UserIdentityUpdateOne { |
||||||
|
_u.mutation.SetBlockedUntil(v) |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// SetNillableBlockedUntil sets the "blocked_until" field if the given value is not nil.
|
||||||
|
func (_u *UserIdentityUpdateOne) SetNillableBlockedUntil(v *time.Time) *UserIdentityUpdateOne { |
||||||
|
if v != nil { |
||||||
|
_u.SetBlockedUntil(*v) |
||||||
|
} |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// Mutation returns the UserIdentityMutation object of the builder.
|
||||||
|
func (_u *UserIdentityUpdateOne) Mutation() *UserIdentityMutation { |
||||||
|
return _u.mutation |
||||||
|
} |
||||||
|
|
||||||
|
// Where appends a list predicates to the UserIdentityUpdate builder.
|
||||||
|
func (_u *UserIdentityUpdateOne) Where(ps ...predicate.UserIdentity) *UserIdentityUpdateOne { |
||||||
|
_u.mutation.Where(ps...) |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// Select allows selecting one or more fields (columns) of the returned entity.
|
||||||
|
// The default is selecting all fields defined in the entity schema.
|
||||||
|
func (_u *UserIdentityUpdateOne) Select(field string, fields ...string) *UserIdentityUpdateOne { |
||||||
|
_u.fields = append([]string{field}, fields...) |
||||||
|
return _u |
||||||
|
} |
||||||
|
|
||||||
|
// Save executes the query and returns the updated UserIdentity entity.
|
||||||
|
func (_u *UserIdentityUpdateOne) Save(ctx context.Context) (*UserIdentity, error) { |
||||||
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) |
||||||
|
} |
||||||
|
|
||||||
|
// SaveX is like Save, but panics if an error occurs.
|
||||||
|
func (_u *UserIdentityUpdateOne) SaveX(ctx context.Context) *UserIdentity { |
||||||
|
node, err := _u.Save(ctx) |
||||||
|
if err != nil { |
||||||
|
panic(err) |
||||||
|
} |
||||||
|
return node |
||||||
|
} |
||||||
|
|
||||||
|
// Exec executes the query on the entity.
|
||||||
|
func (_u *UserIdentityUpdateOne) Exec(ctx context.Context) error { |
||||||
|
_, err := _u.Save(ctx) |
||||||
|
return err |
||||||
|
} |
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (_u *UserIdentityUpdateOne) ExecX(ctx context.Context) { |
||||||
|
if err := _u.Exec(ctx); err != nil { |
||||||
|
panic(err) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// check runs all checks and user-defined validators on the builder.
|
||||||
|
func (_u *UserIdentityUpdateOne) check() error { |
||||||
|
if v, ok := _u.mutation.UserID(); ok { |
||||||
|
if err := useridentity.UserIDValidator(v); err != nil { |
||||||
|
return &ValidationError{Name: "user_id", err: fmt.Errorf(`db: validator failed for field "UserIdentity.user_id": %w`, err)} |
||||||
|
} |
||||||
|
} |
||||||
|
if v, ok := _u.mutation.ConnectorID(); ok { |
||||||
|
if err := useridentity.ConnectorIDValidator(v); err != nil { |
||||||
|
return &ValidationError{Name: "connector_id", err: fmt.Errorf(`db: validator failed for field "UserIdentity.connector_id": %w`, err)} |
||||||
|
} |
||||||
|
} |
||||||
|
return nil |
||||||
|
} |
||||||
|
|
||||||
|
func (_u *UserIdentityUpdateOne) sqlSave(ctx context.Context) (_node *UserIdentity, err error) { |
||||||
|
if err := _u.check(); err != nil { |
||||||
|
return _node, err |
||||||
|
} |
||||||
|
_spec := sqlgraph.NewUpdateSpec(useridentity.Table, useridentity.Columns, sqlgraph.NewFieldSpec(useridentity.FieldID, field.TypeString)) |
||||||
|
id, ok := _u.mutation.ID() |
||||||
|
if !ok { |
||||||
|
return nil, &ValidationError{Name: "id", err: errors.New(`db: missing "UserIdentity.id" for update`)} |
||||||
|
} |
||||||
|
_spec.Node.ID.Value = id |
||||||
|
if fields := _u.fields; len(fields) > 0 { |
||||||
|
_spec.Node.Columns = make([]string, 0, len(fields)) |
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, useridentity.FieldID) |
||||||
|
for _, f := range fields { |
||||||
|
if !useridentity.ValidColumn(f) { |
||||||
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)} |
||||||
|
} |
||||||
|
if f != useridentity.FieldID { |
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, f) |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
if ps := _u.mutation.predicates; len(ps) > 0 { |
||||||
|
_spec.Predicate = func(selector *sql.Selector) { |
||||||
|
for i := range ps { |
||||||
|
ps[i](selector) |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
if value, ok := _u.mutation.UserID(); ok { |
||||||
|
_spec.SetField(useridentity.FieldUserID, field.TypeString, value) |
||||||
|
} |
||||||
|
if value, ok := _u.mutation.ConnectorID(); ok { |
||||||
|
_spec.SetField(useridentity.FieldConnectorID, field.TypeString, value) |
||||||
|
} |
||||||
|
if value, ok := _u.mutation.ClaimsUserID(); ok { |
||||||
|
_spec.SetField(useridentity.FieldClaimsUserID, field.TypeString, value) |
||||||
|
} |
||||||
|
if value, ok := _u.mutation.ClaimsUsername(); ok { |
||||||
|
_spec.SetField(useridentity.FieldClaimsUsername, field.TypeString, value) |
||||||
|
} |
||||||
|
if value, ok := _u.mutation.ClaimsPreferredUsername(); ok { |
||||||
|
_spec.SetField(useridentity.FieldClaimsPreferredUsername, field.TypeString, value) |
||||||
|
} |
||||||
|
if value, ok := _u.mutation.ClaimsEmail(); ok { |
||||||
|
_spec.SetField(useridentity.FieldClaimsEmail, field.TypeString, value) |
||||||
|
} |
||||||
|
if value, ok := _u.mutation.ClaimsEmailVerified(); ok { |
||||||
|
_spec.SetField(useridentity.FieldClaimsEmailVerified, field.TypeBool, value) |
||||||
|
} |
||||||
|
if value, ok := _u.mutation.ClaimsGroups(); ok { |
||||||
|
_spec.SetField(useridentity.FieldClaimsGroups, field.TypeJSON, value) |
||||||
|
} |
||||||
|
if value, ok := _u.mutation.AppendedClaimsGroups(); ok { |
||||||
|
_spec.AddModifier(func(u *sql.UpdateBuilder) { |
||||||
|
sqljson.Append(u, useridentity.FieldClaimsGroups, value) |
||||||
|
}) |
||||||
|
} |
||||||
|
if _u.mutation.ClaimsGroupsCleared() { |
||||||
|
_spec.ClearField(useridentity.FieldClaimsGroups, field.TypeJSON) |
||||||
|
} |
||||||
|
if value, ok := _u.mutation.Consents(); ok { |
||||||
|
_spec.SetField(useridentity.FieldConsents, field.TypeBytes, value) |
||||||
|
} |
||||||
|
if value, ok := _u.mutation.CreatedAt(); ok { |
||||||
|
_spec.SetField(useridentity.FieldCreatedAt, field.TypeTime, value) |
||||||
|
} |
||||||
|
if value, ok := _u.mutation.LastLogin(); ok { |
||||||
|
_spec.SetField(useridentity.FieldLastLogin, field.TypeTime, value) |
||||||
|
} |
||||||
|
if value, ok := _u.mutation.BlockedUntil(); ok { |
||||||
|
_spec.SetField(useridentity.FieldBlockedUntil, field.TypeTime, value) |
||||||
|
} |
||||||
|
_node = &UserIdentity{config: _u.config} |
||||||
|
_spec.Assign = _node.assignValues |
||||||
|
_spec.ScanValues = _node.scanValues |
||||||
|
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { |
||||||
|
if _, ok := err.(*sqlgraph.NotFoundError); ok { |
||||||
|
err = &NotFoundError{useridentity.Label} |
||||||
|
} else if sqlgraph.IsConstraintError(err) { |
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err} |
||||||
|
} |
||||||
|
return nil, err |
||||||
|
} |
||||||
|
_u.mutation.done = true |
||||||
|
return _node, nil |
||||||
|
} |
||||||
@ -0,0 +1,56 @@ |
|||||||
|
package schema |
||||||
|
|
||||||
|
import ( |
||||||
|
"entgo.io/ent" |
||||||
|
"entgo.io/ent/schema/field" |
||||||
|
) |
||||||
|
|
||||||
|
// UserIdentity holds the schema definition for the UserIdentity entity.
|
||||||
|
type UserIdentity struct { |
||||||
|
ent.Schema |
||||||
|
} |
||||||
|
|
||||||
|
// Fields of the UserIdentity.
|
||||||
|
func (UserIdentity) Fields() []ent.Field { |
||||||
|
return []ent.Field{ |
||||||
|
// Using id field here because it's impossible to create multi-key primary yet
|
||||||
|
field.Text("id"). |
||||||
|
SchemaType(textSchema). |
||||||
|
NotEmpty(). |
||||||
|
Unique(), |
||||||
|
field.Text("user_id"). |
||||||
|
SchemaType(textSchema). |
||||||
|
NotEmpty(), |
||||||
|
field.Text("connector_id"). |
||||||
|
SchemaType(textSchema). |
||||||
|
NotEmpty(), |
||||||
|
field.Text("claims_user_id"). |
||||||
|
SchemaType(textSchema). |
||||||
|
Default(""), |
||||||
|
field.Text("claims_username"). |
||||||
|
SchemaType(textSchema). |
||||||
|
Default(""), |
||||||
|
field.Text("claims_preferred_username"). |
||||||
|
SchemaType(textSchema). |
||||||
|
Default(""), |
||||||
|
field.Text("claims_email"). |
||||||
|
SchemaType(textSchema). |
||||||
|
Default(""), |
||||||
|
field.Bool("claims_email_verified"). |
||||||
|
Default(false), |
||||||
|
field.JSON("claims_groups", []string{}). |
||||||
|
Optional(), |
||||||
|
field.Bytes("consents"), |
||||||
|
field.Time("created_at"). |
||||||
|
SchemaType(timeSchema), |
||||||
|
field.Time("last_login"). |
||||||
|
SchemaType(timeSchema), |
||||||
|
field.Time("blocked_until"). |
||||||
|
SchemaType(timeSchema), |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// Edges of the UserIdentity.
|
||||||
|
func (UserIdentity) Edges() []ent.Edge { |
||||||
|
return []ent.Edge{} |
||||||
|
} |
||||||
Loading…
Reference in new issue