2022-08-29 07:16:12 +00:00
|
|
|
// Code generated by ent, DO NOT EDIT.
|
2021-01-01 20:34:47 +00:00
|
|
|
|
|
|
|
package db
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
|
|
|
|
2021-03-24 06:37:51 +00:00
|
|
|
"entgo.io/ent/dialect/sql"
|
2021-01-01 20:34:47 +00:00
|
|
|
"github.com/dexidp/dex/storage/ent/db/offlinesession"
|
|
|
|
)
|
|
|
|
|
|
|
|
// OfflineSession is the model entity for the OfflineSession schema.
|
|
|
|
type OfflineSession 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"`
|
|
|
|
// ConnID holds the value of the "conn_id" field.
|
|
|
|
ConnID string `json:"conn_id,omitempty"`
|
|
|
|
// Refresh holds the value of the "refresh" field.
|
|
|
|
Refresh []byte `json:"refresh,omitempty"`
|
|
|
|
// ConnectorData holds the value of the "connector_data" field.
|
|
|
|
ConnectorData *[]byte `json:"connector_data,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
|
|
|
func (*OfflineSession) scanValues(columns []string) ([]interface{}, error) {
|
|
|
|
values := make([]interface{}, len(columns))
|
|
|
|
for i := range columns {
|
|
|
|
switch columns[i] {
|
|
|
|
case offlinesession.FieldRefresh, offlinesession.FieldConnectorData:
|
2021-04-30 14:31:49 +00:00
|
|
|
values[i] = new([]byte)
|
2021-01-01 20:34:47 +00:00
|
|
|
case offlinesession.FieldID, offlinesession.FieldUserID, offlinesession.FieldConnID:
|
2021-04-30 14:31:49 +00:00
|
|
|
values[i] = new(sql.NullString)
|
2021-01-01 20:34:47 +00:00
|
|
|
default:
|
|
|
|
return nil, fmt.Errorf("unexpected column %q for type OfflineSession", columns[i])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return values, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
|
|
|
// to the OfflineSession fields.
|
|
|
|
func (os *OfflineSession) assignValues(columns []string, values []interface{}) 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 offlinesession.FieldID:
|
|
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field id", values[i])
|
|
|
|
} else if value.Valid {
|
|
|
|
os.ID = value.String
|
|
|
|
}
|
|
|
|
case offlinesession.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 {
|
|
|
|
os.UserID = value.String
|
|
|
|
}
|
|
|
|
case offlinesession.FieldConnID:
|
|
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field conn_id", values[i])
|
|
|
|
} else if value.Valid {
|
|
|
|
os.ConnID = value.String
|
|
|
|
}
|
|
|
|
case offlinesession.FieldRefresh:
|
|
|
|
if value, ok := values[i].(*[]byte); !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field refresh", values[i])
|
|
|
|
} else if value != nil {
|
|
|
|
os.Refresh = *value
|
|
|
|
}
|
|
|
|
case offlinesession.FieldConnectorData:
|
|
|
|
if value, ok := values[i].(*[]byte); !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field connector_data", values[i])
|
|
|
|
} else if value != nil {
|
|
|
|
os.ConnectorData = value
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update returns a builder for updating this OfflineSession.
|
|
|
|
// Note that you need to call OfflineSession.Unwrap() before calling this method if this OfflineSession
|
|
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
|
|
func (os *OfflineSession) Update() *OfflineSessionUpdateOne {
|
|
|
|
return (&OfflineSessionClient{config: os.config}).UpdateOne(os)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Unwrap unwraps the OfflineSession 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 (os *OfflineSession) Unwrap() *OfflineSession {
|
2022-08-29 07:16:12 +00:00
|
|
|
_tx, ok := os.config.driver.(*txDriver)
|
2021-01-01 20:34:47 +00:00
|
|
|
if !ok {
|
|
|
|
panic("db: OfflineSession is not a transactional entity")
|
|
|
|
}
|
2022-08-29 07:16:12 +00:00
|
|
|
os.config.driver = _tx.drv
|
2021-01-01 20:34:47 +00:00
|
|
|
return os
|
|
|
|
}
|
|
|
|
|
|
|
|
// String implements the fmt.Stringer.
|
|
|
|
func (os *OfflineSession) String() string {
|
|
|
|
var builder strings.Builder
|
|
|
|
builder.WriteString("OfflineSession(")
|
2022-08-29 07:16:12 +00:00
|
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", os.ID))
|
|
|
|
builder.WriteString("user_id=")
|
2021-01-01 20:34:47 +00:00
|
|
|
builder.WriteString(os.UserID)
|
2022-08-29 07:16:12 +00:00
|
|
|
builder.WriteString(", ")
|
|
|
|
builder.WriteString("conn_id=")
|
2021-01-01 20:34:47 +00:00
|
|
|
builder.WriteString(os.ConnID)
|
2022-08-29 07:16:12 +00:00
|
|
|
builder.WriteString(", ")
|
|
|
|
builder.WriteString("refresh=")
|
2021-01-01 20:34:47 +00:00
|
|
|
builder.WriteString(fmt.Sprintf("%v", os.Refresh))
|
2022-08-29 07:16:12 +00:00
|
|
|
builder.WriteString(", ")
|
2021-01-01 20:34:47 +00:00
|
|
|
if v := os.ConnectorData; v != nil {
|
2022-08-29 07:16:12 +00:00
|
|
|
builder.WriteString("connector_data=")
|
2021-01-01 20:34:47 +00:00
|
|
|
builder.WriteString(fmt.Sprintf("%v", *v))
|
|
|
|
}
|
|
|
|
builder.WriteByte(')')
|
|
|
|
return builder.String()
|
|
|
|
}
|
|
|
|
|
|
|
|
// OfflineSessions is a parsable slice of OfflineSession.
|
|
|
|
type OfflineSessions []*OfflineSession
|
|
|
|
|
|
|
|
func (os OfflineSessions) config(cfg config) {
|
|
|
|
for _i := range os {
|
|
|
|
os[_i].config = cfg
|
|
|
|
}
|
|
|
|
}
|