mirror of
https://github.com/apache/superset.git
synced 2026-04-19 16:14:52 +00:00
feat!: pass datasource_type and datasource_id to form_data (#19981)
* pass datasource_type and datasource_id to form_data * add datasource_type to delete command * add datasource_type to delete command * fix old keys implementation * add more tests
This commit is contained in:
committed by
GitHub
parent
a813528958
commit
32bb1ce3ff
@@ -15,15 +15,40 @@
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import logging
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
from flask import Flask
|
||||
from flask_caching import Cache
|
||||
from markupsafe import Markup
|
||||
|
||||
from superset.utils.core import DatasourceType
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
CACHE_IMPORT_PATH = "superset.extensions.metastore_cache.SupersetMetastoreCache"
|
||||
|
||||
|
||||
class ExploreFormDataCache(Cache):
|
||||
def get(self, *args: Any, **kwargs: Any) -> Optional[Union[str, Markup]]:
|
||||
cache = self.cache.get(*args, **kwargs)
|
||||
|
||||
if not cache:
|
||||
return None
|
||||
|
||||
# rename data keys for existing cache based on new TemporaryExploreState model
|
||||
if isinstance(cache, dict):
|
||||
cache = {
|
||||
("datasource_id" if key == "dataset_id" else key): value
|
||||
for (key, value) in cache.items()
|
||||
}
|
||||
# add default datasource_type if it doesn't exist
|
||||
# temporarily defaulting to table until sqlatables are deprecated
|
||||
if "datasource_type" not in cache:
|
||||
cache["datasource_type"] = DatasourceType.TABLE
|
||||
|
||||
return cache
|
||||
|
||||
|
||||
class CacheManager:
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
@@ -32,7 +57,7 @@ class CacheManager:
|
||||
self._data_cache = Cache()
|
||||
self._thumbnail_cache = Cache()
|
||||
self._filter_state_cache = Cache()
|
||||
self._explore_form_data_cache = Cache()
|
||||
self._explore_form_data_cache = ExploreFormDataCache()
|
||||
|
||||
@staticmethod
|
||||
def _init_cache(
|
||||
|
||||
Reference in New Issue
Block a user