Add test for #2331

This commit is contained in:
Lunny Xiao 2023-10-19 16:29:40 +08:00
parent dbe499091a
commit f556e8a899
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
2 changed files with 9 additions and 3 deletions

View File

@ -131,6 +131,8 @@ func TestJoin(t *testing.T) {
assert.EqualValues(t, "[a].*,[b].[c]", quoter.Join([]string{"a.*", " b.c"}, ","))
assert.EqualValues(t, "[a] [c]", quoter.Join([]string{"a c"}, ","))
assert.EqualValues(t, "[f1], [f2], [f3]", quoter.Join(cols, ", "))
quoter.IsReserved = AlwaysNoReserve
@ -146,7 +148,7 @@ func TestStrings(t *testing.T) {
}
func TestTrim(t *testing.T) {
var kases = map[string]string{
kases := map[string]string{
"[table_name]": "table_name",
"[schema].[table_name]": "schema.table_name",
}
@ -159,7 +161,7 @@ func TestTrim(t *testing.T) {
func TestReplace(t *testing.T) {
q := Quoter{'[', ']', AlwaysReserve}
var kases = []struct {
kases := []struct {
source string
expected string
}{
@ -171,6 +173,10 @@ func TestReplace(t *testing.T) {
"SELECT 'abc```test```''', `a` FROM b",
"SELECT 'abc```test```''', [a] FROM b",
},
{
"SELECT * FROM `a` INNER JOIN `b` `c` WHERE `a`.`id` = `c`.`a_id`",
"SELECT * FROM [a] INNER JOIN [b] [c] WHERE [a].[id] = [c].[a_id]",
},
{
"UPDATE table SET `a` = ~ `a`, `b`='abc`'",
"UPDATE table SET [a] = ~ [a], [b]='abc`'",

View File

@ -493,4 +493,4 @@ func TestRowsReset(t *testing.T) {
assert.EqualValues(t, "4", rrs[0].Name)
assert.EqualValues(t, "5", rrs[1].Name)
assert.EqualValues(t, "6", rrs[2].Name)
}
}