From 30bd28fca2091e4b2b093154a14c668c09ae3ccd Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Thu, 20 Oct 2016 10:24:40 -0400 Subject: Ensure TypeDecorator delegates _set_parent_with_dispatch Ensure TypeDecorator delegates _set_parent_with_dispatch as well as _set_parent to itself as well as its impl, as the TypeDecorator class itself may have an active SchemaType implementation as well. Fixed regression which occurred as a side effect of :ticket:`2919`, which in the less typical case of a user-defined :class:`.TypeDecorator` that was also itself an instance of :class:`.SchemaType` (rather than the implementation being such) would cause the column attachment events to be skipped for the type itself. Change-Id: I0afb498fd91ab7d948e4439e7323a89eafcce0bc Fixes: #3832 --- lib/sqlalchemy/sql/base.py | 2 -- lib/sqlalchemy/sql/type_api.py | 4 ++++ 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/sqlalchemy/sql') diff --git a/lib/sqlalchemy/sql/base.py b/lib/sqlalchemy/sql/base.py index cf7dcfd31..0b036847b 100644 --- a/lib/sqlalchemy/sql/base.py +++ b/lib/sqlalchemy/sql/base.py @@ -426,8 +426,6 @@ class SchemaEventTarget(object): def _set_parent(self, parent): """Associate with this SchemaEvent's parent object.""" - raise NotImplementedError() - def _set_parent_with_dispatch(self, parent): self.dispatch.before_parent_attach(self, parent) self._set_parent(parent) diff --git a/lib/sqlalchemy/sql/type_api.py b/lib/sqlalchemy/sql/type_api.py index 689b4c79b..98ede4e66 100644 --- a/lib/sqlalchemy/sql/type_api.py +++ b/lib/sqlalchemy/sql/type_api.py @@ -860,12 +860,16 @@ class TypeDecorator(SchemaEventTarget, TypeEngine): def _set_parent(self, column): """Support SchemaEentTarget""" + super(TypeDecorator, self)._set_parent(column) + if isinstance(self.impl, SchemaEventTarget): self.impl._set_parent(column) def _set_parent_with_dispatch(self, parent): """Support SchemaEentTarget""" + super(TypeDecorator, self)._set_parent_with_dispatch(parent) + if isinstance(self.impl, SchemaEventTarget): self.impl._set_parent_with_dispatch(parent) -- cgit v1.2.1