From 658617dfa5cded3178c1edf3b90113073179a0d4 Mon Sep 17 00:00:00 2001 From: cjber Date: Sun, 15 Nov 2026 20:08:30 +0000 Subject: [PATCH] test: pin membership and relationship compatibility cases Compare both membership operators with empty and null-containing arrays against npm Zero across every Postgres adapter. Exercise two callbacks sharing the same relationship base in one query. These deterministic cases cover the four upstream branches missed by the generated examples in dependency PR CI. --- tests/wire/test_query.py | 21 +++++++++++++++++++++ tests/wire/test_sql.py | 12 ++++++++++++ 2 files changed, 33 insertions(+) diff --git a/tests/wire/test_query.py b/tests/wire/test_query.py index c743445..fe0371a 100644 --- a/tests/wire/test_query.py +++ b/tests/wire/test_query.py @@ -301,3 +301,24 @@ def test_raw_handlers_match_upstream(harness: Harness, schema: Schema) -> None: handle_query_request(handler=lambda n, args: raw[n](args), schema=schema, body=body, user_id="u") ) assert _comparable(actual.to_json()) == _comparable(expected), name + + +def test_repeated_relationship_callbacks_match_upstream(harness: Harness, schema: Schema) -> None: + """Two exists callbacks reuse one parent query's interned relationship base.""" + program = _q( + "issue", + [ + "whereFn", + [ + "and", + [ + ["exists", "comments", {"ops": [["where", "body", "a"]]}, None], + ["exists", "comments", {"ops": [["where", "body", "b"]]}, None], + ], + ], + ], + ) + body = ["transform", [{"id": "repeated", "name": "prog", "args": [program]}]] + expected = harness.call("query", body=body, userID="u") + actual = asyncio.run(handle_query_request(handler=make_handler(schema), schema=schema, body=body, user_id="u")) + assert _comparable(actual.to_json()) == _comparable(expected) diff --git a/tests/wire/test_sql.py b/tests/wire/test_sql.py index a1d2d0a..64e5152 100644 --- a/tests/wire/test_sql.py +++ b/tests/wire/test_sql.py @@ -142,3 +142,15 @@ def test_pinned_queries_return_upstreams_rows( ) -> None: expected = harness.call("runQuery", url=sql_db.url, program=program) assert as_js(run_python(sql_db, schema, program, adapter)) == as_js(expected) + + +@pytest.mark.parametrize("adapter", ADAPTERS) +@pytest.mark.parametrize("operator", ["IN", "NOT IN"]) +@pytest.mark.parametrize("excluded", [[], ["a"], [None, "a"]]) +def test_membership_matches_upstreams_rows( + harness: Harness, sql_db: SqlDB, schema: Schema, adapter: str, operator: str, excluded: list[str | None] +) -> None: + """Pin both membership operators, including empty and null-containing SQL arrays.""" + program = _q("issue", ["where", "title", operator, excluded]) + expected = harness.call("runQuery", url=sql_db.url, program=program) + assert as_js(run_python(sql_db, schema, program, adapter)) == as_js(expected)