mirror of
https://github.com/ent/ent.git
synced 2026-05-22 09:31:45 +03:00
dialect/sql: add example to SIMILAR TO predicate (#2055)
This commit is contained in:
@@ -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` = ?",
|
||||
|
||||
Reference in New Issue
Block a user