- attached mapper.diff
using polymorphic_on with boolean columns 0.5.4p2
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)
-
Account Deleted -
repo owner - changed milestone to 0.5.6
-
Account Deleted - attached test_basic.diff
unit test for mapper patch, adds a few more checks to FalseDiscriminatorTest
-
repo owner - changed status to resolved
-
repo owner - removed milestone
Removing milestone: 0.5.6 (automated comment)
- Log in to comment
Mapper:init() explicit checks for polymorphic_identity is not None