summaryrefslogtreecommitdiffstats
path: root/tests/test_transpile.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_transpile.py')
-rw-r--r--tests/test_transpile.py57
1 files changed, 56 insertions, 1 deletions
diff --git a/tests/test_transpile.py b/tests/test_transpile.py
index d588f07..c16b1f6 100644
--- a/tests/test_transpile.py
+++ b/tests/test_transpile.py
@@ -19,6 +19,9 @@ class TestTranspile(unittest.TestCase):
def validate(self, sql, target, **kwargs):
self.assertEqual(transpile(sql, **kwargs)[0], target)
+ def test_weird_chars(self):
+ self.assertEqual(transpile("0Êß")[0], "0 AS Êß")
+
def test_alias(self):
self.assertEqual(transpile("SELECT SUM(y) KEEP")[0], "SELECT SUM(y) AS KEEP")
self.assertEqual(transpile("SELECT 1 overwrite")[0], "SELECT 1 AS overwrite")
@@ -87,7 +90,18 @@ class TestTranspile(unittest.TestCase):
self.validate("SELECT 3>=3", "SELECT 3 >= 3")
def test_comments(self):
- self.validate("SELECT\n foo\n/* comments */\n;", "SELECT foo /* comments */")
+ self.validate(
+ "SELECT * FROM t1\n/*x*/\nUNION ALL SELECT * FROM t2",
+ "SELECT * FROM t1 /* x */ UNION ALL SELECT * FROM t2",
+ )
+ self.validate(
+ "SELECT * FROM t1\n/*x*/\nINTERSECT ALL SELECT * FROM t2",
+ "SELECT * FROM t1 /* x */ INTERSECT ALL SELECT * FROM t2",
+ )
+ self.validate(
+ "SELECT\n foo\n/* comments */\n;",
+ "SELECT foo /* comments */",
+ )
self.validate(
"SELECT * FROM a INNER /* comments */ JOIN b",
"SELECT * FROM a /* comments */ INNER JOIN b",
@@ -379,6 +393,47 @@ LEFT OUTER JOIN b""",
FROM tbl""",
pretty=True,
)
+ self.validate(
+ """
+SELECT
+ 'hotel1' AS hotel,
+ *
+FROM dw_1_dw_1_1.exactonline_1.transactionlines
+/*
+ UNION ALL
+ SELECT
+ 'Thon Partner Hotel Jølster' AS hotel,
+ name,
+ date,
+ CAST(identifier AS VARCHAR) AS identifier,
+ value
+ FROM d2o_889_oupjr_1348.public.accountvalues_forecast
+*/
+UNION ALL
+SELECT
+ 'hotel2' AS hotel,
+ *
+FROM dw_1_dw_1_1.exactonline_2.transactionlines""",
+ """SELECT
+ 'hotel1' AS hotel,
+ *
+FROM dw_1_dw_1_1.exactonline_1.transactionlines /*
+ UNION ALL
+ SELECT
+ 'Thon Partner Hotel Jølster' AS hotel,
+ name,
+ date,
+ CAST(identifier AS VARCHAR) AS identifier,
+ value
+ FROM d2o_889_oupjr_1348.public.accountvalues_forecast
+*/
+UNION ALL
+SELECT
+ 'hotel2' AS hotel,
+ *
+FROM dw_1_dw_1_1.exactonline_2.transactionlines""",
+ pretty=True,
+ )
def test_types(self):
self.validate("INT 1", "CAST(1 AS INT)")