1
0
Fork 0

Adding upstream version 25.24.5.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-13 21:55:31 +01:00
parent a0663ae805
commit 7af32ea9ec
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
80 changed files with 61531 additions and 59444 deletions

View file

@ -157,11 +157,20 @@ class TestDiff(unittest.TestCase):
self._validate_delta_only(
diff_delta_only(expr_src, expr_tgt),
[
Remove(parse_one("ROW_NUMBER()")), # the Anonymous node
Insert(parse_one("RANK()")), # the Anonymous node
Remove(parse_one("ROW_NUMBER()")),
Insert(parse_one("RANK()")),
Update(source=expr_src.selects[0], target=expr_tgt.selects[0]),
],
)
expr_src = parse_one("SELECT MAX(x) OVER (ORDER BY y) FROM z", "oracle")
expr_tgt = parse_one("SELECT MAX(x) KEEP (DENSE_RANK LAST ORDER BY y) FROM z", "oracle")
self._validate_delta_only(
diff_delta_only(expr_src, expr_tgt),
[Update(source=expr_src.selects[0], target=expr_tgt.selects[0])],
)
def test_pre_matchings(self):
expr_src = parse_one("SELECT 1")
expr_tgt = parse_one("SELECT 1, 2, 3, 4")
@ -202,5 +211,34 @@ class TestDiff(unittest.TestCase):
],
)
expr_src = parse_one("SELECT 1 AS c1, 2 AS c2")
expr_tgt = parse_one("SELECT 2 AS c1, 3 AS c2")
self._validate_delta_only(
diff_delta_only(expr_src, expr_tgt),
[
Remove(expression=exp.alias_(1, "c1")),
Remove(expression=exp.Literal.number(1)),
Insert(expression=exp.alias_(3, "c2")),
Insert(expression=exp.Literal.number(3)),
Update(source=exp.alias_(2, "c2"), target=exp.alias_(2, "c1")),
],
)
def test_dialect_aware_diff(self):
from sqlglot.generator import logger
with self.assertLogs(logger) as cm:
# We want to assert there are no warnings, but the 'assertLogs' method does not support that.
# Therefore, we are adding a dummy warning, and then we will assert it is the only warning.
logger.warning("Dummy warning")
expression = parse_one("SELECT foo FROM bar FOR UPDATE", dialect="oracle")
self._validate_delta_only(
diff_delta_only(expression, expression.copy(), dialect="oracle"), []
)
self.assertEqual(["WARNING:sqlglot:Dummy warning"], cm.output)
def _validate_delta_only(self, actual_delta, expected_delta):
self.assertEqual(set(actual_delta), set(expected_delta))