From cad3b840a41bb0ef201d89a8e32b6a829bf0556d Mon Sep 17 00:00:00 2001 From: Roman <79310030+roman-right@users.noreply.github.com> Date: Tue, 6 Jul 2021 21:42:07 +0200 Subject: [PATCH] bool type in search criteria (#86) --- beanie/__init__.py | 2 +- beanie/odm/documents.py | 18 +++++++++--------- beanie/odm/queries/find.py | 22 +++++++++++----------- docs/changelog.md | 14 +++++++++++++- pyproject.toml | 2 +- tests/test_beanie.py | 2 +- 6 files changed, 36 insertions(+), 24 deletions(-) diff --git a/beanie/__init__.py b/beanie/__init__.py index e894bb85..5edc60a7 100644 --- a/beanie/__init__.py +++ b/beanie/__init__.py @@ -4,7 +4,7 @@ from beanie.odm.utils.general import init_beanie from beanie.odm.documents import Document -__version__ = "1.2.1" +__version__ = "1.2.2" __all__ = [ # ODM "Document", diff --git a/beanie/odm/documents.py b/beanie/odm/documents.py index d8b73209..0184d43a 100644 --- a/beanie/odm/documents.py +++ b/beanie/odm/documents.py @@ -170,7 +170,7 @@ async def get( @classmethod def find_one( cls: Type[DocType], - *args: Union[Mapping[str, Any], Any], + *args: Union[Mapping[str, Any], bool], projection_model: None = None, session: Optional[ClientSession] = None, ) -> FindOne[DocType]: @@ -180,7 +180,7 @@ def find_one( @classmethod def find_one( cls: Type[DocType], - *args: Union[Mapping[str, Any], Any], + *args: Union[Mapping[str, Any], bool], projection_model: Type[DocumentProjectionType], session: Optional[ClientSession] = None, ) -> FindOne[DocumentProjectionType]: @@ -189,7 +189,7 @@ def find_one( @classmethod def find_one( cls: Type[DocType], - *args: Union[Mapping[str, Any], Any], + *args: Union[Mapping[str, Any], bool], projection_model: Optional[Type[DocumentProjectionType]] = None, session: Optional[ClientSession] = None, ): @@ -213,7 +213,7 @@ def find_one( @classmethod def find_many( cls: Type[DocType], - *args: Union[Mapping[str, Any], Any], + *args: Union[Mapping[str, Any], bool], projection_model: None = None, skip: Optional[int] = None, limit: Optional[int] = None, @@ -226,7 +226,7 @@ def find_many( @classmethod def find_many( cls: Type[DocType], - *args: Union[Mapping[str, Any], Any], + *args: Union[Mapping[str, Any], bool], projection_model: Type[DocumentProjectionType] = None, skip: Optional[int] = None, limit: Optional[int] = None, @@ -238,7 +238,7 @@ def find_many( @classmethod def find_many( cls: Type[DocType], - *args: Union[Mapping[str, Any], Any], + *args: Union[Mapping[str, Any], bool], projection_model: Optional[Type[DocumentProjectionType]] = None, skip: Optional[int] = None, limit: Optional[int] = None, @@ -272,7 +272,7 @@ def find_many( @classmethod def find( cls: Type[DocType], - *args: Union[Mapping[str, Any], Any], + *args: Union[Mapping[str, Any], bool], projection_model: None = None, skip: Optional[int] = None, limit: Optional[int] = None, @@ -285,7 +285,7 @@ def find( @classmethod def find( cls: Type[DocType], - *args: Union[Mapping[str, Any], Any], + *args: Union[Mapping[str, Any], bool], projection_model: Type[DocumentProjectionType], skip: Optional[int] = None, limit: Optional[int] = None, @@ -297,7 +297,7 @@ def find( @classmethod def find( cls: Type[DocType], - *args: Union[Mapping[str, Any], Any], + *args: Union[Mapping[str, Any], bool], projection_model: Optional[Type[DocumentProjectionType]] = None, skip: Optional[int] = None, limit: Optional[int] = None, diff --git a/beanie/odm/queries/find.py b/beanie/odm/queries/find.py index 7926e237..8e879771 100644 --- a/beanie/odm/queries/find.py +++ b/beanie/odm/queries/find.py @@ -187,7 +187,7 @@ def __init__(self, document_model: Type["DocType"]): @overload def find_many( self: "FindMany[FindQueryResultType]", - *args: Union[Mapping[str, Any], Any], + *args: Union[Mapping[str, Any], bool], projection_model: None = None, skip: Optional[int] = None, limit: Optional[int] = None, @@ -199,7 +199,7 @@ def find_many( @overload def find_many( self: "FindMany[FindQueryResultType]", - *args: Union[Mapping[str, Any], Any], + *args: Union[Mapping[str, Any], bool], projection_model: Type[FindQueryProjectionType] = None, skip: Optional[int] = None, limit: Optional[int] = None, @@ -210,7 +210,7 @@ def find_many( def find_many( self: "FindMany[FindQueryResultType]", - *args: Union[Mapping[str, Any], Any], + *args: Union[Mapping[str, Any], bool], projection_model: Optional[Type[FindQueryProjectionType]] = None, skip: Optional[int] = None, limit: Optional[int] = None, @@ -232,7 +232,7 @@ def find_many( :param session: Optional[ClientSession] - pymongo session :return: FindMany - query instance """ - self.find_expressions += args + self.find_expressions += args # type: ignore # bool workaround self.skip(skip) self.limit(limit) self.sort(sort) @@ -275,7 +275,7 @@ def project( @overload def find( self: "FindMany[FindQueryResultType]", - *args: Union[Mapping[str, Any], Any], + *args: Union[Mapping[str, Any], bool], projection_model: None = None, skip: Optional[int] = None, limit: Optional[int] = None, @@ -287,7 +287,7 @@ def find( @overload def find( self: "FindMany[FindQueryResultType]", - *args: Union[Mapping[str, Any], Any], + *args: Union[Mapping[str, Any], bool], projection_model: Type[FindQueryProjectionType] = None, skip: Optional[int] = None, limit: Optional[int] = None, @@ -298,7 +298,7 @@ def find( def find( self: "FindMany[FindQueryResultType]", - *args: Union[Mapping[str, Any], Any], + *args: Union[Mapping[str, Any], bool], projection_model: Optional[Type[FindQueryProjectionType]] = None, skip: Optional[int] = None, limit: Optional[int] = None, @@ -519,7 +519,7 @@ def project( @overload def find_one( self: "FindOne[FindQueryResultType]", - *args: Union[Mapping[str, Any], Any], + *args: Union[Mapping[str, Any], bool], projection_model: None = None, session: Optional[ClientSession] = None, ) -> "FindOne[FindQueryResultType]": @@ -528,7 +528,7 @@ def find_one( @overload def find_one( self: "FindOne[FindQueryResultType]", - *args: Union[Mapping[str, Any], Any], + *args: Union[Mapping[str, Any], bool], projection_model: Type[FindQueryProjectionType], session: Optional[ClientSession] = None, ) -> "FindOne[FindQueryProjectionType]": @@ -536,7 +536,7 @@ def find_one( def find_one( self: "FindOne[FindQueryResultType]", - *args: Union[Mapping[str, Any], Any], + *args: Union[Mapping[str, Any], bool], projection_model: Optional[Type[FindQueryProjectionType]] = None, session: Optional[ClientSession] = None, ) -> Union[ @@ -550,7 +550,7 @@ def find_one( :param session: Optional[ClientSession] - pymongo session :return: FindOne - query instance """ - self.find_expressions += args + self.find_expressions += args # type: ignore # bool workaround self.project(projection_model) self.set_session(session=session) return self diff --git a/docs/changelog.md b/docs/changelog.md index a6dc541b..4476d22c 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -2,6 +2,16 @@ Beanie project changes +## [1.2.2] - 2021-07-06 + +### Fixed + +- Bool types in search criteria + +### Implementation + +- Issue - + ## [1.2.1] - 2021-07-06 ### Fixed @@ -336,4 +346,6 @@ Beanie project changes [1.2.0]: https://pypi.org/project/beanie/1.2.0 -[1.2.1]: https://pypi.org/project/beanie/1.2.1 \ No newline at end of file +[1.2.1]: https://pypi.org/project/beanie/1.2.1 + +[1.2.2]: https://pypi.org/project/beanie/1.2.2 \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 4e813922..22c28cde 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "beanie" -version = "1.2.1" +version = "1.2.2" description = "Asynchronous Python ODM for MongoDB" authors = ["Roman "] license = "Apache-2.0" diff --git a/tests/test_beanie.py b/tests/test_beanie.py index fc303180..6b91c073 100644 --- a/tests/test_beanie.py +++ b/tests/test_beanie.py @@ -2,4 +2,4 @@ def test_version(): - assert __version__ == "1.2.1" + assert __version__ == "1.2.2"