]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Reworded the exception raised when a flush
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 28 Mar 2011 01:08:02 +0000 (21:08 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 28 Mar 2011 01:08:02 +0000 (21:08 -0400)
is attempted of a subclass that is not polymorphic
against the supertype.  [ticket:2063]

CHANGES
lib/sqlalchemy/orm/dependency.py

diff --git a/CHANGES b/CHANGES
index f1eee3d7214565be447c479f47bcf113dd697ffc..0ef914d1faf43410e1b72afbbd0817f276fd3b0c 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -45,6 +45,10 @@ CHANGES
     entity.  Note 0.7 has an updated version of this
     fix.  [ticket:2098]
 
+  - Reworded the exception raised when a flush
+    is attempted of a subclass that is not polymorphic
+    against the supertype.  [ticket:2063]
+
 - sql
   - Column.copy(), as used in table.tometadata(), copies the 
     'doc' attribute.  [ticket:2028]
index 26894e37996e330389c67cc2d4593b578c08bba8..80c669c9700cce7e80b67f2919ce1a363d8e02c5 100644 (file)
@@ -243,14 +243,21 @@ class DependencyProcessor(object):
             not self.mapper._canload(state, 
                             allow_subtypes=not self.enable_typechecks):
             if self.mapper._canload(state, allow_subtypes=True):
-                raise exc.FlushError(
-                "Attempting to flush an item of type %s on collection '%s', "
-                "which is not the expected type %s.  Configure mapper '%s' "
-                "to load this subtype polymorphically, or set "
-                "enable_typechecks=False to allow subtypes. "
-                "Mismatched typeloading may cause bi-directional "
-                "relationships (backrefs) to not function properly." % 
-                (state.class_, self.prop, self.mapper.class_, self.mapper))
+                raise exc.FlushError('Attempting to flush an item of type '
+                                '%(x)s as a member of collection '
+                                '"%(y)s". Expected an object of type '
+                                '%(z)s or a polymorphic subclass of '
+                                'this type. If %(x)s is a subclass of '
+                                '%(z)s, configure mapper "%(zm)s" to '
+                                'load this subtype polymorphically, or '
+                                'set enable_typechecks=False to allow '
+                                'any subtype to be accepted for flush. '
+                                 % {
+                    'x': state.class_,
+                    'y': self.prop,
+                    'z': self.mapper.class_,
+                    'zm': self.mapper,
+                    })
             else:
                 raise exc.FlushError(
                 "Attempting to flush an item of type %s on collection '%s', "