forked from sqlc-dev/sqlc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.go
More file actions
90 lines (79 loc) · 1.66 KB
/
models.go
File metadata and controls
90 lines (79 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.17.2
package db
import (
"database/sql/driver"
"fmt"
)
type EnumType string
const (
EnumTypeBeforefirst EnumType = "beforefirst"
EnumTypeFirst EnumType = "first"
EnumTypeSecond EnumType = "second"
EnumTypeThird EnumType = "third"
EnumTypeFourth EnumType = "fourth"
EnumTypeFifth EnumType = "fifth"
EnumTypeLast EnumType = "last"
EnumTypeAfterlast EnumType = "afterlast"
)
func (e *EnumType) Scan(src interface{}) error {
switch s := src.(type) {
case []byte:
*e = EnumType(s)
case string:
*e = EnumType(s)
default:
return fmt.Errorf("unsupported scan type for EnumType: %T", src)
}
return nil
}
type NullEnumType struct {
EnumType EnumType
Valid bool // Valid is true if EnumType is not NULL
}
// Scan implements the Scanner interface.
func (ns *NullEnumType) Scan(value interface{}) error {
if value == nil {
ns.EnumType, ns.Valid = "", false
return nil
}
ns.Valid = true
return ns.EnumType.Scan(value)
}
// Value implements the driver Valuer interface.
func (ns NullEnumType) Value() (driver.Value, error) {
if !ns.Valid {
return nil, nil
}
return string(ns.EnumType), nil
}
func (e EnumType) Valid() bool {
switch e {
case EnumTypeBeforefirst,
EnumTypeFirst,
EnumTypeSecond,
EnumTypeThird,
EnumTypeFourth,
EnumTypeFifth,
EnumTypeLast,
EnumTypeAfterlast:
return true
}
return false
}
func AllEnumTypeValues() []EnumType {
return []EnumType{
EnumTypeBeforefirst,
EnumTypeFirst,
EnumTypeSecond,
EnumTypeThird,
EnumTypeFourth,
EnumTypeFifth,
EnumTypeLast,
EnumTypeAfterlast,
}
}
type Foo struct {
ID int32
}