diff --git a/src/blp/blp.py b/src/blp/blp.py index 7ace55a..0ac26f9 100644 --- a/src/blp/blp.py +++ b/src/blp/blp.py @@ -886,9 +886,10 @@ def collect_many_to_bds(self, responses) -> Dict: sec_dict = res.get(security, {}) for field in response["data"]: data = response["data"][field] - rows = sec_dict.get(field, []) - rows.extend(data) - sec_dict[field] = rows + if data: + rows = sec_dict.get(field, []) + rows.extend(data) + sec_dict[field] = rows res[security] = sec_dict for s in res: for f in res[s]: diff --git a/src/blp/test/test_blp.py b/src/blp/test/test_blp.py index d6b31e6..acf1ca6 100644 --- a/src/blp/test/test_blp.py +++ b/src/blp/test/test_blp.py @@ -2448,19 +2448,22 @@ def collector_params(): "INDX_MWEIGHT_HIST": pandas.DataFrame({"Index Member": ["BON9", "C N9"], "Percent Weight": [2.89, 5.32]}) } } + # test for https://github.com/matthewgilbert/blp/pull/8 + bulk_reference_parsed_data_empty = [ + {"security": "TRAD3 BZ Equity", "fields": ["DVD_HIST_ALL"], "data": {"DVD_HIST_ALL": None}} + ] + bulk_reference_empty_collected_exp = {"TRAD3 BZ Equity": {}} + return { - "ids": ["collect_many_to_bds_single_bulk", "collect_many_to_bds_with_multi_bulk"], + "ids": [ + "collect_many_to_bds_single_bulk", + "collect_many_to_bds_with_multi_bulk", + "collect_many_empty_to_bds_single_bulk", + ], "argvalues": [ - ( - bulk_reference_parsed_data, - blp.BlpQuery().collect_many_to_bds, - bulk_reference_collected_exp, - ), - ( - bulk_reference_parsed_data_multi, - blp.BlpQuery().collect_many_to_bds, - bulk_reference_collected_multi_exp, - ), + (bulk_reference_parsed_data, blp.BlpQuery().collect_many_to_bds, bulk_reference_collected_exp), + (bulk_reference_parsed_data_multi, blp.BlpQuery().collect_many_to_bds, bulk_reference_collected_multi_exp), + (bulk_reference_parsed_data_empty, blp.BlpQuery().collect_many_to_bds, bulk_reference_empty_collected_exp), ], }