dialect/sql: add example to SIMILAR TO predicate (#2055)

This commit is contained in:
Ariel Mashraki
2021-10-21 12:01:58 +03:00
committed by GitHub
parent 8c752862cf
commit 963bd669fd

View File

@@ -322,6 +322,15 @@ func TestBuilder(t *testing.T) {
wantQuery: `UPDATE "users" SET "name" = $1, "age" = $2`,
wantArgs: []interface{}{"foo", 10},
},
{
input: Dialect(dialect.Postgres).Update("users").
Set("active", false).
Where(P(func(b *Builder) {
b.Ident("name").WriteString(" SIMILAR TO ").Arg("(b|c)%")
})),
wantQuery: `UPDATE "users" SET "active" = $1 WHERE "name" SIMILAR TO $2`,
wantArgs: []interface{}{false, "(b|c)%"},
},
{
input: Update("users").Set("name", "foo").Where(EQ("name", "bar")),
wantQuery: "UPDATE `users` SET `name` = ? WHERE `name` = ?",