1
0
Fork 0

Adding upstream version 18.17.0.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-13 21:08:47 +01:00
parent fc6bad5705
commit 03001ce1e6
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
90 changed files with 46581 additions and 43319 deletions

View file

@ -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)")