oceanbase

Форк
0
152 строки · 5.0 Кб
1
// Code generated by entc, DO NOT EDIT.
2

3
package ent
4

5
import (
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.
15
type ObCluster struct {
16
	config `json:"-"`
17
	// ID of the ent.
18
	ID int `json:"id,omitempty"`
19
	// CreateTime holds the value of the "create_time" field.
20
	CreateTime time.Time `json:"create_time,omitempty"`
21
	// UpdateTime holds the value of the "update_time" field.
22
	UpdateTime time.Time `json:"update_time,omitempty"`
23
	// Name holds the value of the "name" field.
24
	Name string `json:"name,omitempty"`
25
	// ObClusterID holds the value of the "ob_cluster_id" field.
26
	ObClusterID int64 `json:"ob_cluster_id,omitempty"`
27
	// Type holds the value of the "type" field.
28
	Type string `json:"type,omitempty"`
29
	// RootserviceJSON holds the value of the "rootservice_json" field.
30
	RootserviceJSON string `json:"rootservice_json,omitempty"`
31
}
32

33
// scanValues returns the types for scanning values from sql.Rows.
34
func (*ObCluster) scanValues(columns []string) ([]interface{}, error) {
35
	values := make([]interface{}, len(columns))
36
	for i := range columns {
37
		switch columns[i] {
38
		case obcluster.FieldID, obcluster.FieldObClusterID:
39
			values[i] = new(sql.NullInt64)
40
		case obcluster.FieldName, obcluster.FieldType, obcluster.FieldRootserviceJSON:
41
			values[i] = new(sql.NullString)
42
		case obcluster.FieldCreateTime, obcluster.FieldUpdateTime:
43
			values[i] = new(sql.NullTime)
44
		default:
45
			return nil, fmt.Errorf("unexpected column %q for type ObCluster", columns[i])
46
		}
47
	}
48
	return values, nil
49
}
50

51
// assignValues assigns the values that were returned from sql.Rows (after scanning)
52
// to the ObCluster fields.
53
func (oc *ObCluster) assignValues(columns []string, values []interface{}) error {
54
	if m, n := len(values), len(columns); m < n {
55
		return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
56
	}
57
	for i := range columns {
58
		switch columns[i] {
59
		case obcluster.FieldID:
60
			value, ok := values[i].(*sql.NullInt64)
61
			if !ok {
62
				return fmt.Errorf("unexpected type %T for field id", value)
63
			}
64
			oc.ID = int(value.Int64)
65
		case obcluster.FieldCreateTime:
66
			if value, ok := values[i].(*sql.NullTime); !ok {
67
				return fmt.Errorf("unexpected type %T for field create_time", values[i])
68
			} else if value.Valid {
69
				oc.CreateTime = value.Time
70
			}
71
		case obcluster.FieldUpdateTime:
72
			if value, ok := values[i].(*sql.NullTime); !ok {
73
				return fmt.Errorf("unexpected type %T for field update_time", values[i])
74
			} else if value.Valid {
75
				oc.UpdateTime = value.Time
76
			}
77
		case obcluster.FieldName:
78
			if value, ok := values[i].(*sql.NullString); !ok {
79
				return fmt.Errorf("unexpected type %T for field name", values[i])
80
			} else if value.Valid {
81
				oc.Name = value.String
82
			}
83
		case obcluster.FieldObClusterID:
84
			if value, ok := values[i].(*sql.NullInt64); !ok {
85
				return fmt.Errorf("unexpected type %T for field ob_cluster_id", values[i])
86
			} else if value.Valid {
87
				oc.ObClusterID = value.Int64
88
			}
89
		case obcluster.FieldType:
90
			if value, ok := values[i].(*sql.NullString); !ok {
91
				return fmt.Errorf("unexpected type %T for field type", values[i])
92
			} else if value.Valid {
93
				oc.Type = value.String
94
			}
95
		case obcluster.FieldRootserviceJSON:
96
			if value, ok := values[i].(*sql.NullString); !ok {
97
				return fmt.Errorf("unexpected type %T for field rootservice_json", values[i])
98
			} else if value.Valid {
99
				oc.RootserviceJSON = value.String
100
			}
101
		}
102
	}
103
	return 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.
109
func (oc *ObCluster) Update() *ObClusterUpdateOne {
110
	return (&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.
115
func (oc *ObCluster) Unwrap() *ObCluster {
116
	tx, ok := oc.config.driver.(*txDriver)
117
	if !ok {
118
		panic("ent: ObCluster is not a transactional entity")
119
	}
120
	oc.config.driver = tx.drv
121
	return oc
122
}
123

124
// String implements the fmt.Stringer.
125
func (oc *ObCluster) String() string {
126
	var builder strings.Builder
127
	builder.WriteString("ObCluster(")
128
	builder.WriteString(fmt.Sprintf("id=%v", oc.ID))
129
	builder.WriteString(", create_time=")
130
	builder.WriteString(oc.CreateTime.Format(time.ANSIC))
131
	builder.WriteString(", update_time=")
132
	builder.WriteString(oc.UpdateTime.Format(time.ANSIC))
133
	builder.WriteString(", name=")
134
	builder.WriteString(oc.Name)
135
	builder.WriteString(", ob_cluster_id=")
136
	builder.WriteString(fmt.Sprintf("%v", oc.ObClusterID))
137
	builder.WriteString(", type=")
138
	builder.WriteString(oc.Type)
139
	builder.WriteString(", rootservice_json=")
140
	builder.WriteString(oc.RootserviceJSON)
141
	builder.WriteByte(')')
142
	return builder.String()
143
}
144

145
// ObClusters is a parsable slice of ObCluster.
146
type ObClusters []*ObCluster
147

148
func (oc ObClusters) config(cfg config) {
149
	for _i := range oc {
150
		oc[_i].config = cfg
151
	}
152
}
153

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.