diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-02-08 04:14:30 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-02-08 04:14:30 +0000 |
commit | 99980f928b5b7be237d108266072e51aa3bb354e (patch) | |
tree | ce6fff00ea2b834bdbe3d84dcac90df1617d4245 /tests/test_expressions.py | |
parent | Adding upstream version 10.6.0. (diff) | |
download | sqlglot-99980f928b5b7be237d108266072e51aa3bb354e.tar.xz sqlglot-99980f928b5b7be237d108266072e51aa3bb354e.zip |
Adding upstream version 10.6.3.upstream/10.6.3
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_expressions.py')
-rw-r--r-- | tests/test_expressions.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/test_expressions.py b/tests/test_expressions.py index 2d5407e..55e07d1 100644 --- a/tests/test_expressions.py +++ b/tests/test_expressions.py @@ -466,6 +466,7 @@ class TestExpressions(unittest.TestCase): self.assertIsInstance(parse_one("BEGIN DEFERRED TRANSACTION"), exp.Transaction) 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) def test_column(self): dot = parse_one("a.b.c") @@ -630,6 +631,19 @@ FROM foo""", FROM foo""", ) + def test_to_interval(self): + self.assertEqual(exp.to_interval("1day").sql(), "INTERVAL '1' day") + self.assertEqual(exp.to_interval(" 5 months").sql(), "INTERVAL '5' months") + with self.assertRaises(ValueError): + exp.to_interval("bla") + + self.assertEqual(exp.to_interval(exp.Literal.string("1day")).sql(), "INTERVAL '1' day") + self.assertEqual( + exp.to_interval(exp.Literal.string(" 5 months")).sql(), "INTERVAL '5' months" + ) + with self.assertRaises(ValueError): + exp.to_interval(exp.Literal.string("bla")) + def test_to_table(self): table_only = exp.to_table("table_name") self.assertEqual(table_only.name, "table_name") |