Skip to content

Commit

Permalink
Feat: add is_ builder.
Browse files Browse the repository at this point in the history
  • Loading branch information
tobymao committed May 16, 2023
1 parent cc7a5de commit 40820b1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions sqlglot/expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,9 @@ def between(self, low: t.Any, high: t.Any, copy=True, **opts) -> Between:
high=convert(high, copy=copy, **opts),
)

def is_(self, other: ExpOrStr) -> Is:
return self._binop(Is, other)

def like(self, other: ExpOrStr) -> Like:
return self._binop(Like, other)

Expand Down
1 change: 1 addition & 0 deletions tests/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def test_build(self):
(lambda: 1 >= x, "x <= 1"),
(lambda: x.eq(1), "x = 1"),
(lambda: x.neq(1), "x <> 1"),
(lambda: x.is_(exp.Null()), "x IS NULL"),
(lambda: x.isin(1, "2"), "x IN (1, '2')"),
(lambda: x.isin(query="select 1"), "x IN (SELECT 1)"),
(lambda: x.between(1, 2), "x BETWEEN 1 AND 2"),
Expand Down

0 comments on commit 40820b1

Please sign in to comment.