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:
@@ -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."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user