1
0
Fork 0

Adding upstream version 15.0.0.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-13 15:56:32 +01:00
parent 70d5d3451a
commit bb75596aa9
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
167 changed files with 58268 additions and 51337 deletions

View file

@ -224,7 +224,10 @@ FROM bar /* comment 5 */, tbl /* comment 6 */""",
)
self.validate(
"""
select a from b
select a
-- from
from b
-- where
where foo
-- comment 1
and bar
@ -233,7 +236,9 @@ FROM bar /* comment 5 */, tbl /* comment 6 */""",
""",
"""SELECT
a
/* from */
FROM b
/* where */
WHERE
foo /* comment 1 */ AND bar AND bla /* comment 2 */""",
pretty=True,
@ -550,14 +555,14 @@ FROM v""",
def test_error_level(self, logger):
invalid = "x + 1. ("
expected_messages = [
"Required keyword: 'expressions' missing for <class 'sqlglot.expressions.Aliases'>. Line 1, Col: 9.\n x + 1. \033[4m(\033[0m",
"Expecting ). Line 1, Col: 9.\n x + 1. \033[4m(\033[0m",
"Required keyword: 'expressions' missing for <class 'sqlglot.expressions.Aliases'>. Line 1, Col: 8.\n x + 1. \033[4m(\033[0m",
"Expecting ). Line 1, Col: 8.\n x + 1. \033[4m(\033[0m",
]
expected_errors = [
{
"description": "Required keyword: 'expressions' missing for <class 'sqlglot.expressions.Aliases'>",
"line": 1,
"col": 9,
"col": 8,
"start_context": "x + 1. ",
"highlight": "(",
"end_context": "",
@ -566,7 +571,7 @@ FROM v""",
{
"description": "Expecting )",
"line": 1,
"col": 9,
"col": 8,
"start_context": "x + 1. ",
"highlight": "(",
"end_context": "",
@ -580,26 +585,28 @@ FROM v""",
with self.assertRaises(ParseError) as ctx:
transpile(invalid, error_level=ErrorLevel.IMMEDIATE)
self.assertEqual(str(ctx.exception), expected_messages[0])
self.assertEqual(ctx.exception.errors[0], expected_errors[0])
with self.assertRaises(ParseError) as ctx:
transpile(invalid, error_level=ErrorLevel.RAISE)
self.assertEqual(str(ctx.exception), "\n\n".join(expected_messages))
self.assertEqual(ctx.exception.errors, expected_errors)
more_than_max_errors = "(((("
expected_messages = (
"Required keyword: 'this' missing for <class 'sqlglot.expressions.Paren'>. Line 1, Col: 5.\n (((\033[4m(\033[0m\n\n"
"Expecting ). Line 1, Col: 5.\n (((\033[4m(\033[0m\n\n"
"Expecting ). Line 1, Col: 5.\n (((\033[4m(\033[0m\n\n"
"Required keyword: 'this' missing for <class 'sqlglot.expressions.Paren'>. Line 1, Col: 4.\n (((\033[4m(\033[0m\n\n"
"Expecting ). Line 1, Col: 4.\n (((\033[4m(\033[0m\n\n"
"Expecting ). Line 1, Col: 4.\n (((\033[4m(\033[0m\n\n"
"... and 2 more"
)
expected_errors = [
{
"description": "Required keyword: 'this' missing for <class 'sqlglot.expressions.Paren'>",
"line": 1,
"col": 5,
"col": 4,
"start_context": "(((",
"highlight": "(",
"end_context": "",
@ -608,7 +615,7 @@ FROM v""",
{
"description": "Expecting )",
"line": 1,
"col": 5,
"col": 4,
"start_context": "(((",
"highlight": "(",
"end_context": "",
@ -620,6 +627,7 @@ FROM v""",
with self.assertRaises(ParseError) as ctx:
transpile(more_than_max_errors, error_level=ErrorLevel.RAISE)
self.assertEqual(str(ctx.exception), expected_messages)
self.assertEqual(ctx.exception.errors, expected_errors)