fix: type the ids filter from its configured id type

advanced_alchemy annotates the `ids` query parameter as list[str] whatever the
config says, so a bigint primary key was compared against strings and Postgres
refused. Nothing had called ?ids= until now.
This commit is contained in:
2026-08-16 20:20:44 -04:00
parent 2e0d556c33
commit a48be517e4
2 changed files with 40 additions and 0 deletions
+15
View File
@@ -209,6 +209,21 @@ async def test_get_book_file(
assert downloaded_content == file_content
async def test_list_books_by_id(populated_authenticated_client: AsyncClient) -> None:
"""
`?ids=` has to reach the database as integers.
advanced_alchemy's stock id filter annotates the parameter as `list[str]` whatever
the configured id type, so the ids arrived as strings and Postgres refused to
compare a bigint primary key against them. Nothing called it until a screen needed
to fetch a handful of books by id.
"""
response = await populated_authenticated_client.get("/books?ids=1&ids=2&pageSize=10")
assert response.status_code == 200
assert sorted(book["id"] for book in response.json()["items"]) == [1, 2]
async def test_get_book_by_id(populated_authenticated_client: AsyncClient) -> None:
"""Test retrieving a specific book by ID."""