mirror of https://github.com/dexidp/dex.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
150 lines
5.1 KiB
150 lines
5.1 KiB
// Code generated by ent, DO NOT EDIT. |
|
|
|
package db |
|
|
|
import ( |
|
"fmt" |
|
"strings" |
|
"time" |
|
|
|
"entgo.io/ent" |
|
"entgo.io/ent/dialect/sql" |
|
"github.com/dexidp/dex/storage/ent/db/authsession" |
|
) |
|
|
|
// AuthSession is the model entity for the AuthSession schema. |
|
type AuthSession struct { |
|
config `json:"-"` |
|
// ID of the ent. |
|
ID string `json:"id,omitempty"` |
|
// ClientStates holds the value of the "client_states" field. |
|
ClientStates []byte `json:"client_states,omitempty"` |
|
// CreatedAt holds the value of the "created_at" field. |
|
CreatedAt time.Time `json:"created_at,omitempty"` |
|
// LastActivity holds the value of the "last_activity" field. |
|
LastActivity time.Time `json:"last_activity,omitempty"` |
|
// IPAddress holds the value of the "ip_address" field. |
|
IPAddress string `json:"ip_address,omitempty"` |
|
// UserAgent holds the value of the "user_agent" field. |
|
UserAgent string `json:"user_agent,omitempty"` |
|
selectValues sql.SelectValues |
|
} |
|
|
|
// scanValues returns the types for scanning values from sql.Rows. |
|
func (*AuthSession) scanValues(columns []string) ([]any, error) { |
|
values := make([]any, len(columns)) |
|
for i := range columns { |
|
switch columns[i] { |
|
case authsession.FieldClientStates: |
|
values[i] = new([]byte) |
|
case authsession.FieldID, authsession.FieldIPAddress, authsession.FieldUserAgent: |
|
values[i] = new(sql.NullString) |
|
case authsession.FieldCreatedAt, authsession.FieldLastActivity: |
|
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 AuthSession fields. |
|
func (_m *AuthSession) 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 authsession.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 authsession.FieldClientStates: |
|
if value, ok := values[i].(*[]byte); !ok { |
|
return fmt.Errorf("unexpected type %T for field client_states", values[i]) |
|
} else if value != nil { |
|
_m.ClientStates = *value |
|
} |
|
case authsession.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 authsession.FieldLastActivity: |
|
if value, ok := values[i].(*sql.NullTime); !ok { |
|
return fmt.Errorf("unexpected type %T for field last_activity", values[i]) |
|
} else if value.Valid { |
|
_m.LastActivity = value.Time |
|
} |
|
case authsession.FieldIPAddress: |
|
if value, ok := values[i].(*sql.NullString); !ok { |
|
return fmt.Errorf("unexpected type %T for field ip_address", values[i]) |
|
} else if value.Valid { |
|
_m.IPAddress = value.String |
|
} |
|
case authsession.FieldUserAgent: |
|
if value, ok := values[i].(*sql.NullString); !ok { |
|
return fmt.Errorf("unexpected type %T for field user_agent", values[i]) |
|
} else if value.Valid { |
|
_m.UserAgent = value.String |
|
} |
|
default: |
|
_m.selectValues.Set(columns[i], values[i]) |
|
} |
|
} |
|
return nil |
|
} |
|
|
|
// Value returns the ent.Value that was dynamically selected and assigned to the AuthSession. |
|
// This includes values selected through modifiers, order, etc. |
|
func (_m *AuthSession) Value(name string) (ent.Value, error) { |
|
return _m.selectValues.Get(name) |
|
} |
|
|
|
// Update returns a builder for updating this AuthSession. |
|
// Note that you need to call AuthSession.Unwrap() before calling this method if this AuthSession |
|
// was returned from a transaction, and the transaction was committed or rolled back. |
|
func (_m *AuthSession) Update() *AuthSessionUpdateOne { |
|
return NewAuthSessionClient(_m.config).UpdateOne(_m) |
|
} |
|
|
|
// Unwrap unwraps the AuthSession 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 *AuthSession) Unwrap() *AuthSession { |
|
_tx, ok := _m.config.driver.(*txDriver) |
|
if !ok { |
|
panic("db: AuthSession is not a transactional entity") |
|
} |
|
_m.config.driver = _tx.drv |
|
return _m |
|
} |
|
|
|
// String implements the fmt.Stringer. |
|
func (_m *AuthSession) String() string { |
|
var builder strings.Builder |
|
builder.WriteString("AuthSession(") |
|
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) |
|
builder.WriteString("client_states=") |
|
builder.WriteString(fmt.Sprintf("%v", _m.ClientStates)) |
|
builder.WriteString(", ") |
|
builder.WriteString("created_at=") |
|
builder.WriteString(_m.CreatedAt.Format(time.ANSIC)) |
|
builder.WriteString(", ") |
|
builder.WriteString("last_activity=") |
|
builder.WriteString(_m.LastActivity.Format(time.ANSIC)) |
|
builder.WriteString(", ") |
|
builder.WriteString("ip_address=") |
|
builder.WriteString(_m.IPAddress) |
|
builder.WriteString(", ") |
|
builder.WriteString("user_agent=") |
|
builder.WriteString(_m.UserAgent) |
|
builder.WriteByte(')') |
|
return builder.String() |
|
} |
|
|
|
// AuthSessions is a parsable slice of AuthSession. |
|
type AuthSessions []*AuthSession
|
|
|