-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
A MongoQuery may return an inaccurate empty list after multiple requests with different payloads.
For example, referring to the following query, sending a first query Q1 with a "report_type:A" parameter will return a list of - for example - 3 ReportDto's. A second query Q2 with a "report_type:B" parameter will return an empty list, which is correct in the test.
A third query Q3 with a "report_type:A" parameter (so the same query as Q1!) will now return an empty list - which is wrong as it should still be 3...
class ReportsByTypeQuery(Query[OperationResult[ReportDto]]):
"""Represents the query used to get an account by its owner id"""
report_type: ReportType
def __init__(self, report_type: ReportType):
self.report_type = report_type
class ReportsByTypeQueryHandler(
QueryHandler[ReportsByTypeQuery, OperationResult[ReportDto]]
):
"""Represents the service used to handle ReportsByTypeQuery instances"""
def __init__(self, repository: QueryableRepository[ReportDto, str]):
self.repository = repository
repository: QueryableRepository[ReportDto, str]
async def handle_async(
self, query: ReportsByTypeQuery
) -> OperationResult[ReportDto]:
# q = await self.repository.query_async()
# result = q.where(lambda r: r.type == query.report_type.value).to_list()
# return self.ok(result)
return self.ok((await self.repository.query_async()).where(lambda r: r.type == query.report_type.value).to_list())I'm using the neuroglia.data.infrastructure.mongo.mongo_repository module... Thanks!
Metadata
Metadata
Assignees
Labels
No labels