-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Fix nested_to_record with None values in nested levels #21164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -375,3 +375,59 @@ def test_nonetype_dropping(self): | |
'info.last_updated': '26/05/2012'}] | ||
|
||
assert result == expected | ||
|
||
def test_nonetype_top_level_bottom_level(self): | ||
# GH21158: If inner level json has a key with a null value | ||
# make sure it doesnt do a new_d.pop twice and except | ||
data = { | ||
"id": None, | ||
"location": { | ||
"country": { | ||
"state": { | ||
"id": None, | ||
"town.info": { | ||
"id": None, | ||
"region": None, | ||
"x": 49.151580810546875, | ||
"y": -33.148521423339844, | ||
"z": 27.572303771972656}}} | ||
} | ||
} | ||
result = nested_to_record(data) | ||
expected = { | ||
'location.country.state.id': None, | ||
'location.country.state.town.info.id': None, | ||
'location.country.state.town.info.region': None, | ||
'location.country.state.town.info.x': 49.151580810546875, | ||
'location.country.state.town.info.y': -33.148521423339844, | ||
'location.country.state.town.info.z': 27.572303771972656} | ||
assert result == expected | ||
|
||
def test_nonetype_multiple_levels(self): | ||
# GH21158: If inner level json has a key with a null value | ||
# make sure it doesnt do a new_d.pop twice and except | ||
data = { | ||
"id": None, | ||
"location": { | ||
"id": None, | ||
"country": { | ||
"id": None, | ||
"state": { | ||
"id": None, | ||
"town.info": { | ||
"region": None, | ||
"x": 49.151580810546875, | ||
"y": -33.148521423339844, | ||
"z": 27.572303771972656}}} | ||
} | ||
} | ||
result = nested_to_record(data) | ||
expected = { | ||
'location.id': None, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was reading through the commentary of the issue and noticed there was some confusion on the topic, but I don't understand why we would want to drop the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know I'm late replying to this, but I agree. I don't understand the intention of dropping the top level |
||
'location.country.id': None, | ||
'location.country.state.id': None, | ||
'location.country.state.town.info.region': None, | ||
'location.country.state.town.info.x': 49.151580810546875, | ||
'location.country.state.town.info.y': -33.148521423339844, | ||
'location.country.state.town.info.z': 27.572303771972656} | ||
assert result == expected |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this have the same result if id is NOT repeated (with None), just missing at various levels? e.g. try with a single id with None at the top and bottom levels (in another case, leave this one as well)