From e974bed379e4a224936eaf226840d0d328ff2d72 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Tue, 29 Jul 2014 13:32:05 -0400 Subject: [PATCH] - Fixed 0.9.7 regression caused by :ticket:`3067` in conjunction with a mis-named unit test such that so-called "schema" types like :class:`.Boolean` and :class:`.Enum` could no longer be pickled. fixes #3144 --- doc/build/changelog/changelog_09.rst | 9 +++++++++ lib/sqlalchemy/sql/elements.py | 3 +++ test/sql/test_types.py | 4 ++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/doc/build/changelog/changelog_09.rst b/doc/build/changelog/changelog_09.rst index 9d5614d683..c63ed7fbb0 100644 --- a/doc/build/changelog/changelog_09.rst +++ b/doc/build/changelog/changelog_09.rst @@ -13,6 +13,15 @@ .. changelog:: :version: 0.9.8 + .. change:: + :tags: bug, sql + :versions: 1.0.0 + :tickets: 3144, 3067 + + Fixed 0.9.7 regression caused by :ticket:`3067` in conjunction with + a mis-named unit test such that so-called "schema" types like + :class:`.Boolean` and :class:`.Enum` could no longer be pickled. + .. change:: :tags: bug, postgresql :versions: 1.0.0 diff --git a/lib/sqlalchemy/sql/elements.py b/lib/sqlalchemy/sql/elements.py index 6114460dc3..6cbf583cc4 100644 --- a/lib/sqlalchemy/sql/elements.py +++ b/lib/sqlalchemy/sql/elements.py @@ -3276,6 +3276,9 @@ class _defer_name(_truncated_label): else: return super(_defer_name, cls).__new__(cls, value) + def __reduce__(self): + return self.__class__, (util.text_type(self), ) + class _defer_none_name(_defer_name): """indicate a 'deferred' name that was ultimately the value None.""" diff --git a/test/sql/test_types.py b/test/sql/test_types.py index e2d347928b..20ba9d3ef2 100644 --- a/test/sql/test_types.py +++ b/test/sql/test_types.py @@ -232,9 +232,9 @@ class TypeAffinityTest(fixtures.TestBase): assert t1.dialect_impl(d)._type_affinity is postgresql.UUID -class PickleMetadataTest(fixtures.TestBase): +class PickleTypesTest(fixtures.TestBase): - def testmeta(self): + def test_pickle_types(self): for loads, dumps in picklers(): column_types = [ Column('Boo', Boolean()), -- 2.47.3