summaryrefslogtreecommitdiffstats
path: root/tests/test_expressions.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_expressions.py')
-rw-r--r--tests/test_expressions.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/tests/test_expressions.py b/tests/test_expressions.py
index f050c0b..277bec1 100644
--- a/tests/test_expressions.py
+++ b/tests/test_expressions.py
@@ -442,12 +442,15 @@ class TestExpressions(unittest.TestCase):
expression.find(exp.Table).replace(parse_one("y"))
self.assertEqual(expression.sql(), "SELECT c, b FROM y")
- def test_pop(self):
+ def test_arg_deletion(self):
+ # Using the pop helper method
expression = parse_one("SELECT a, b FROM x")
expression.find(exp.Column).pop()
self.assertEqual(expression.sql(), "SELECT b FROM x")
+
expression.find(exp.Column).pop()
self.assertEqual(expression.sql(), "SELECT FROM x")
+
expression.pop()
self.assertEqual(expression.sql(), "SELECT FROM x")
@@ -455,6 +458,15 @@ class TestExpressions(unittest.TestCase):
expression.find(exp.With).pop()
self.assertEqual(expression.sql(), "SELECT * FROM x")
+ # Manually deleting by setting to None
+ expression = parse_one("SELECT * FROM foo JOIN bar")
+ self.assertEqual(len(expression.args.get("joins", [])), 1)
+
+ expression.set("joins", None)
+ self.assertEqual(expression.sql(), "SELECT * FROM foo")
+ self.assertEqual(expression.args.get("joins", []), [])
+ self.assertIsNone(expression.args.get("joins"))
+
def test_walk(self):
expression = parse_one("SELECT * FROM (SELECT * FROM x)")
self.assertEqual(len(list(expression.walk())), 9)
@@ -539,6 +551,9 @@ class TestExpressions(unittest.TestCase):
self.assertIsInstance(parse_one("ARRAY(time, foo)"), exp.Array)
self.assertIsInstance(parse_one("STANDARD_HASH('hello', 'sha256')"), exp.StandardHash)
self.assertIsInstance(parse_one("DATE(foo)"), exp.Date)
+ self.assertIsInstance(parse_one("HEX(foo)"), exp.Hex)
+ self.assertIsInstance(parse_one("TO_HEX(foo)", read="bigquery"), exp.Hex)
+ self.assertIsInstance(parse_one("TO_HEX(MD5(foo))", read="bigquery"), exp.MD5)
def test_column(self):
column = parse_one("a.b.c.d")