Skip to content

Commit f27a89c

Browse files
committed
add json object test
1 parent 1805725 commit f27a89c

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

test/resources/orders_test.jsonl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,4 @@
6161
{"name": "union_all", "sql": "SELECT id FROM orders WHERE id = 123 UNION ALL SELECT id FROM orders WHERE id = 123", "errors": [], "data": [[123], [123]]}
6262
{"name": "union_all_3_parts", "sql": "SELECT id FROM orders WHERE id = 123 UNION ALL SELECT id FROM orders WHERE id = 123 UNION ALL SELECT id FROM orders WHERE id = 123", "errors": [], "data": [[123], [123], [123]]}
6363
{"name": "union_all_missing_restriction", "sql": "SELECT id FROM orders WHERE id = 123 UNION ALL SELECT id FROM orders", "errors": ["Missing restriction for table: orders column: id value: 123"], "fix": "SELECT id FROM orders WHERE id = 123 UNION ALL SELECT id FROM orders WHERE id = 123", "data": [[123], [123]]}
64+
{"name": "with_and_json_object", "skip-reason": "Parser replaces comma with colon inside json_object", "sql": "WITH expanded AS ( SELECT id, product_name, account_id, status FROM orders WHERE id = 123) SELECT json_object('id', id, 'status', status) FROM expanded", "errors": ["Column status is not allowed. Column removed from SELECT clause"], "fix": "WITH expanded AS (SELECT id, product_name, account_id FROM orders WHERE id = 123) SELECT JSON_OBJECT('id', id, 'status', status) FROM expanded", "data": [[123]]}

test/test_sql_guard_unit.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,9 @@ def ai_tests(self) -> dict:
8686
@pytest.mark.parametrize("test_name", [t["name"] for t in _get_tests("orders_test.jsonl")])
8787
def test_orders_from_file(self, test_name, config, cnn, tests):
8888
test = tests[test_name]
89-
_test_sql(test["sql"], config, set(test.get("errors", [])),
90-
test.get("fix"), cnn=cnn, data=test.get("data"))
89+
if not "skip-reason" in test:
90+
_test_sql(test["sql"], config, set(test.get("errors", [])),
91+
test.get("fix"), cnn=cnn, data=test.get("data"))
9192

9293
@pytest.mark.parametrize("test_name", [t["name"] for t in _get_tests("orders_ai_generated.jsonl")])
9394
def test_orders_from_file_ai(self, test_name, config, cnn, ai_tests):

0 commit comments

Comments
 (0)