Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,4 @@ Contributors (chronological)
- Emmanuel Ferdman `@emmanuel-ferdman <https://github.com/emmanuel-ferdman>`_
- Fridayworks `@worksbyfriday <https://github.com/worksbyfriday>`_
- `@rstar327 <https://github.com/rstar327>`_
- Kadir Can Ozden `@bysiber <https://github.com/bysiber>`_
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Bug fixes:
Thanks :user:`nosnickid` for the report and :user:`worksbyfriday` for the PR.
- Fix `marshmallow.validate.OneOf` emitting extra pairs when labels outnumber choices (:issue:`2869`).
Thanks: user:`T90REAL` for the report and :user:`rstar327` for the PR.
- Fix behavior when passing a dot-delited attribute name to ``partial`` for a key with ``data_key`` set (:pr:`2903`).
Thanks :user:`bysiber` for the PR.


4.2.2 (2026-02-04)
Expand Down
2 changes: 1 addition & 1 deletion src/marshmallow/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ def _deserialize(
d_kwargs = {}
# Allow partial loading of nested schemas.
if partial_is_collection:
prefix = field_name + "."
prefix = attr_name + "."
len_prefix = len(prefix)
sub_partial = [
f[len_prefix:] for f in partial if f.startswith(prefix)
Expand Down
20 changes: 20 additions & 0 deletions tests/test_deserialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -2307,6 +2307,26 @@ class SchemaB(Schema):
with pytest.raises(ValidationError):
SchemaB().load({"z": {"x": 0}})

def test_nested_partial_tuple_with_data_key(self):
class AddressSchema(Schema):
zip_code = fields.String(required=True)
city = fields.String(required=True)

class PersonSchema(Schema):
address = fields.Nested(
AddressSchema, data_key="homeAddress", required=True
)

data = {"homeAddress": {"city": "Springfield"}}
# partial uses attr_name ("address.zip_code"), not data_key
result = PersonSchema().load(data, partial=("address.zip_code",))
assert result["address"]["city"] == "Springfield"
assert "zip_code" not in result["address"]
# Without partial, it should fail on the missing required field
with pytest.raises(ValidationError) as excinfo:
PersonSchema().load(data)
assert "zip_code" in excinfo.value.messages["homeAddress"]


@pytest.mark.parametrize("FieldClass", ALL_FIELDS)
def test_required_field_failure(FieldClass):
Expand Down