This is an automated email from the ASF dual-hosted git repository.

sadpandajoe pushed a commit to branch fix-tags-object-type-native-enum
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 4f355af7f2f1a9206b8cc1d147c6c8eff7a71a62
Author: Claude <[email protected]>
AuthorDate: Sat Nov 14 02:20:47 2026 +0000

    fix(tags): store tag enum columns as VARCHAR on Postgres
    
    Saving a tag with two or more objects fails on a PostgreSQL metadata
    database with `type "objecttype" does not exist`, leaving the tag
    without its objects.
    
    Migration 07f9a902af1b converted tag.type and tagged_object.object_type
    to plain VARCHAR and does not guarantee the native objecttype/tagtype
    types exist (it drops `objecttypes`/`tagtypes`, which are not
    SQLAlchemy's native type names). The models still declared native
    ENUMs, so SQLAlchemy 2.0's postgresql insertmanyvalues batch INSERT
    casts bound parameters to those types (`p2::objecttype`) and fails
    when they are absent. Single-row inserts do not render the cast.
    
    Declare both columns with native_enum=False so the model matches the
    VARCHAR columns, as already done for RowLevelSecurityFilter.filter_type.
    Stored values are unchanged (enum member names), no CHECK constraint is
    added, and no migration is required.
    
    Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
---
 superset/tags/models.py | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/superset/tags/models.py b/superset/tags/models.py
index 9a7dd5db412..903d19ca862 100644
--- a/superset/tags/models.py
+++ b/superset/tags/models.py
@@ -90,7 +90,8 @@ class Tag(CoreTag, AuditMixinNullable):
     __tablename__ = "tag"
     id = Column(Integer, primary_key=True)
     name = Column(String(250), unique=True)
-    type = Column(Enum(TagType))
+    # Stored as VARCHAR, not a native enum; see ``TaggedObject.object_type``.
+    type = Column(Enum(TagType, native_enum=False))
     description = Column(Text)
 
     objects = relationship(
@@ -119,7 +120,15 @@ class TaggedObject(Model, AuditMixinNullable):
     # slices FK. The original migration (c82ee8a39623) defined no FK here. See
     # issue #35941.
     object_id = Column(Integer)
-    object_type = Column(Enum(ObjectType))
+    # Migration 07f9a902af1b converted this column (and ``tag.type``) to plain
+    # VARCHAR on Postgres and never guarantees a native ``objecttype`` type
+    # exists. SQLAlchemy 2.0's postgresql "insertmanyvalues" feature casts each
+    # bound parameter to its column type's DDL name (``p2::objecttype``) when
+    # inserting two or more rows at once, which fails if that type is absent.
+    # native_enum=False keeps the column a plain VARCHAR in SQLAlchemy's eyes,
+    # matching the database. Stored values remain the enum member names, and
+    # ``create_constraint`` defaults to False, so no CHECK constraint is added.
+    object_type = Column(Enum(ObjectType, native_enum=False))
 
     tag = relationship(
         "Tag",

Reply via email to