]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Rearranged the `load_dialect_impl()` method in
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 13 Nov 2008 20:38:56 +0000 (20:38 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 13 Nov 2008 20:38:56 +0000 (20:38 +0000)
`TypeDecorator` such that it will take effect
even if the user-defined `TypeDecorator` uses
another `TypeDecorator` as its impl.

CHANGES
lib/sqlalchemy/types.py

diff --git a/CHANGES b/CHANGES
index b9d2c1bbef2db49a97bc22de5e9b06d1ec23a4f8..58859fb40231f1d95fb346167f8098418928c62c 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -43,6 +43,11 @@ CHANGES
     
     - Restored "active rowcount" fetch before ResultProxy
       autocloses the cursor.  This was removed in 0.5rc3.
+    
+    - Rearranged the `load_dialect_impl()` method in 
+      `TypeDecorator` such that it will take effect
+      even if the user-defined `TypeDecorator` uses
+      another `TypeDecorator` as its impl.
       
 - access
     - Added support for Currency type.
index fe6cc7b534e7febe9ddca8cba6753cca6468fde3..084ec51172c6e5ed35fa5fcc3ebb3ce1884d854f 100644 (file)
@@ -152,13 +152,11 @@ class TypeDecorator(AbstractType):
         except KeyError:
             pass
 
-        if isinstance(self.impl, TypeDecorator):
-            typedesc = self.impl.dialect_impl(dialect)
-        else:
-            typedesc = self.load_dialect_impl(dialect)
+        typedesc = self.load_dialect_impl(dialect)
         tt = self.copy()
         if not isinstance(tt, self.__class__):
-            raise AssertionError("Type object %s does not properly implement the copy() method, it must return an object of type %s" % (self, self.__class__))
+            raise AssertionError("Type object %s does not properly implement the copy() "
+                    "method, it must return an object of type %s" % (self, self.__class__))
         tt.impl = typedesc
         self._impl_dict[dialect] = tt
         return tt
@@ -170,7 +168,10 @@ class TypeDecorator(AbstractType):
         can be overridden to provide different behavior.
         """
 
-        return dialect.type_descriptor(self.impl)
+        if isinstance(self.impl, TypeDecorator):
+            return self.impl.dialect_impl(dialect)
+        else:
+            return dialect.type_descriptor(self.impl)
 
     def __getattr__(self, key):
         """Proxy all other undefined accessors to the underlying implementation."""