-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_test.go
More file actions
66 lines (59 loc) · 1.3 KB
/
Copy pathupdate_test.go
File metadata and controls
66 lines (59 loc) · 1.3 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
package gosql
import (
"reflect"
"testing"
)
func TestInt(t *testing.T) {
var i1 int = 0
var i2 int16 = 0
var i3 int8 = 0
var i4 int32 = 0
var i5 int64 = 0
var i6 float32 = 0
var i7 float64 = 0
t.Log(reflect.ValueOf(i1).Int() == 0)
t.Log(reflect.ValueOf(i2).Int() == 0)
t.Log(reflect.ValueOf(i3).Int() == 0)
t.Log(reflect.ValueOf(i4).Int() == 0)
t.Log(reflect.ValueOf(i5).Int() == 0)
t.Log(reflect.ValueOf(i6).Float() == 0)
t.Log(reflect.ValueOf(i7).Float() == 0)
}
func TestStruct(t *testing.T) {
p := Person{}
t.Log(reflect.DeepEqual(p, Person{}))
}
func TestUpdate(t *testing.T) {
conf := Sqlconfig{
UserName: "test",
Password: "123456",
Port: 3306,
DbName: "test",
Host: "192.168.50.250",
MultiStatements: true,
}
db, err := conf.NewMysqlDb()
if err != nil {
t.Fatal(err)
}
ps := &Person{
FirstName: "what is it",
LastName: "hyahm.com",
Email: "aaaaa@eaml.com",
// Me: MeStruct{
// X: 10,
// Y: 20,
// Z: 30,
// },
Uids: []int64{1},
Age: 1,
}
// $key $value 是固定占位符
// omitempty: 如果为空, 那么为数据库的默认值
// struct, 指针, 切片 默认值为 ""
// $set
res := db.UpdateInterface(ps, "update person set $set where id=?", 4)
if res.Err != nil {
t.Fatal(err)
}
}