summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authorJason Kirtland <jek@discorporate.us>2008-02-09 19:15:45 +0000
committerJason Kirtland <jek@discorporate.us>2008-02-09 19:15:45 +0000
commit1ddf4af3552cf28739fb8ca1be7e521767cc034c (patch)
tree28e8b80526adcdb5f27b254753a926e156d6e2a0 /lib/sqlalchemy
parent7313f5c7149ef7a3f911e53a54bd76dec0f0e185 (diff)
downloadsqlalchemy-1ddf4af3552cf28739fb8ca1be7e521767cc034c.tar.gz
- Better error messaging on failed collection bulk-assignments
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/orm/collections.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/sqlalchemy/orm/collections.py b/lib/sqlalchemy/orm/collections.py
index 5f701bccc..45f978ba8 100644
--- a/lib/sqlalchemy/orm/collections.py
+++ b/lib/sqlalchemy/orm/collections.py
@@ -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: