Skip to content

Commit

Permalink
🎨 [#4431] Improve addressNL mapping backwards compatibility
Browse files Browse the repository at this point in the history
This way we don't need to add a data migration to update the options,
the old configuration (pre 3.0) will continue to work.
  • Loading branch information
sergei-maertens committed Nov 22, 2024
1 parent a2ece69 commit c91acc9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -503,11 +503,14 @@ def _get_data(

filtered_value = {k: v for k, v in value.items() if v}
if target_path:
filtered_value.pop("secretStreetCity", None)
# 'old' behaviour - the component as a whole is mapped to an object
# in the schema. We send it as-is, but drop internal data structures.
_value = value.copy()
_value.pop("secretStreetCity", None)
glom.assign(
record_data,
glom.Path(*target_path),
filtered_value,
_value,
missing=dict,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,6 @@ def test_addressNl_legacy_before_of_30(self):
"streetName": "",
"houseLetter": "d",
"houseNumber": "73",
"secretStreetCity": "",
"houseNumberAddition": "2",
}
},
Expand Down Expand Up @@ -1292,6 +1291,8 @@ def test_addressNl_with_object_target_path(self):
"houseLetter": "d",
"houseNumber": "73",
"houseNumberAddition": "2",
"streetName": "",
"city": "",
}
},
)

0 comments on commit c91acc9

Please sign in to comment.