-
Notifications
You must be signed in to change notification settings - Fork 1k
Expand file tree
/
Copy pathcopyfrom.go
More file actions
76 lines (64 loc) · 1.77 KB
/
copyfrom.go
File metadata and controls
76 lines (64 loc) · 1.77 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
// Code generated by sqlc. DO NOT EDIT.
// source: copyfrom.go
package querytest
import (
"context"
"database/sql"
)
// iteratorForInsertSingleValue implements pgx.CopyFromSource.
type iteratorForInsertSingleValue struct {
rows []sql.NullString
skippedFirstNextCall bool
}
func (r *iteratorForInsertSingleValue) Next() bool {
if len(r.rows) == 0 {
return false
}
if !r.skippedFirstNextCall {
r.skippedFirstNextCall = true
return true
}
r.rows = r.rows[1:]
return len(r.rows) > 0
}
func (r iteratorForInsertSingleValue) Values() ([]interface{}, error) {
return []interface{}{
r.rows[0],
}, nil
}
func (r iteratorForInsertSingleValue) Err() error {
return nil
}
// InsertSingleValue inserts a single value using copy.
func (q *Queries) InsertSingleValue(ctx context.Context, a []sql.NullString) (int64, error) {
return q.db.CopyFrom(ctx, []string{"myschema", "foo"}, []string{"a"}, &iteratorForInsertSingleValue{rows: a})
}
// iteratorForInsertValues implements pgx.CopyFromSource.
type iteratorForInsertValues struct {
rows []InsertValuesParams
skippedFirstNextCall bool
}
func (r *iteratorForInsertValues) Next() bool {
if len(r.rows) == 0 {
return false
}
if !r.skippedFirstNextCall {
r.skippedFirstNextCall = true
return true
}
r.rows = r.rows[1:]
return len(r.rows) > 0
}
func (r iteratorForInsertValues) Values() ([]interface{}, error) {
return []interface{}{
r.rows[0].A,
r.rows[0].B,
}, nil
}
func (r iteratorForInsertValues) Err() error {
return nil
}
// InsertValues inserts multiple values using copy.
func (q *Queries) InsertValues(ctx context.Context, arg []InsertValuesParams) (int64, error) {
return q.db.CopyFrom(ctx, []string{"myschema", "foo"}, []string{"a", "b"}, &iteratorForInsertValues{rows: arg})
}