Skip to content

Commit

Permalink
working fix
Browse files Browse the repository at this point in the history
  • Loading branch information
hughhhh authored May 23, 2022
1 parent 9a368cb commit 169022a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 16 deletions.
2 changes: 1 addition & 1 deletion superset/datasets/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand Down
4 changes: 1 addition & 3 deletions superset/datasets/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
Expand Down
13 changes: 1 addition & 12 deletions tests/integration_tests/datasets/api_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 169022a

Please sign in to comment.