dialect/sql: fix escape issue occurred in fuzzy testing (#3115)

* fix(builder):fix escape method

* fix(builder):fix escape method

Co-authored-by: chenfuqing <chenfuqing@laiye.com>
This commit is contained in:
cheny-alf
2022-11-26 19:26:14 +08:00
committed by GitHub
parent 05de3fb096
commit 2840921231
2 changed files with 8 additions and 3 deletions

View File

@@ -2067,6 +2067,11 @@ func TestEscapePatterns(t *testing.T) {
Query()
require.Equal(t, "UPDATE `users` SET `name` = NULL WHERE `nickname` LIKE ? ESCAPE ? OR `nickname` LIKE ? ESCAPE ? OR `nickname` LIKE ? ESCAPE ? OR LOWER(`nickname`) LIKE ? ESCAPE ?", q)
require.Equal(t, []any{"\\%a8m\\%%", "\\", "%\\_alexsn\\_", "\\", "%\\\\pedro\\\\%", "\\", "%\\%abcd\\%efg%", "\\"}, args)
q, args = Select("*").From(Table("dataset")).
Where(Contains("title", "_第一")).Query()
require.Equal(t, "SELECT * FROM `dataset` WHERE `title` LIKE ?", q)
require.Equal(t, []any{"%\\_第一%"}, args)
}
func TestReusePredicates(t *testing.T) {