You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// SELECT id, name FROM products WHERE tenant_id = $1 AND deleted_at IS NULL AND ("status" = $2 AND "id" IN ($3, $4)) ORDER BY "created_at" DESC, "id" ASC LIMIT $5
// [acme active 1 2 20]
}
func ExampleQuery_AndIf() {
q := "widget"
query, args, err := sqlwhere.On("SELECT id, name FROM products").
AndIf(q != "", sqlwhere.Like("name", "%"+q+"%")).
Build(sqlwhere.Postgres)
if err != nil {
panic(err)
}
fmt.Println(query)
fmt.Println(args)
// Output:
// SELECT id, name FROM products WHERE ("name" LIKE $1)