-
Notifications
You must be signed in to change notification settings - Fork 90
/
conn_go19_test.go
68 lines (65 loc) · 1.43 KB
/
conn_go19_test.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
//go:build go1.9
// +build go1.9
package clickhouse
func (s *connSuite) TestExecBuild19() {
testCases := []struct {
query string
query2 string
args []interface{}
}{
{
"INSERT INTO data (u64) VALUES (?)",
"SELECT u64 FROM data WHERE u64=?",
[]interface{}{uint64(maxAllowedUInt64 - 1)},
},
{
"INSERT INTO data (u64) VALUES (?)",
"SELECT u64 FROM data WHERE u64=?",
[]interface{}{uint64(maxAllowedUInt64 * 2)},
},
}
for _, tc := range testCases {
result, err := s.conn.Exec(tc.query, tc.args...)
if !s.NoError(err) {
continue
}
s.NotNil(result)
_, err = result.LastInsertId()
s.Equal(ErrNoLastInsertID, err)
_, err = result.RowsAffected()
s.Equal(ErrNoRowsAffected, err)
if len(tc.query2) == 0 {
continue
}
rows, err := s.conn.Query(tc.query2, tc.args...)
if !s.NoError(err) {
continue
}
v, err := scanValues(rows, tc.args)
if s.NoError(err) {
s.Equal([][]interface{}{tc.args}, v)
}
s.NoError(rows.Close())
}
}
func (s *connSuite) TestQuotedStrings() {
testCases := []struct {
query, expected1, expected2 string
}{
{
`SELECT '"foo" foo', 'bar'`, `"foo" foo`, "bar",
},
{
`SELECT 'bar', '"foo" foo'`, "bar", `"foo" foo`,
},
}
for _, tc := range testCases {
var actual1, actual2 string
err := s.conn.QueryRow(tc.query).Scan(&actual1, &actual2)
if !s.NoError(err) {
continue
}
s.Equal(tc.expected1, actual1)
s.Equal(tc.expected2, actual2)
}
}