diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2011-11-28 12:44:56 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2011-11-28 12:44:56 -0500 |
commit | beef2b5aa811efd42a111c87a4308d6584c78b97 (patch) | |
tree | 05812d93880a1c7e1fca897cd6be9dfb43b854c3 /test | |
parent | 3e98d31d99c6f6d6f7df20607e43602b356094ab (diff) | |
download | sqlalchemy-beef2b5aa811efd42a111c87a4308d6584c78b97.tar.gz |
- [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.
Diffstat (limited to 'test')
-rw-r--r-- | test/sql/test_types.py | 17 |
1 files changed, 17 insertions, 0 deletions
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(): |