diff --git a/superset/models/dashboard.py b/superset/models/dashboard.py index d6dfe79d7f1d5..9292e1acd1bea 100644 --- a/superset/models/dashboard.py +++ b/superset/models/dashboard.py @@ -149,14 +149,13 @@ class Dashboard(Model, AuditMixinNullable, ImportExportMixin): Slice, secondary=dashboard_slices, backref="dashboards" ) owners = relationship(security_manager.user_model, secondary=dashboard_user) - if is_feature_enabled("TAGGING_SYSTEM"): - tags = relationship( - "Tag", - secondary="tagged_object", - primaryjoin="and_(Dashboard.id == TaggedObject.object_id)", - secondaryjoin="and_(TaggedObject.tag_id == Tag.id, " - "TaggedObject.object_type == 'dashboard')", - ) + tags = relationship( + "Tag", + secondary="tagged_object", + primaryjoin="and_(Dashboard.id == TaggedObject.object_id)", + secondaryjoin="and_(TaggedObject.tag_id == Tag.id, " + "TaggedObject.object_type == 'dashboard')", + ) published = Column(Boolean, default=False) is_managed_externally = Column(Boolean, nullable=False, default=False) external_url = Column(Text, nullable=True) diff --git a/superset/models/slice.py b/superset/models/slice.py index 6bdd1bda6e78d..cc975d26350d5 100644 --- a/superset/models/slice.py +++ b/superset/models/slice.py @@ -96,14 +96,13 @@ class Slice( # pylint: disable=too-many-public-methods security_manager.user_model, foreign_keys=[last_saved_by_fk] ) owners = relationship(security_manager.user_model, secondary=slice_user) - if is_feature_enabled("TAGGING_SYSTEM"): - tags = relationship( - "Tag", - secondary="tagged_object", - primaryjoin="and_(Slice.id == TaggedObject.object_id)", - secondaryjoin="and_(TaggedObject.tag_id == Tag.id, " - "TaggedObject.object_type == 'chart')", - ) + tags = relationship( + "Tag", + secondary="tagged_object", + primaryjoin="and_(Slice.id == TaggedObject.object_id)", + secondaryjoin="and_(TaggedObject.tag_id == Tag.id, " + "TaggedObject.object_type == 'chart')", + ) table = relationship( "SqlaTable", foreign_keys=[datasource_id], diff --git a/superset/models/sql_lab.py b/superset/models/sql_lab.py index f12c8d6c45521..3b5f171f41b7f 100644 --- a/superset/models/sql_lab.py +++ b/superset/models/sql_lab.py @@ -42,7 +42,7 @@ from sqlalchemy.engine.url import URL from sqlalchemy.orm import backref, relationship -from superset import is_feature_enabled, security_manager +from superset import security_manager from superset.jinja_context import BaseTemplateProcessor, get_template_processor from superset.models.helpers import ( AuditMixinNullable, @@ -366,14 +366,13 @@ class SavedQuery(Model, AuditMixinNullable, ExtraJSONMixin, ImportExportMixin): ) rows = Column(Integer, nullable=True) last_run = Column(DateTime, nullable=True) - if is_feature_enabled("TAGGING_SYSTEM"): - tags = relationship( - "Tag", - secondary="tagged_object", - primaryjoin="and_(SavedQuery.id == TaggedObject.object_id)", - secondaryjoin="and_(TaggedObject.tag_id == Tag.id, " - "TaggedObject.object_type == 'saved_query')", - ) + tags = relationship( + "Tag", + secondary="tagged_object", + primaryjoin="and_(SavedQuery.id == TaggedObject.object_id)", + secondaryjoin="and_(TaggedObject.tag_id == Tag.id, " + "TaggedObject.object_type == 'saved_query')", + ) export_parent = "database" export_fields = [ diff --git a/tests/integration_tests/charts/api_tests.py b/tests/integration_tests/charts/api_tests.py index 62da324d56389..5a261fb5520c5 100644 --- a/tests/integration_tests/charts/api_tests.py +++ b/tests/integration_tests/charts/api_tests.py @@ -830,6 +830,7 @@ def test_get_chart(self): ], "params": None, "slice_name": "title", + "tags": [], "viz_type": None, "query_context": None, "is_managed_externally": False, diff --git a/tests/integration_tests/dashboards/api_tests.py b/tests/integration_tests/dashboards/api_tests.py index 6abc649b9a967..29be38bc1b5b8 100644 --- a/tests/integration_tests/dashboards/api_tests.py +++ b/tests/integration_tests/dashboards/api_tests.py @@ -434,6 +434,7 @@ def test_get_dashboard(self): "published": False, "url": "/superset/dashboard/slug1/", "slug": "slug1", + "tags": [], "thumbnail_url": dashboard.thumbnail_url, "is_managed_externally": False, } diff --git a/tests/integration_tests/tags/dao_tests.py b/tests/integration_tests/tags/dao_tests.py index 0234b2c8c2dfd..f46abaa723bda 100644 --- a/tests/integration_tests/tags/dao_tests.py +++ b/tests/integration_tests/tags/dao_tests.py @@ -88,7 +88,6 @@ def create_tags(self): ) ) yield tags - db.session.commit() @pytest.fixture() def create_tagged_objects(self): @@ -121,8 +120,8 @@ def create_tagged_objects(self): tag_id=tag.id, ) ) + yield tagged_objects - db.session.commit() @pytest.mark.usefixtures("load_world_bank_dashboard_with_slices") @pytest.mark.usefixtures("with_tagging_system_feature") @@ -297,3 +296,5 @@ def test_delete_tagged_object(self): def test_validate_tag_name(self): assert TagDAO.validate_tag_name("example_tag_name") is True assert TagDAO.validate_tag_name("invalid:tag_name") is False + db.session.query(TaggedObject).delete() + db.session.query(Tag).delete() diff --git a/tests/integration_tests/tasks/async_queries_tests.py b/tests/integration_tests/tasks/async_queries_tests.py index 20d0f39eea0f4..9e5c9657cf936 100644 --- a/tests/integration_tests/tasks/async_queries_tests.py +++ b/tests/integration_tests/tasks/async_queries_tests.py @@ -38,6 +38,7 @@ load_birth_names_data, ) from tests.integration_tests.fixtures.query_context import get_query_context +from tests.integration_tests.fixtures.tags import with_tagging_system_feature from tests.integration_tests.test_app import app