Skip to content

Commit

Permalink
Refactor Encoder
Browse files Browse the repository at this point in the history
  • Loading branch information
gsakkis committed Sep 17, 2023
1 parent 60dc39c commit 28712de
Show file tree
Hide file tree
Showing 4 changed files with 166 additions and 280 deletions.
4 changes: 1 addition & 3 deletions beanie/odm/queries/find.py
Original file line number Diff line number Diff line change
Expand Up @@ -940,9 +940,7 @@ async def replace_one(
Operation(
operation=ReplaceOne,
first_query=self.get_filter_query(),
second_query=Encoder(
by_alias=True, exclude={"_id"}
).encode(document),
second_query=Encoder(exclude={"_id"}).encode(document),
object_class=self.document_model,
pymongo_kwargs=self.pymongo_kwargs,
)
Expand Down
5 changes: 2 additions & 3 deletions beanie/odm/utils/dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ def get_dict(
exclude.add("_id")
if not document.get_settings().use_revision:
exclude.add("revision_id")
return Encoder(
by_alias=True, exclude=exclude, to_db=to_db, keep_nulls=keep_nulls
).encode(document)
encoder = Encoder(exclude=exclude, to_db=to_db, keep_nulls=keep_nulls)
return encoder.encode(document)


def get_nulls(
Expand Down
Loading

0 comments on commit 28712de

Please sign in to comment.