diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2011-03-27 21:06:32 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2011-03-27 21:06:32 -0400 |
| commit | 33691f6837970adfb6043094ab7e4ef63e44aceb (patch) | |
| tree | b6c1fdb6042bfce3431f99fd7b74ff3ef6da638a /lib/sqlalchemy/orm/dependency.py | |
| parent | 6882cb17e9eb56b137fa4c2ac2ba736aa286c35d (diff) | |
| download | sqlalchemy-33691f6837970adfb6043094ab7e4ef63e44aceb.tar.gz | |
- Reworded the exception raised when a flush
is attempted of a subclass that is not polymorphic
against the supertype. [ticket:2063]
Diffstat (limited to 'lib/sqlalchemy/orm/dependency.py')
| -rw-r--r-- | lib/sqlalchemy/orm/dependency.py | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/lib/sqlalchemy/orm/dependency.py b/lib/sqlalchemy/orm/dependency.py index 5dddd02dd..023b3e07e 100644 --- a/lib/sqlalchemy/orm/dependency.py +++ b/lib/sqlalchemy/orm/dependency.py @@ -251,14 +251,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', " |
