JCelento commented on code in PR #36985:
URL: https://github.com/apache/superset/pull/36985#discussion_r2704754471
##########
tests/unit_tests/utils/test_core.py:
##########
@@ -1089,6 +1090,151 @@ def
test_merge_extra_filters_when_applied_time_extras_predefined():
}
+def test_merge_extra_form_data_updates_temporal_range_subject():
+ """
+ Test that when extra_form_data contains granularity_sqla, it should update
+ the subject of any TEMPORAL_RANGE adhoc filter to use the new time column.
+ """
+ form_data = {
+ "adhoc_filters": [
+ {
+ "clause": "WHERE",
+ "comparator": "No filter",
+ "expressionType": "SIMPLE",
+ "operator": "TEMPORAL_RANGE",
+ "subject": "created_at",
+ }
+ ],
+ "extra_form_data": {
+ "granularity_sqla": "event_date",
+ "time_range": "Last week",
+ },
+ }
+ merge_extra_form_data(form_data)
+
+ assert form_data["adhoc_filters"][0]["subject"] == "event_date"
+ assert form_data["time_range"] == "Last week"
+ assert form_data["granularity"] == "event_date"
Review Comment:
Not sure why codeant is suggesting this, but I'll add context here to avoid
confusion: merge_extra_form_data sets granularity in the result, not
granularity_sqla. granularity_sqla is the input (from extra_form_data), and it
gets mapped to granularity in the output.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]