-
Notifications
You must be signed in to change notification settings - Fork 869
/
Copy pathquery.sql.go
183 lines (165 loc) · 3.85 KB
/
query.sql.go
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.28.0
// source: query.sql
package querytest
import (
"context"
"database/sql"
)
const coalesceNumeric = `-- name: CoalesceNumeric :many
SELECT coalesce(baz, 0) as login
FROM foo
`
func (q *Queries) CoalesceNumeric(ctx context.Context) ([]int64, error) {
rows, err := q.db.QueryContext(ctx, coalesceNumeric)
if err != nil {
return nil, err
}
defer rows.Close()
var items []int64
for rows.Next() {
var login int64
if err := rows.Scan(&login); err != nil {
return nil, err
}
items = append(items, login)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const coalesceNumericColumns = `-- name: CoalesceNumericColumns :many
SELECT baz, qux, coalesce(baz, qux)
FROM foo
`
type CoalesceNumericColumnsRow struct {
Baz sql.NullInt64
Qux int64
Baz_2 int64
}
func (q *Queries) CoalesceNumericColumns(ctx context.Context) ([]CoalesceNumericColumnsRow, error) {
rows, err := q.db.QueryContext(ctx, coalesceNumericColumns)
if err != nil {
return nil, err
}
defer rows.Close()
var items []CoalesceNumericColumnsRow
for rows.Next() {
var i CoalesceNumericColumnsRow
if err := rows.Scan(&i.Baz, &i.Qux, &i.Baz_2); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const coalesceNumericNull = `-- name: CoalesceNumericNull :many
SELECT baz, coalesce(baz)
FROM foo
`
type CoalesceNumericNullRow struct {
Baz sql.NullInt64
Baz_2 sql.NullInt64
}
func (q *Queries) CoalesceNumericNull(ctx context.Context) ([]CoalesceNumericNullRow, error) {
rows, err := q.db.QueryContext(ctx, coalesceNumericNull)
if err != nil {
return nil, err
}
defer rows.Close()
var items []CoalesceNumericNullRow
for rows.Next() {
var i CoalesceNumericNullRow
if err := rows.Scan(&i.Baz, &i.Baz_2); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const coalesceString = `-- name: CoalesceString :many
SELECT coalesce(bar, '') as login
FROM foo
`
func (q *Queries) CoalesceString(ctx context.Context) ([]string, error) {
rows, err := q.db.QueryContext(ctx, coalesceString)
if err != nil {
return nil, err
}
defer rows.Close()
var items []string
for rows.Next() {
var login string
if err := rows.Scan(&login); err != nil {
return nil, err
}
items = append(items, login)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const coalesceStringColumns = `-- name: CoalesceStringColumns :many
SELECT bar, bat, coalesce(bar, bat)
FROM foo
`
type CoalesceStringColumnsRow struct {
Bar sql.NullString
Bat string
Bar_2 string
}
func (q *Queries) CoalesceStringColumns(ctx context.Context) ([]CoalesceStringColumnsRow, error) {
rows, err := q.db.QueryContext(ctx, coalesceStringColumns)
if err != nil {
return nil, err
}
defer rows.Close()
var items []CoalesceStringColumnsRow
for rows.Next() {
var i CoalesceStringColumnsRow
if err := rows.Scan(&i.Bar, &i.Bat, &i.Bar_2); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const coalesceStringNull = `-- name: CoalesceStringNull :many
SELECT bar, coalesce(bar)
FROM foo
`
type CoalesceStringNullRow struct {
Bar sql.NullString
Bar_2 sql.NullString
}
func (q *Queries) CoalesceStringNull(ctx context.Context) ([]CoalesceStringNullRow, error) {
rows, err := q.db.QueryContext(ctx, coalesceStringNull)
if err != nil {
return nil, err
}
defer rows.Close()
var items []CoalesceStringNullRow
for rows.Next() {
var i CoalesceStringNullRow
if err := rows.Scan(&i.Bar, &i.Bar_2); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}