summaryrefslogtreecommitdiffstats
path: root/tests/test_expressions.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-01-04 07:24:05 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-01-04 07:24:05 +0000
commit621555af37594a213d91ea113d5fc7739af84d40 (patch)
tree5aaa3b586692062accffc21cfaaa5a3917ee77b3 /tests/test_expressions.py
parentAdding upstream version 10.2.9. (diff)
downloadsqlglot-621555af37594a213d91ea113d5fc7739af84d40.tar.xz
sqlglot-621555af37594a213d91ea113d5fc7739af84d40.zip
Adding upstream version 10.4.2.upstream/10.4.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_expressions.py')
-rw-r--r--tests/test_expressions.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/tests/test_expressions.py b/tests/test_expressions.py
index 0e13ade..1e23983 100644
--- a/tests/test_expressions.py
+++ b/tests/test_expressions.py
@@ -1,4 +1,5 @@
import datetime
+import math
import unittest
from sqlglot import alias, exp, parse_one
@@ -491,7 +492,7 @@ class TestExpressions(unittest.TestCase):
self.assertEqual(alias("foo", "bar-1").sql(), 'foo AS "bar-1"')
self.assertEqual(alias("foo", "bar_1").sql(), "foo AS bar_1")
self.assertEqual(alias("foo * 2", "2bar").sql(), 'foo * 2 AS "2bar"')
- self.assertEqual(alias('"foo"', "_bar").sql(), '"foo" AS "_bar"')
+ self.assertEqual(alias('"foo"', "_bar").sql(), '"foo" AS _bar')
self.assertEqual(alias("foo", "bar", quoted=True).sql(), 'foo AS "bar"')
def test_unit(self):
@@ -503,6 +504,8 @@ class TestExpressions(unittest.TestCase):
def test_identifier(self):
self.assertTrue(exp.to_identifier('"x"').quoted)
self.assertFalse(exp.to_identifier("x").quoted)
+ self.assertTrue(exp.to_identifier("foo ").quoted)
+ self.assertFalse(exp.to_identifier("_x").quoted)
def test_function_normalizer(self):
self.assertEqual(parse_one("HELLO()").sql(normalize_functions="lower"), "hello()")
@@ -549,14 +552,15 @@ class TestExpressions(unittest.TestCase):
([1, "2", None], "ARRAY(1, '2', NULL)"),
({"x": None}, "MAP('x', NULL)"),
(
- datetime.datetime(2022, 10, 1, 1, 1, 1),
- "TIME_STR_TO_TIME('2022-10-01 01:01:01.000000')",
+ datetime.datetime(2022, 10, 1, 1, 1, 1, 1),
+ "TIME_STR_TO_TIME('2022-10-01T01:01:01.000001+00:00')",
),
(
datetime.datetime(2022, 10, 1, 1, 1, 1, tzinfo=datetime.timezone.utc),
- "TIME_STR_TO_TIME('2022-10-01 01:01:01.000000+0000')",
+ "TIME_STR_TO_TIME('2022-10-01T01:01:01+00:00')",
),
(datetime.date(2022, 10, 1), "DATE_STR_TO_DATE('2022-10-01')"),
+ (math.nan, "NULL"),
]:
with self.subTest(value):
self.assertEqual(exp.convert(value).sql(), expected)