mirror of
https://github.com/apache/superset.git
synced 2026-06-07 00:29:17 +00:00
fix(daos/tag): prevent non-unique tags getting created along with unique ones (#32405)
Signed-off-by: hainenber <dotronghai96@gmail.com>
This commit is contained in:
@@ -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 = (
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user