oceanbase
152 строки · 5.0 Кб
1// Code generated by entc, DO NOT EDIT.
2
3package ent
4
5import (
6"fmt"
7"strings"
8"time"
9
10"entgo.io/ent/dialect/sql"
11"github.com/oceanbase/configserver/ent/obcluster"
12)
13
14// ObCluster is the model entity for the ObCluster schema.
15type ObCluster struct {
16config `json:"-"`
17// ID of the ent.
18ID int `json:"id,omitempty"`
19// CreateTime holds the value of the "create_time" field.
20CreateTime time.Time `json:"create_time,omitempty"`
21// UpdateTime holds the value of the "update_time" field.
22UpdateTime time.Time `json:"update_time,omitempty"`
23// Name holds the value of the "name" field.
24Name string `json:"name,omitempty"`
25// ObClusterID holds the value of the "ob_cluster_id" field.
26ObClusterID int64 `json:"ob_cluster_id,omitempty"`
27// Type holds the value of the "type" field.
28Type string `json:"type,omitempty"`
29// RootserviceJSON holds the value of the "rootservice_json" field.
30RootserviceJSON string `json:"rootservice_json,omitempty"`
31}
32
33// scanValues returns the types for scanning values from sql.Rows.
34func (*ObCluster) scanValues(columns []string) ([]interface{}, error) {
35values := make([]interface{}, len(columns))
36for i := range columns {
37switch columns[i] {
38case obcluster.FieldID, obcluster.FieldObClusterID:
39values[i] = new(sql.NullInt64)
40case obcluster.FieldName, obcluster.FieldType, obcluster.FieldRootserviceJSON:
41values[i] = new(sql.NullString)
42case obcluster.FieldCreateTime, obcluster.FieldUpdateTime:
43values[i] = new(sql.NullTime)
44default:
45return nil, fmt.Errorf("unexpected column %q for type ObCluster", columns[i])
46}
47}
48return values, nil
49}
50
51// assignValues assigns the values that were returned from sql.Rows (after scanning)
52// to the ObCluster fields.
53func (oc *ObCluster) assignValues(columns []string, values []interface{}) error {
54if m, n := len(values), len(columns); m < n {
55return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
56}
57for i := range columns {
58switch columns[i] {
59case obcluster.FieldID:
60value, ok := values[i].(*sql.NullInt64)
61if !ok {
62return fmt.Errorf("unexpected type %T for field id", value)
63}
64oc.ID = int(value.Int64)
65case obcluster.FieldCreateTime:
66if value, ok := values[i].(*sql.NullTime); !ok {
67return fmt.Errorf("unexpected type %T for field create_time", values[i])
68} else if value.Valid {
69oc.CreateTime = value.Time
70}
71case obcluster.FieldUpdateTime:
72if value, ok := values[i].(*sql.NullTime); !ok {
73return fmt.Errorf("unexpected type %T for field update_time", values[i])
74} else if value.Valid {
75oc.UpdateTime = value.Time
76}
77case obcluster.FieldName:
78if value, ok := values[i].(*sql.NullString); !ok {
79return fmt.Errorf("unexpected type %T for field name", values[i])
80} else if value.Valid {
81oc.Name = value.String
82}
83case obcluster.FieldObClusterID:
84if value, ok := values[i].(*sql.NullInt64); !ok {
85return fmt.Errorf("unexpected type %T for field ob_cluster_id", values[i])
86} else if value.Valid {
87oc.ObClusterID = value.Int64
88}
89case obcluster.FieldType:
90if value, ok := values[i].(*sql.NullString); !ok {
91return fmt.Errorf("unexpected type %T for field type", values[i])
92} else if value.Valid {
93oc.Type = value.String
94}
95case obcluster.FieldRootserviceJSON:
96if value, ok := values[i].(*sql.NullString); !ok {
97return fmt.Errorf("unexpected type %T for field rootservice_json", values[i])
98} else if value.Valid {
99oc.RootserviceJSON = value.String
100}
101}
102}
103return nil
104}
105
106// Update returns a builder for updating this ObCluster.
107// Note that you need to call ObCluster.Unwrap() before calling this method if this ObCluster
108// was returned from a transaction, and the transaction was committed or rolled back.
109func (oc *ObCluster) Update() *ObClusterUpdateOne {
110return (&ObClusterClient{config: oc.config}).UpdateOne(oc)
111}
112
113// Unwrap unwraps the ObCluster entity that was returned from a transaction after it was closed,
114// so that all future queries will be executed through the driver which created the transaction.
115func (oc *ObCluster) Unwrap() *ObCluster {
116tx, ok := oc.config.driver.(*txDriver)
117if !ok {
118panic("ent: ObCluster is not a transactional entity")
119}
120oc.config.driver = tx.drv
121return oc
122}
123
124// String implements the fmt.Stringer.
125func (oc *ObCluster) String() string {
126var builder strings.Builder
127builder.WriteString("ObCluster(")
128builder.WriteString(fmt.Sprintf("id=%v", oc.ID))
129builder.WriteString(", create_time=")
130builder.WriteString(oc.CreateTime.Format(time.ANSIC))
131builder.WriteString(", update_time=")
132builder.WriteString(oc.UpdateTime.Format(time.ANSIC))
133builder.WriteString(", name=")
134builder.WriteString(oc.Name)
135builder.WriteString(", ob_cluster_id=")
136builder.WriteString(fmt.Sprintf("%v", oc.ObClusterID))
137builder.WriteString(", type=")
138builder.WriteString(oc.Type)
139builder.WriteString(", rootservice_json=")
140builder.WriteString(oc.RootserviceJSON)
141builder.WriteByte(')')
142return builder.String()
143}
144
145// ObClusters is a parsable slice of ObCluster.
146type ObClusters []*ObCluster
147
148func (oc ObClusters) config(cfg config) {
149for _i := range oc {
150oc[_i].config = cfg
151}
152}
153