diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-01-27 02:21:23 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-01-27 02:21:23 +0000 |
| commit | 88f42cf1f4baa9818dfb014ac4e162ce345a4459 (patch) | |
| tree | 00429df0c441c968e0a109ccf784dde0cd08de2c /lib/sqlalchemy | |
| parent | 63d2ce51911058af655c5eee28aa949f829073ef (diff) | |
| download | sqlalchemy-88f42cf1f4baa9818dfb014ac4e162ce345a4459.tar.gz | |
- Fixed bug in polymorphic inheritance where incorrect
exception is raised when base polymorphic_on
column does not correspond to any columns within
the local selectable of an inheriting mapper more
than one level deep
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/orm/mapper.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/sqlalchemy/orm/mapper.py b/lib/sqlalchemy/orm/mapper.py index d9dc70a58..959cf274c 100644 --- a/lib/sqlalchemy/orm/mapper.py +++ b/lib/sqlalchemy/orm/mapper.py @@ -352,9 +352,14 @@ class Mapper(object): if self.polymorphic_identity is not None: self.inherits.polymorphic_map[self.polymorphic_identity] = self if self.polymorphic_on is None: - if self.inherits.polymorphic_on is not None: - self.polymorphic_on = self.mapped_table.corresponding_column(self.inherits.polymorphic_on) + for mapper in self.iterate_to_root(): + # try to set up polymorphic on using correesponding_column(); else leave + # as None + if mapper.polymorphic_on: + self.polymorphic_on = self.mapped_table.corresponding_column(mapper.polymorphic_on) + break else: + # TODO: this exception not covered raise exceptions.ArgumentError("Mapper '%s' specifies a polymorphic_identity of '%s', but no mapper in it's hierarchy specifies the 'polymorphic_on' column argument" % (str(self), self.polymorphic_identity)) if self.polymorphic_identity is not None and not self.concrete: |
