Skip to content

Commit eb0d49f

Browse files
committed
added test case
1 parent a279c16 commit eb0d49f

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

tests/test_api/test_api_sqla_with_includes.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2520,6 +2520,54 @@ async def test_filter_none_instead_of_uuid(
25202520
],
25212521
}
25222522

2523+
async def test_join_by_relationships_works_correctly_with_many_filters_for_one_field(
2524+
self,
2525+
app: FastAPI,
2526+
async_session: AsyncSession,
2527+
client: AsyncClient,
2528+
user_1: User,
2529+
user_1_post: PostComment,
2530+
):
2531+
comment_1 = PostComment(
2532+
text=fake.sentence(),
2533+
post_id=user_1_post.id,
2534+
author_id=user_1.id,
2535+
)
2536+
comment_2 = PostComment(
2537+
text=fake.sentence(),
2538+
post_id=user_1_post.id,
2539+
author_id=user_1.id,
2540+
)
2541+
assert comment_1.text != comment_2.text
2542+
async_session.add_all([comment_1, comment_2])
2543+
await async_session.commit()
2544+
2545+
params = {
2546+
"filter": dumps(
2547+
[
2548+
{
2549+
"name": "posts.comments.text",
2550+
"op": "eq",
2551+
"val": comment_1.text,
2552+
},
2553+
{
2554+
"name": "posts.comments.text",
2555+
"op": "eq",
2556+
"val": comment_2.text,
2557+
},
2558+
],
2559+
),
2560+
}
2561+
2562+
url = app.url_path_for("get_user_list")
2563+
res = await client.get(url, params=params)
2564+
assert res.status_code == status.HTTP_200_OK, res.text
2565+
assert res.json() == {
2566+
"data": [],
2567+
"jsonapi": {"version": "1.0"},
2568+
"meta": {"count": 1, "totalPages": 1},
2569+
}
2570+
25232571

25242572
ASCENDING = ""
25252573
DESCENDING = "-"

0 commit comments

Comments
 (0)