From 169022a28aa17a3b44c17145686ba05b7cbd5192 Mon Sep 17 00:00:00 2001 From: "Hugh A. Miles II" Date: Mon, 23 May 2022 18:22:01 +0000 Subject: [PATCH] working fix --- superset/datasets/api.py | 2 +- superset/datasets/filters.py | 4 +--- tests/integration_tests/datasets/api_tests.py | 13 +------------ 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/superset/datasets/api.py b/superset/datasets/api.py index 8c8d1797a4a1a..fb01b6ee8c9cc 100644 --- a/superset/datasets/api.py +++ b/superset/datasets/api.py @@ -199,7 +199,7 @@ class DatasetRestApi(BaseSupersetModelRestApi): "sql": [DatasetIsNullOrEmptyFilter], "id": [DatasetCertifiedFilter], } - search_columns = ["id", "sql"] + search_columns = ["id", "database", "owners", "sql", "table_name"] filter_rel_fields = {"database": [["id", DatabaseFilter, lambda: []]]} allowed_rel_fields = {"database", "owners"} allowed_distinct_fields = {"schema"} diff --git a/superset/datasets/filters.py b/superset/datasets/filters.py index d90d66ca3b288..e72eb281818ae 100644 --- a/superset/datasets/filters.py +++ b/superset/datasets/filters.py @@ -14,8 +14,6 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -from typing import Any - from flask_babel import lazy_gettext as _ from sqlalchemy import not_, or_ from sqlalchemy.orm.query import Query @@ -41,7 +39,7 @@ class DatasetCertifiedFilter(BaseFilter): # pylint: disable=too-few-public-meth name = _("Is certified") arg_name = "dataset_is_certified" - def apply(self, query: Query, value: Any) -> Query: + def apply(self, query: Query, value: bool) -> Query: check_value = '%"certification":%' if value is True: return query.filter(SqlaTable.extra.ilike(check_value)) diff --git a/tests/integration_tests/datasets/api_tests.py b/tests/integration_tests/datasets/api_tests.py index f8a0f3495dcec..781ae929b743c 100644 --- a/tests/integration_tests/datasets/api_tests.py +++ b/tests/integration_tests/datasets/api_tests.py @@ -1813,22 +1813,11 @@ def test_import_dataset_invalid_v0_validation(self): ] } - @pytest.mark.usefixtures("create_datasets", "create_virtual_datasets") + @pytest.mark.usefixtures("create_datasets") def test_get_datasets_is_certified_filter(self): """ Dataset API: Test custom dataset_is_certified filter """ - arguments = { - "filters": [{"col": "id", "opr": "dataset_is_certified", "value": False}] - } - self.login(username="admin") - uri = f"api/v1/dataset/?q={prison.dumps(arguments)}" - rv = self.client.get(uri) - - assert rv.status_code == 200 - response = json.loads(rv.data.decode("utf-8")) - assert response.get("count") == 5 - table_w_certification = SqlaTable( table_name="foo", schema=None,