@@ -31,7 +31,7 @@ func (s ExampleStruct) Value() (driver.Value, error) {
31
31
}
32
32
33
33
func format (v []byte , escaper string ) string {
34
- return escaper + strings .ReplaceAll (string (v ), escaper , " \\ " + escaper ) + escaper
34
+ return escaper + strings .ReplaceAll (string (v ), escaper , escaper + escaper ) + escaper
35
35
}
36
36
37
37
func TestExplainSQL (t * testing.T ) {
@@ -40,7 +40,7 @@ func TestExplainSQL(t *testing.T) {
40
40
var (
41
41
tt = now .MustParse ("2020-02-23 11:10:10" )
42
42
myrole = role ("admin" )
43
- pwd = password ([] byte ( "pass" ) )
43
+ pwd = password ("pass" )
44
44
jsVal = []byte (`{"Name":"test","Val":"test"}` )
45
45
js = JSON (jsVal )
46
46
esVal = []byte (`{"Name":"test","Val":"test"}` )
@@ -57,13 +57,13 @@ func TestExplainSQL(t *testing.T) {
57
57
SQL : "create table users (name, age, height, actived, bytes, create_at, update_at, deleted_at, email, role, pass) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" ,
58
58
NumericRegexp : nil ,
59
59
Vars : []interface {}{"jinzhu" , 1 , 999.99 , true , []byte ("12345" ), tt , & tt , nil , "w@g.\" com" , myrole , pwd },
60
- Result : `create table users (name, age, height, actived, bytes, create_at, update_at, deleted_at, email, role, pass) values ("jinzhu", 1, 999.99, true, "12345", "2020-02-23 11:10:10", "2020-02-23 11:10:10", NULL, "w@g.\ "com", "admin", "pass")` ,
60
+ Result : `create table users (name, age, height, actived, bytes, create_at, update_at, deleted_at, email, role, pass) values ("jinzhu", 1, 999.99, true, "12345", "2020-02-23 11:10:10", "2020-02-23 11:10:10", NULL, "w@g." "com", "admin", "pass")` ,
61
61
},
62
62
{
63
63
SQL : "create table users (name, age, height, actived, bytes, create_at, update_at, deleted_at, email, role, pass) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" ,
64
64
NumericRegexp : nil ,
65
65
Vars : []interface {}{"jinzhu?" , 1 , 999.99 , true , []byte ("12345" ), tt , & tt , nil , "w@g.\" com" , myrole , pwd },
66
- Result : `create table users (name, age, height, actived, bytes, create_at, update_at, deleted_at, email, role, pass) values ("jinzhu?", 1, 999.99, true, "12345", "2020-02-23 11:10:10", "2020-02-23 11:10:10", NULL, "w@g.\ "com", "admin", "pass")` ,
66
+ Result : `create table users (name, age, height, actived, bytes, create_at, update_at, deleted_at, email, role, pass) values ("jinzhu?", 1, 999.99, true, "12345", "2020-02-23 11:10:10", "2020-02-23 11:10:10", NULL, "w@g." "com", "admin", "pass")` ,
67
67
},
68
68
{
69
69
SQL : "create table users (name, age, height, actived, bytes, create_at, update_at, deleted_at, email, role, pass) values (@p1, @p2, @p3, @p4, @p5, @p6, @p7, @p8, @p9, @p10, @p11)" ,
@@ -87,25 +87,25 @@ func TestExplainSQL(t *testing.T) {
87
87
SQL : "create table users (name, age, height, actived, bytes, create_at, update_at, deleted_at, email, role, pass, json_struct, example_struct) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" ,
88
88
NumericRegexp : nil ,
89
89
Vars : []interface {}{"jinzhu" , 1 , 999.99 , true , []byte ("12345" ), tt , & tt , nil , "w@g.\" com" , myrole , pwd , js , es },
90
- Result : fmt .Sprintf (`create table users (name, age, height, actived, bytes, create_at, update_at, deleted_at, email, role, pass, json_struct, example_struct) values ("jinzhu", 1, 999.99, true, "12345", "2020-02-23 11:10:10", "2020-02-23 11:10:10", NULL, "w@g.\ "com", "admin", "pass", %v, %v)` , format (jsVal , `"` ), format (esVal , `"` )),
90
+ Result : fmt .Sprintf (`create table users (name, age, height, actived, bytes, create_at, update_at, deleted_at, email, role, pass, json_struct, example_struct) values ("jinzhu", 1, 999.99, true, "12345", "2020-02-23 11:10:10", "2020-02-23 11:10:10", NULL, "w@g." "com", "admin", "pass", %v, %v)` , format (jsVal , `"` ), format (esVal , `"` )),
91
91
},
92
92
{
93
93
SQL : "create table users (name, age, height, actived, bytes, create_at, update_at, deleted_at, email, role, pass, json_struct, example_struct) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" ,
94
94
NumericRegexp : nil ,
95
95
Vars : []interface {}{"jinzhu" , 1 , 999.99 , true , []byte ("12345" ), tt , & tt , nil , "w@g.\" com" , myrole , pwd , & js , & es },
96
- Result : fmt .Sprintf (`create table users (name, age, height, actived, bytes, create_at, update_at, deleted_at, email, role, pass, json_struct, example_struct) values ("jinzhu", 1, 999.99, true, "12345", "2020-02-23 11:10:10", "2020-02-23 11:10:10", NULL, "w@g.\ "com", "admin", "pass", %v, %v)` , format (jsVal , `"` ), format (esVal , `"` )),
96
+ Result : fmt .Sprintf (`create table users (name, age, height, actived, bytes, create_at, update_at, deleted_at, email, role, pass, json_struct, example_struct) values ("jinzhu", 1, 999.99, true, "12345", "2020-02-23 11:10:10", "2020-02-23 11:10:10", NULL, "w@g." "com", "admin", "pass", %v, %v)` , format (jsVal , `"` ), format (esVal , `"` )),
97
97
},
98
98
{
99
99
SQL : "create table users (name, age, height, actived, bytes, create_at, update_at, deleted_at, email, role, pass, json_struct, example_struct) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" ,
100
100
NumericRegexp : nil ,
101
101
Vars : []interface {}{"jinzhu" , 1 , 0.1753607109 , true , []byte ("12345" ), tt , & tt , nil , "w@g.\" com" , myrole , pwd , & js , & es },
102
- Result : fmt .Sprintf (`create table users (name, age, height, actived, bytes, create_at, update_at, deleted_at, email, role, pass, json_struct, example_struct) values ("jinzhu", 1, 0.1753607109, true, "12345", "2020-02-23 11:10:10", "2020-02-23 11:10:10", NULL, "w@g.\ "com", "admin", "pass", %v, %v)` , format (jsVal , `"` ), format (esVal , `"` )),
102
+ Result : fmt .Sprintf (`create table users (name, age, height, actived, bytes, create_at, update_at, deleted_at, email, role, pass, json_struct, example_struct) values ("jinzhu", 1, 0.1753607109, true, "12345", "2020-02-23 11:10:10", "2020-02-23 11:10:10", NULL, "w@g." "com", "admin", "pass", %v, %v)` , format (jsVal , `"` ), format (esVal , `"` )),
103
103
},
104
104
{
105
105
SQL : "create table users (name, age, height, actived, bytes, create_at, update_at, deleted_at, email, role, pass, json_struct, example_struct) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" ,
106
106
NumericRegexp : nil ,
107
107
Vars : []interface {}{"jinzhu" , 1 , float32 (999.99 ), true , []byte ("12345" ), tt , & tt , nil , "w@g.\" com" , myrole , pwd , & js , & es },
108
- Result : fmt .Sprintf (`create table users (name, age, height, actived, bytes, create_at, update_at, deleted_at, email, role, pass, json_struct, example_struct) values ("jinzhu", 1, 999.99, true, "12345", "2020-02-23 11:10:10", "2020-02-23 11:10:10", NULL, "w@g.\ "com", "admin", "pass", %v, %v)` , format (jsVal , `"` ), format (esVal , `"` )),
108
+ Result : fmt .Sprintf (`create table users (name, age, height, actived, bytes, create_at, update_at, deleted_at, email, role, pass, json_struct, example_struct) values ("jinzhu", 1, 999.99, true, "12345", "2020-02-23 11:10:10", "2020-02-23 11:10:10", NULL, "w@g." "com", "admin", "pass", %v, %v)` , format (jsVal , `"` ), format (esVal , `"` )),
109
109
},
110
110
}
111
111
0 commit comments