Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions tests/wire/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Comment thread
cjber marked this conversation as resolved.
Resolved
"""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)
12 changes: 12 additions & 0 deletions tests/wire/test_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Loading