1
0
Fork 0

Adding upstream version 25.5.1.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-13 21:41:00 +01:00
parent 147b6e06e8
commit 4e506fbac7
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
136 changed files with 80990 additions and 72541 deletions

View file

@ -2,8 +2,9 @@ import json
import os
import unittest
from sqlglot import exp, jsonpath
from sqlglot import exp
from sqlglot.errors import ParseError, TokenError
from sqlglot.jsonpath import parse
from tests.helpers import FIXTURES_DIR
@ -25,7 +26,7 @@ class TestJsonpath(unittest.TestCase):
exp.JSONPathSelector(this=exp.JSONPathScript(this="@.x)")),
]
self.assertEqual(
jsonpath.parse("$.*.a[0]['x'][*, 'y', 1].z[?(@.a == 'b'), 1:][1:5][1,?@.a][(@.x)]"),
parse("$.*.a[0]['x'][*, 'y', 1].z[?(@.a == 'b'), 1:][1:5][1,?@.a][(@.x)]"),
exp.JSONPath(expressions=expected_expressions),
)
@ -36,7 +37,7 @@ class TestJsonpath(unittest.TestCase):
("$[((@.length-1))]", "$[((@.length-1))]"),
):
with self.subTest(f"{selector} -> {expected}"):
self.assertEqual(jsonpath.parse(selector).sql(), f"'{expected}'")
self.assertEqual(parse(selector).sql(), f"'{expected}'")
def test_cts_file(self):
with open(os.path.join(FIXTURES_DIR, "jsonpath", "cts.json")) as file:
@ -131,9 +132,9 @@ class TestJsonpath(unittest.TestCase):
with self.subTest(f"{selector.strip()} /* {test['name']} */"):
if test.get("invalid_selector"):
try:
jsonpath.parse(selector)
parse(selector)
except (ParseError, TokenError):
pass
else:
path = jsonpath.parse(selector)
path = parse(selector)
self.assertEqual(path.sql(), f"'{overrides.get(selector, selector)}'")