mirror of
https://github.com/apache/superset.git
synced 2026-04-14 05:34:38 +00:00
chore(sqla): refactor query utils (#21811)
Co-authored-by: Ville Brofeldt <ville.brofeldt@apple.com>
This commit is contained in:
@@ -1098,3 +1098,53 @@ def test_chart_cache_timeout_chart_not_found(
|
||||
|
||||
rv = test_client.post(CHART_DATA_URI, json=physical_query_context)
|
||||
assert rv.json["result"][0]["cache_timeout"] == 1010
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"status_code,extras",
|
||||
[
|
||||
(200, {"where": "1 = 1"}),
|
||||
(200, {"having": "count(*) > 0"}),
|
||||
(400, {"where": "col1 in (select distinct col1 from physical_dataset)"}),
|
||||
(400, {"having": "count(*) > (select count(*) from physical_dataset)"}),
|
||||
],
|
||||
)
|
||||
@with_feature_flags(ALLOW_ADHOC_SUBQUERY=False)
|
||||
@pytest.mark.usefixtures("load_birth_names_dashboard_with_slices")
|
||||
def test_chart_data_subquery_not_allowed(
|
||||
test_client,
|
||||
login_as_admin,
|
||||
physical_dataset,
|
||||
physical_query_context,
|
||||
status_code,
|
||||
extras,
|
||||
):
|
||||
physical_query_context["queries"][0]["extras"] = extras
|
||||
rv = test_client.post(CHART_DATA_URI, json=physical_query_context)
|
||||
|
||||
assert rv.status_code == status_code
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"status_code,extras",
|
||||
[
|
||||
(200, {"where": "1 = 1"}),
|
||||
(200, {"having": "count(*) > 0"}),
|
||||
(200, {"where": "col1 in (select distinct col1 from physical_dataset)"}),
|
||||
(200, {"having": "count(*) > (select count(*) from physical_dataset)"}),
|
||||
],
|
||||
)
|
||||
@with_feature_flags(ALLOW_ADHOC_SUBQUERY=True)
|
||||
@pytest.mark.usefixtures("load_birth_names_dashboard_with_slices")
|
||||
def test_chart_data_subquery_allowed(
|
||||
test_client,
|
||||
login_as_admin,
|
||||
physical_dataset,
|
||||
physical_query_context,
|
||||
status_code,
|
||||
extras,
|
||||
):
|
||||
physical_query_context["queries"][0]["extras"] = extras
|
||||
rv = test_client.post(CHART_DATA_URI, json=physical_query_context)
|
||||
|
||||
assert rv.status_code == status_code
|
||||
|
||||
Reference in New Issue
Block a user