fix(migrations): Handle comparator None in old time comparison migration (#32538)

This commit is contained in:
Antonio Rivero
2025-03-07 16:30:24 +01:00
committed by GitHub
parent 68e8d9858c
commit 20e5df501e
2 changed files with 29 additions and 1 deletions

View File

@@ -170,6 +170,23 @@ params_v2_other_than_custom_false: dict[str, Any] = {
"time_compare": [],
}
params_v1_with_custom_and_no_comparator: dict[str, Any] = {
**params_v1_with_custom,
"adhoc_custom": [
{
"expressionType": "SIMPLE",
"subject": "ds",
"operator": "TEMPORAL_RANGE",
"comparator": None,
"clause": "WHERE",
"sqlExpression": None,
"isExtra": False,
"isNew": False,
"datasourceWarning": False,
}
],
}
def test_upgrade_chart_params_with_custom():
"""
@@ -241,3 +258,14 @@ def test_upgrade_chart_params_empty():
assert downgrade_comparison_params(None) == {}
assert downgrade_comparison_params({}) == {}
assert downgrade_comparison_params("") == {}
def test_upgrade_chart_params_with_custom_no_comparator():
"""
ensure that the new time comparison params are added but no start_date_offset
"""
original_params = deepcopy(params_v1_with_custom_and_no_comparator)
expected_after_upgrade = deepcopy(params_v2_with_custom)
expected_after_upgrade.pop("start_date_offset")
upgraded_params = upgrade_comparison_params(original_params)
assert upgraded_params == expected_after_upgrade