From: Mike Bayer Date: Mon, 28 Mar 2011 01:06:32 +0000 (-0400) Subject: - Reworded the exception raised when a flush X-Git-Tag: rel_0_7b4~46 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=33691f6837970adfb6043094ab7e4ef63e44aceb;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - Reworded the exception raised when a flush is attempted of a subclass that is not polymorphic against the supertype. [ticket:2063] --- diff --git a/CHANGES b/CHANGES index 5ec0dae420..2562f69fda 100644 --- a/CHANGES +++ b/CHANGES @@ -29,6 +29,11 @@ CHANGES are noted as are if any differences in implementation/behavior are present. +- orm + - Reworded the exception raised when a flush + is attempted of a subclass that is not polymorphic + against the supertype. [ticket:2063] + - sql - Restored the "catchall" constructor on the base TypeEngine class, with a deprecation warning. diff --git a/lib/sqlalchemy/orm/dependency.py b/lib/sqlalchemy/orm/dependency.py index 5dddd02dda..023b3e07e2 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', "