diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-03-19 10:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-03-19 10:22:09 +0000 |
commit | 66af5c6fc22f6f11e9ea807b274e011a6f64efb7 (patch) | |
tree | 08ceed3b311b7b343935c1e55941b9d15e6f56d8 /tests/test_expressions.py | |
parent | Releasing debian version 11.3.6-1. (diff) | |
download | sqlglot-66af5c6fc22f6f11e9ea807b274e011a6f64efb7.tar.xz sqlglot-66af5c6fc22f6f11e9ea807b274e011a6f64efb7.zip |
Merging upstream version 11.4.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_expressions.py')
-rw-r--r-- | tests/test_expressions.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/test_expressions.py b/tests/test_expressions.py index ecbdc24..69e1d14 100644 --- a/tests/test_expressions.py +++ b/tests/test_expressions.py @@ -6,6 +6,8 @@ from sqlglot import alias, exp, parse_one class TestExpressions(unittest.TestCase): + maxDiff = None + def test_arg_key(self): self.assertEqual(parse_one("sum(1)").find(exp.Literal).arg_key, "this") @@ -91,6 +93,32 @@ class TestExpressions(unittest.TestCase): self.assertIsInstance(column.parent_select, exp.Select) self.assertIsNone(column.find_ancestor(exp.Join)) + def test_to_dot(self): + column = parse_one('a.b.c."d".e.f').find(exp.Column) + dot = column.to_dot() + + self.assertEqual(dot.sql(), 'a.b.c."d".e.f') + + self.assertEqual( + dot, + exp.Dot( + this=exp.Dot( + this=exp.Dot( + this=exp.Dot( + this=exp.Dot( + this=exp.to_identifier("a"), + expression=exp.to_identifier("b"), + ), + expression=exp.to_identifier("c"), + ), + expression=exp.to_identifier("d", quoted=True), + ), + expression=exp.to_identifier("e"), + ), + expression=exp.to_identifier("f"), + ), + ) + def test_root(self): ast = parse_one("select * from (select a from x)") self.assertIs(ast, ast.root()) @@ -480,6 +508,7 @@ class TestExpressions(unittest.TestCase): self.assertIsInstance(parse_one("COMMIT"), exp.Commit) self.assertIsInstance(parse_one("ROLLBACK"), exp.Rollback) self.assertIsInstance(parse_one("GENERATE_SERIES(a, b, c)"), exp.GenerateSeries) + self.assertIsInstance(parse_one("COUNT_IF(a > 0)"), exp.CountIf) def test_column(self): column = parse_one("a.b.c.d") |