diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-07-10 05:36:25 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-07-10 05:36:25 +0000 |
commit | 3517257d82008871c863f71a402742556dacc5cf (patch) | |
tree | 65704dee85c7aa830d01426c9bc3080a80c4e863 /tests/test_expressions.py | |
parent | Adding upstream version 17.2.0. (diff) | |
download | sqlglot-3517257d82008871c863f71a402742556dacc5cf.tar.xz sqlglot-3517257d82008871c863f71a402742556dacc5cf.zip |
Adding upstream version 17.3.0.upstream/17.3.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | tests/test_expressions.py | 17 |
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") |