summaryrefslogtreecommitdiffstats
path: root/tests/test_expressions.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-02-08 04:14:34 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-02-08 04:14:34 +0000
commit8bec55350caa5c760d8b7e7e2d0ba6c77a32bc71 (patch)
treed6259e0351c7b4a50d528122513d533bb582eb2b /tests/test_expressions.py
parentReleasing debian version 10.6.0-1. (diff)
downloadsqlglot-8bec55350caa5c760d8b7e7e2d0ba6c77a32bc71.tar.xz
sqlglot-8bec55350caa5c760d8b7e7e2d0ba6c77a32bc71.zip
Merging upstream version 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.py14
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")