fix: don't reformat generated queries (#30350)

This commit is contained in:
Beto Dealmeida
2024-10-04 11:09:37 -04:00
committed by GitHub
parent b627011463
commit 0b34197815
11 changed files with 29 additions and 50 deletions

View File

@@ -716,7 +716,7 @@ class TestPostChartDataApi(BaseTestChartDataApi):
rv = self.post_assert_metric(CHART_DATA_URI, self.query_context_payload, "data")
result = rv.json["result"][0]["query"]
if get_example_database().backend != "presto":
assert "(\n 'boy' = 'boy'\n )" in result
assert "('boy' = 'boy')" in result
@unittest.skip("Extremely flaky test on MySQL")
@with_feature_flags(GLOBAL_ASYNC_QUERIES=True)
@@ -1347,13 +1347,13 @@ def test_time_filter_with_grain(test_client, login_as_admin, physical_query_cont
backend = get_example_database().backend
if backend == "sqlite":
assert (
"DATETIME(col5, 'start of day', -STRFTIME('%w', col5) || ' days') >="
"DATETIME(col5, 'start of day', -strftime('%w', col5) || ' days') >="
in query
)
elif backend == "mysql":
assert "DATE(DATE_SUB(col5, INTERVAL (DAYOFWEEK(col5) - 1) DAY)) >=" in query
assert "DATE(DATE_SUB(col5, INTERVAL DAYOFWEEK(col5) - 1 DAY)) >=" in query
elif backend == "postgresql":
assert "DATE_TRUNC('WEEK', col5) >=" in query
assert "DATE_TRUNC('week', col5) >=" in query
elif backend == "presto":
assert "date_trunc('week', CAST(col5 AS TIMESTAMP)) >=" in query