]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Determine the basic collection interface dynamically when adapting a collection...
authorJason Kirtland <jek@discorporate.us>
Sat, 9 Feb 2008 18:45:11 +0000 (18:45 +0000)
committerJason Kirtland <jek@discorporate.us>
Sat, 9 Feb 2008 18:45:11 +0000 (18:45 +0000)
lib/sqlalchemy/orm/collections.py

index f2b726b4c4fa206c50c4fae0bcfec3b77bfa34de..5f701bccc490d124c4c315b1e89a973615d1261d 100644 (file)
@@ -504,11 +504,13 @@ class CollectionAdapter(object):
             return converter(obj)
 
         setting_type = sautil.duck_type_collection(obj)
+        receiving_type = sautil.duck_type_collection(self._data())
 
-        if obj is None or setting_type != self.attr.collection_interface:
+        if obj is None or setting_type != receiving_type:
             raise TypeError(
                 "Incompatible collection type: %s is not %s-like" %
-                (type(obj).__name__, self.attr.collection_interface.__name__))
+                (type(obj).__class__.__name__,
+                 receiving_type.__class__.__name__))
 
         # If the object is an adapted collection, return the (iterable) adapter.
         if getattr(obj, '_sa_adapter', None) is not None: