Merging upstream version 17.12.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
aa315e6009
commit
aae08e0bb3
64 changed files with 12465 additions and 11885 deletions
|
@ -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)")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue