mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
fix(migrations): Handle comparator None in old time comparison migration (#32538)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user