using polymorphic_on with boolean columns 0.5.4p2

Issue #1440 resolved
Former user created an issue

Currently polymorphic_identity doesn't work properly with boolean columns.

As far as I can tell Mapper:init() when checks to see if the polymorphic_identity keyword is not None it does a: "if polymorphic_on:" when it probably should be doing "if polymorphic_on is not None:"

Attached is a patch.

example: asset_mapper = mapper(Asset, asset_table, polymorphic_on=asset_table.c.is_file, polymorphic_identity=False, save_on_init=False) mapper(AssetVersion, inherits=asset_mapper, polymorphic_identity=True, save_on_init=False)

upon querying for an asset instance I get a traceback: /usr/lib/pymodules/python2.5/sqlalchemy/orm/mapper.pyc in configure_subclass_mapper(discriminator) 1740 mapper = self.polymorphic_mapdiscriminator 1741 except KeyError: -> 1742 raise AssertionError("No such polymorphic_identity %r is defined" % discriminator) 1743 if mapper is self: 1744 return None

AssertionError: No such polymorphic_identity False is defined

Comments (5)

  1. Log in to comment