fastapi-pagination icon indicating copy to clipboard operation
fastapi-pagination copied to clipboard

pymongo filter_fields should default to None, not {}

Open spr opened this issue 2 years ago • 4 comments

The new filter_fields argument in pymongo changes from None to {}, as with query_filter.

https://github.com/uriyyo/fastapi-pagination/blob/91cdd7a706705d8c5d0dbe51d690fb3db06c4803/fastapi_pagination/ext/pymongo.py#L31

However, in pymongo None means "perform no filtering" and {} means "return only the ObjectId".

So, this results in errors of the following kind:

pydantic_core._pydantic_core.ValidationError: 3 validation errors for Page[Peripheral]
items.0.peripheralID
  Field required [type=missing, input_value={'_id': ObjectId('6286cafb01072e1f8a55b7ca')}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.5/v/missing

I think this is as simple as removing the linked line to fix the problem.

spr avatar Dec 13 '23 18:12 spr

@spr Thanks for reporting this issue, will try to fix it ASAP

uriyyo avatar Dec 14 '23 08:12 uriyyo

Thanks for the quick fix!

spr avatar Dec 14 '23 17:12 spr

@spr I am planing to release fix tomorrow. I will notify you, when it will be ready

uriyyo avatar Dec 14 '23 17:12 uriyyo

Hi @spr,

New version 0.12.14 has been released, this issue should be fixed.

uriyyo avatar Dec 17 '23 14:12 uriyyo

Hi @spr,

I am closing this issue, please reopen it in case if issue still exists on your side

uriyyo avatar Feb 09 '24 12:02 uriyyo