]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Better error messaging on failed collection bulk-assignments
authorJason Kirtland <jek@discorporate.us>
Sat, 9 Feb 2008 19:15:45 +0000 (19:15 +0000)
committerJason Kirtland <jek@discorporate.us>
Sat, 9 Feb 2008 19:15:45 +0000 (19:15 +0000)
lib/sqlalchemy/orm/collections.py

index 5f701bccc490d124c4c315b1e89a973615d1261d..45f978ba8961626084e1a65d13dcd33799dad2d5 100644 (file)
@@ -507,10 +507,15 @@ class CollectionAdapter(object):
         receiving_type = sautil.duck_type_collection(self._data())
 
         if obj is None or setting_type != receiving_type:
+            given = obj is None and 'None' or obj.__class__.__name__
+            if receiving_type is None:
+                wanted = self._data().__class__.__name__
+            else:
+                wanted = receiving_type.__name__
+
             raise TypeError(
-                "Incompatible collection type: %s is not %s-like" %
-                (type(obj).__class__.__name__,
-                 receiving_type.__class__.__name__))
+                "Incompatible collection type: %s is not %s-like" % (
+                given, wanted))
 
         # If the object is an adapted collection, return the (iterable) adapter.
         if getattr(obj, '_sa_adapter', None) is not None: