- changed milestone to 1.0.xx
schematype support for typedecorator / PG ENUM
Issue #2919
resolved
figure out how users would know to follow this pattern, or how this can be transparent:
import sqlalchemy as sa
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.dialects import postgresql
Base = declarative_base()
class MyEnum(sa.types.TypeDecorator, sa.types.SchemaType):
impl = postgresql.ENUM
def _set_parent(self, column):
self.impl._set_parent(column)
class Test(Base):
__tablename__ = 'test'
id = sa.Column(sa.Integer, primary_key=True)
enum_column = sa.Column(MyEnum('1', '2', '3', name='my_enum_type'))
engine = sa.create_engine('postgresql://scott:tiger@localhost/test', echo=True)
Base.metadata.create_all(engine)
Comments (5)
-
reporter -
reporter - changed milestone to 1.x.xx
- edited description
-
reporter diff --git a/lib/sqlalchemy/sql/type_api.py b/lib/sqlalchemy/sql/type_api.py index b9826e5..9bfd6dc 100644 --- a/lib/sqlalchemy/sql/type_api.py +++ b/lib/sqlalchemy/sql/type_api.py @@ -772,6 +772,11 @@ class TypeDecorator(TypeEngine): """ return self.impl._type_affinity + def _set_parent(self, column): + """Support SchemaType""" + + self.impl._set_parent(column) + def type_engine(self, dialect): """Return a dialect-specific :class:`.TypeEngine` instance for this :class:`.TypeDecorator`.
-
reporter - changed status to resolved
- The :class:
.TypeDecorator
type extender will now work in conjunction with a :class:.SchemaType
implementation, typically :class:.Enum
or :class:.Boolean
with regards to ensuring that the per-table events are propagated from the implementation type to the outer type. These events are used to ensure that the constraints or Postgresql types (e.g. ENUM) are correctly created (and possibly dropped) along with the parent table. fixes#2919
→ <<cset ed535649d423>>
-
reporter → <<cset 37565d2ce2b4>>
- Log in to comment