summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES5
-rw-r--r--lib/sqlalchemy/types.py2
-rw-r--r--test/sql/test_types.py17
3 files changed, 23 insertions, 1 deletions
diff --git a/CHANGES b/CHANGES
index bb2266f0c..f3793cfc3 100644
--- a/CHANGES
+++ b/CHANGES
@@ -124,6 +124,11 @@ CHANGES
on dialect, but only works on Postgresql so far.
Courtesy Manlio Perillo, [ticket:1679]
+ - [bug] Fixed bug whereby TypeDecorator would
+ return a stale value for _type_affinity, when
+ using a TypeDecorator that "switches" types,
+ like the CHAR/UUID type.
+
- postgresql
- [bug] Postgresql dialect memoizes that an ENUM of a
particular name was processed
diff --git a/lib/sqlalchemy/types.py b/lib/sqlalchemy/types.py
index a4714d3d8..79799da8f 100644
--- a/lib/sqlalchemy/types.py
+++ b/lib/sqlalchemy/types.py
@@ -490,7 +490,7 @@ class TypeDecorator(TypeEngine):
tt.impl = typedesc
return tt
- @util.memoized_property
+ @property
def _type_affinity(self):
return self.impl._type_affinity
diff --git a/test/sql/test_types.py b/test/sql/test_types.py
index efad45501..57193a397 100644
--- a/test/sql/test_types.py
+++ b/test/sql/test_types.py
@@ -199,6 +199,23 @@ class TypeAffinityTest(fixtures.TestBase):
]:
eq_(t1._compare_type_affinity(t2), comp, "%s %s" % (t1, t2))
+ def test_decorator_doesnt_cache(self):
+ from sqlalchemy.dialects import postgresql
+
+ class MyType(TypeDecorator):
+ impl = CHAR
+
+ def load_dialect_impl(self, dialect):
+ if dialect.name == 'postgresql':
+ return dialect.type_descriptor(postgresql.UUID())
+ else:
+ return dialect.type_descriptor(CHAR(32))
+
+ t1 = MyType()
+ d = postgresql.dialect()
+ assert t1._type_affinity is String
+ assert t1.dialect_impl(d)._type_affinity is postgresql.UUID
+
class PickleMetadataTest(fixtures.TestBase):
def testmeta(self):
for loads, dumps in picklers():