1. Michael Bayer
  2. sqlalchemy
  3. Issues

Issues

Issue #2892 resolved

with_variant does not work for SchemaType

Michael Bayer
repo owner created an issue
from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.dialects import postgresql

Base = declarative_base()


class A(Base):
    __tablename__ = 'a'
    id = Column(Integer, primary_key=True)
    things = Column(
        Enum(
            "one", "two", "three"
        ).with_variant(
            postgresql.ENUM("one", "two", "three", name="my_enum"),
            "postgresql"
        )
    )

e = create_engine("postgresql://scott:tiger@localhost/test", echo=True)

Base.metadata.drop_all(e)
Base.metadata.create_all(e)

tries to create the main "enum", does not do the right thing for the variant version either

Comments (7)

  1. Michael Bayer reporter

    Allow SchemaType and Variant to work together

    Added support for the :class:.Variant and the :class:.SchemaType objects to be compatible with each other. That is, a variant can be created against a type like :class:.Enum, and the instructions to create constraints and/or database-specific type objects will propagate correctly as per the variant's dialect mapping.

    Also added testing for some potential double-event scenarios on TypeDecorator but it seems usually this doesn't occur.

    Change-Id: I4a7e7c26b4133cd14e870f5bc34a1b2f0f19a14a Fixes: #2892

    → <<cset c04870ba7b80>>

  2. Log in to comment