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/connector"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Connector is the model entity for the Connector schema.
|
|
|
|
type Connector struct {
|
|
|
|
config `json:"-"`
|
|
|
|
// ID of the ent.
|
|
|
|
ID string `json:"id,omitempty"`
|
|
|
|
// Type holds the value of the "type" field.
|
|
|
|
Type string `json:"type,omitempty"`
|
|
|
|
// Name holds the value of the "name" field.
|
|
|
|
Name string `json:"name,omitempty"`
|
|
|
|
// ResourceVersion holds the value of the "resource_version" field.
|
|
|
|
ResourceVersion string `json:"resource_version,omitempty"`
|
|
|
|
// Config holds the value of the "config" field.
|
|
|
|
Config []byte `json:"config,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
|
|
|
func (*Connector) scanValues(columns []string) ([]interface{}, error) {
|
|
|
|
values := make([]interface{}, len(columns))
|
|
|
|
for i := range columns {
|
|
|
|
switch columns[i] {
|
|
|
|
case connector.FieldConfig:
|
2021-04-30 14:31:49 +00:00
|
|
|
values[i] = new([]byte)
|
2021-01-01 20:34:47 +00:00
|
|
|
case connector.FieldID, connector.FieldType, connector.FieldName, connector.FieldResourceVersion:
|
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 Connector", columns[i])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return values, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
|
|
|
// to the Connector fields.
|
|
|
|
func (c *Connector) assignValues(columns []string, values []interface{}) error {
|
|
|
|
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 connector.FieldID:
|
|
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field id", values[i])
|
|
|
|
} else if value.Valid {
|
|
|
|
c.ID = value.String
|
|
|
|
}
|
|
|
|
case connector.FieldType:
|
|
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field type", values[i])
|
|
|
|
} else if value.Valid {
|
|
|
|
c.Type = value.String
|
|
|
|
}
|
|
|
|
case connector.FieldName:
|
|
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field name", values[i])
|
|
|
|
} else if value.Valid {
|
|
|
|
c.Name = value.String
|
|
|
|
}
|
|
|
|
case connector.FieldResourceVersion:
|
|
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field resource_version", values[i])
|
|
|
|
} else if value.Valid {
|
|
|
|
c.ResourceVersion = value.String
|
|
|
|
}
|
|
|
|
case connector.FieldConfig:
|
|
|
|
if value, ok := values[i].(*[]byte); !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field config", values[i])
|
|
|
|
} else if value != nil {
|
|
|
|
c.Config = *value
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update returns a builder for updating this Connector.
|
|
|
|
// Note that you need to call Connector.Unwrap() before calling this method if this Connector
|
|
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
|
|
func (c *Connector) Update() *ConnectorUpdateOne {
|
|
|
|
return (&ConnectorClient{config: c.config}).UpdateOne(c)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Unwrap unwraps the Connector 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 (c *Connector) Unwrap() *Connector {
|
2022-08-29 07:16:12 +00:00
|
|
|
_tx, ok := c.config.driver.(*txDriver)
|
2021-01-01 20:34:47 +00:00
|
|
|
if !ok {
|
|
|
|
panic("db: Connector is not a transactional entity")
|
|
|
|
}
|
2022-08-29 07:16:12 +00:00
|
|
|
c.config.driver = _tx.drv
|
2021-01-01 20:34:47 +00:00
|
|
|
return c
|
|
|
|
}
|
|
|
|
|
|
|
|
// String implements the fmt.Stringer.
|
|
|
|
func (c *Connector) String() string {
|
|
|
|
var builder strings.Builder
|
|
|
|
builder.WriteString("Connector(")
|
2022-08-29 07:16:12 +00:00
|
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", c.ID))
|
|
|
|
builder.WriteString("type=")
|
2021-01-01 20:34:47 +00:00
|
|
|
builder.WriteString(c.Type)
|
2022-08-29 07:16:12 +00:00
|
|
|
builder.WriteString(", ")
|
|
|
|
builder.WriteString("name=")
|
2021-01-01 20:34:47 +00:00
|
|
|
builder.WriteString(c.Name)
|
2022-08-29 07:16:12 +00:00
|
|
|
builder.WriteString(", ")
|
|
|
|
builder.WriteString("resource_version=")
|
2021-01-01 20:34:47 +00:00
|
|
|
builder.WriteString(c.ResourceVersion)
|
2022-08-29 07:16:12 +00:00
|
|
|
builder.WriteString(", ")
|
|
|
|
builder.WriteString("config=")
|
2021-01-01 20:34:47 +00:00
|
|
|
builder.WriteString(fmt.Sprintf("%v", c.Config))
|
|
|
|
builder.WriteByte(')')
|
|
|
|
return builder.String()
|
|
|
|
}
|
|
|
|
|
|
|
|
// Connectors is a parsable slice of Connector.
|
|
|
|
type Connectors []*Connector
|
|
|
|
|
|
|
|
func (c Connectors) config(cfg config) {
|
|
|
|
for _i := range c {
|
|
|
|
c[_i].config = cfg
|
|
|
|
}
|
|
|
|
}
|