From cdffd0b29d5b072639bb02118d6828f4d1b76099 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 14 Aug 2023 12:12:13 +0200 Subject: Adding upstream version 17.12.0. Signed-off-by: Daniel Baumann --- tests/test_transpile.py | 56 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) (limited to 'tests/test_transpile.py') diff --git a/tests/test_transpile.py b/tests/test_transpile.py index 3f284c9..e58ed86 100644 --- a/tests/test_transpile.py +++ b/tests/test_transpile.py @@ -90,6 +90,19 @@ 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 a INNER /* comments */ JOIN b", + "SELECT * FROM a /* comments */ INNER JOIN b", + ) + self.validate( + "SELECT * FROM a LEFT /* comment 1 */ OUTER /* comment 2 */ JOIN b", + "SELECT * FROM a /* comment 1 */ /* comment 2 */ LEFT OUTER JOIN b", + ) + self.validate( + "SELECT CASE /* test */ WHEN a THEN b ELSE c END", + "SELECT CASE WHEN a THEN b ELSE c END /* test */", + ) self.validate("SELECT 1 /*/2 */", "SELECT 1 /* /2 */") self.validate("SELECT */*comment*/", "SELECT * /* comment */") self.validate( @@ -308,6 +321,7 @@ DROP TABLE IF EXISTS db.tba""", ) self.validate( """ + -- comment4 CREATE TABLE db.tba AS SELECT a, b, c FROM tb_01 @@ -316,8 +330,10 @@ DROP TABLE IF EXISTS db.tba""", a = 1 AND b = 2 --comment6 -- and c = 1 -- comment7 + ; """, - """CREATE TABLE db.tba AS + """/* comment4 */ +CREATE TABLE db.tba AS SELECT a, b, @@ -329,6 +345,44 @@ WHERE /* comment7 */""", pretty=True, ) + self.validate( + """ + SELECT + -- This is testing comments + col, + -- 2nd testing comments + CASE WHEN a THEN b ELSE c END as d + FROM t + """, + """SELECT + col, /* This is testing comments */ + CASE WHEN a THEN b ELSE c END /* 2nd testing comments */ AS d +FROM t""", + pretty=True, + ) + self.validate( + """ + SELECT * FROM a + -- comments + INNER JOIN b + """, + """SELECT + * +FROM a +/* comments */ +INNER JOIN b""", + pretty=True, + ) + self.validate( + "SELECT * FROM a LEFT /* comment 1 */ OUTER /* comment 2 */ JOIN b", + """SELECT + * +FROM a +/* comment 1 */ +/* comment 2 */ +LEFT OUTER JOIN b""", + pretty=True, + ) def test_types(self): self.validate("INT 1", "CAST(1 AS INT)") -- cgit v1.2.3