-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinsert_test.go
More file actions
34 lines (29 loc) · 914 Bytes
/
insert_test.go
File metadata and controls
34 lines (29 loc) · 914 Bytes
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
package sqlbuilder
import "testing"
//
// Author: 陈永佳 chenyongjia@parkingwang.com, yoojiachen@gmail.com
//
func TestInsertInto(t *testing.T) {
sb := NewContext()
sql := sb.Insert("t_users").
Columns("username", "password").
SetValueOfColumn("password", 123).
ToSQL()
checkSQLMatches(sql, "INSERT INTO `t_users`(`username`, `password`) VALUES (?, 123);", t)
}
func TestInsertInto1(t *testing.T) {
sb := NewContext()
sql := sb.Insert("t_users").
Columns("username", "password").
Values("yoojia", "1234").
ToSQL()
checkSQLMatches(sql, "INSERT INTO `t_users`(`username`, `password`) VALUES ('yoojia', '1234');", t)
}
func TestInsertIntoValued(t *testing.T) {
sb := NewContext()
sql := sb.Insert("t_users").
Columns("username", "password").
Values("yoojia", "123456").
ToSQL()
checkSQLMatches(sql, "INSERT INTO `t_users`(`username`, `password`) VALUES ('yoojia', '123456');", t)
}