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)