Skip to content

Commit

Permalink
bool type in search criteria (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-right authored Jul 6, 2021
1 parent eda1340 commit cad3b84
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 24 deletions.
2 changes: 1 addition & 1 deletion beanie/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
18 changes: 9 additions & 9 deletions beanie/odm/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand All @@ -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]:
Expand All @@ -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,
):
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
22 changes: 11 additions & 11 deletions beanie/odm/queries/find.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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)
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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]":
Expand All @@ -528,15 +528,15 @@ 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]":
...

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[
Expand All @@ -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
Expand Down
14 changes: 13 additions & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

Beanie project changes

## [1.2.2] - 2021-07-06

### Fixed

- Bool types in search criteria

### Implementation

- Issue - <https://github.com/roman-right/beanie/issues/85>

## [1.2.1] - 2021-07-06

### Fixed
Expand Down Expand Up @@ -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
[1.2.1]: https://pypi.org/project/beanie/1.2.1

[1.2.2]: https://pypi.org/project/beanie/1.2.2
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "beanie"
version = "1.2.1"
version = "1.2.2"
description = "Asynchronous Python ODM for MongoDB"
authors = ["Roman <[email protected]>"]
license = "Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion tests/test_beanie.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


def test_version():
assert __version__ == "1.2.1"
assert __version__ == "1.2.2"

0 comments on commit cad3b84

Please sign in to comment.