entc/predicate: add isnull/notnull predicates for codegen

Reviewed By: idoshveki

Differential Revision: D16687226

fbshipit-source-id: 14a39e066447dbf77413e5c7f7318a2d61bddd32
This commit is contained in:
Ariel Mashraki
2019-08-07 06:53:00 -07:00
committed by Facebook Github Bot
parent 23059c8bae
commit 25f5a2ef01
27 changed files with 1060 additions and 44 deletions

View File

@@ -191,6 +191,17 @@ func TestBuilder(t *testing.T) {
Where(NotNull("parent_id")),
wantQuery: "DELETE FROM `users` WHERE `parent_id` IS NOT NULL",
},
{
input: Delete("users").
Where(IsNull("parent_id")),
wantQuery: "DELETE FROM `users` WHERE `parent_id` IS NULL",
},
{
input: Delete("users").
Where(IsNull("parent_id").And().NotIn("name", "foo", "bar")),
wantQuery: "DELETE FROM `users` WHERE `parent_id` IS NULL AND `name` NOT IN (?, ?)",
wantArgs: []interface{}{"foo", "bar"},
},
{
input: Delete("users").
Where(False().And().False()),