Skip to content

Commit

Permalink
schema: fix data reference update in pre_load
Browse files Browse the repository at this point in the history
  • Loading branch information
yashlamba committed Feb 15, 2024
1 parent a734cbb commit 3cc509a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions invenio_records_resources/services/records/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# details.

"""Record schema."""

from copy import deepcopy
from datetime import timezone

from marshmallow import Schema, ValidationError, fields, pre_load
Expand All @@ -30,12 +30,13 @@ class BaseRecordSchema(Schema):
revision_id = fields.Integer(dump_only=True)

@pre_load
def clean(self, data, **kwargs):
def clean(self, input_data, **kwargs):
"""Removes dump_only fields.
Why: We want to allow the output of a Schema dump, to be a valid input
to a Schema load without causing strange issues.
"""
data = deepcopy(input_data)
for name, field in self.fields.items():
if field.dump_only:
data.pop(name, None)
Expand Down

0 comments on commit 3cc509a

Please sign in to comment.