From 1947d4da769e75abb616c1fb29ed7e2232a4e810 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90=E1=BB=97=20Tr=E1=BB=8Dng=20H=E1=BA=A3i?= <41283691+hainenber@users.noreply.github.com> Date: Wed, 13 Aug 2025 03:21:42 +0700 Subject: [PATCH] fix(daos/tag): prevent non-unique tags getting created along with unique ones (#32405) Signed-off-by: hainenber --- superset/daos/tag.py | 3 --- tests/integration_tests/tags/dao_tests.py | 9 +++++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/superset/daos/tag.py b/superset/daos/tag.py index aae3c0dacad..2c5cc358265 100644 --- a/superset/daos/tag.py +++ b/superset/daos/tag.py @@ -54,9 +54,6 @@ class TagDAO(BaseDAO[Tag]): for name in clean_tag_names: type_ = TagType.custom tag = TagDAO.get_by_name(name, type_) - tagged_objects.append( - TaggedObject(object_id=object_id, object_type=object_type, tag=tag) - ) # Check if the association already exists existing_tagged_object = ( diff --git a/tests/integration_tests/tags/dao_tests.py b/tests/integration_tests/tags/dao_tests.py index 0bc866da035..6273799a379 100644 --- a/tests/integration_tests/tags/dao_tests.py +++ b/tests/integration_tests/tags/dao_tests.py @@ -144,6 +144,15 @@ class TestTagsDAO(SupersetTestCase): # check if tag exists assert db.session.query(Tag).filter(Tag.name == "example tag 1").first() + # test that a combination of non-unique and unique tags + # can be added. + TagDAO.create_custom_tagged_objects( + object_type=ObjectType.dashboard.name, + object_id=1, + tag_names=["example tag 1", "example tag 2"], + ) + assert db.session.query(Tag).filter(Tag.name == "example tag 2").first() + @pytest.mark.usefixtures("load_world_bank_dashboard_with_slices") @pytest.mark.usefixtures("with_tagging_system_feature") @pytest.mark.usefixtures("create_tags")