Skip to content

Commit

Permalink
tests indexed fields (#795)
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-right committed Dec 3, 2023
1 parent 09b3607 commit 5f03c6f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ test = [
"httpx>=0.23.0",
"fastapi>=0.100",
"pydantic-settings>=2",
"pydantic-extra-types>=2"
"pydantic-extra-types>=2",
"pydantic[email]",
]
doc = [
"Pygments>=2.8.0",
Expand Down
2 changes: 2 additions & 0 deletions tests/odm/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
DocumentWithDeprecatedHiddenField,
DocumentWithExtras,
DocumentWithHttpUrlField,
DocumentWithIndexedObjectId,
DocumentWithIndexMerging1,
DocumentWithIndexMerging2,
DocumentWithKeepNullsFalse,
Expand Down Expand Up @@ -279,6 +280,7 @@ async def init(db):
DocumentWithOptionalBackLink,
DocumentWithOptionalListBackLink,
DocumentWithComplexDictKey,
DocumentWithIndexedObjectId,
]
await init_beanie(
database=db,
Expand Down
7 changes: 7 additions & 0 deletions tests/odm/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
UUID4,
BaseModel,
ConfigDict,
EmailStr,
Field,
HttpUrl,
PrivateAttr,
Expand Down Expand Up @@ -1053,3 +1054,9 @@ class DocumentWithHttpUrlField(Document):

class DocumentWithComplexDictKey(Document):
dict_field: Dict[UUID, datetime.datetime]


class DocumentWithIndexedObjectId(Document):
pyid: Indexed(PydanticObjectId)
uuid: Annotated[UUID4, Indexed(unique=True)]
email: Annotated[EmailStr, Indexed(unique=True)]

0 comments on commit 5f03c6f

Please sign in to comment.