mirror of
https://github.com/apache/superset.git
synced 2026-04-21 00:54:44 +00:00
fix(chart): allow null for most query object props (#12905)
This commit is contained in:
@@ -18,6 +18,8 @@ import pytest
|
||||
|
||||
from superset import db
|
||||
from superset.charts.schemas import ChartDataQueryContextSchema
|
||||
from superset.common.query_context import QueryContext
|
||||
from superset.common.query_object import QueryObject
|
||||
from superset.connectors.connector_registry import ConnectorRegistry
|
||||
from superset.extensions import cache_manager
|
||||
from superset.models.cache import CacheKey
|
||||
@@ -126,6 +128,22 @@ class TestQueryContext(SupersetTestCase):
|
||||
# the new cache_key should be different due to updated datasource
|
||||
self.assertNotEqual(cache_key_original, cache_key_new)
|
||||
|
||||
def test_query_cache_key_does_not_change_for_non_existent_or_null(self):
|
||||
self.login(username="admin")
|
||||
payload = get_query_context("birth_names", add_postprocessing_operations=True)
|
||||
del payload["queries"][0]["granularity"]
|
||||
|
||||
# construct baseline query_cache_key from query_context with post processing operation
|
||||
query_context: QueryContext = ChartDataQueryContextSchema().load(payload)
|
||||
query_object: QueryObject = query_context.queries[0]
|
||||
cache_key_original = query_context.query_cache_key(query_object)
|
||||
|
||||
payload["queries"][0]["granularity"] = None
|
||||
query_context = ChartDataQueryContextSchema().load(payload)
|
||||
query_object = query_context.queries[0]
|
||||
|
||||
assert query_context.query_cache_key(query_object) == cache_key_original
|
||||
|
||||
def test_query_cache_key_changes_when_post_processing_is_updated(self):
|
||||
self.login(username="admin")
|
||||
payload = get_query_context("birth_names", add_postprocessing_operations=True)
|
||||
|
||||
Reference in New Issue
Block a user