New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

many2one with reverse one2many to polymorphic Model #68

gracinet opened this Issue Oct 25, 2018 · 0 comments


None yet
2 participants
Copy link

gracinet commented Oct 25, 2018

It seems that having a many2one with a reverse one2many towards a base polymorphic Model gives rise to problems upon deletions.

This is all happening in a change I'm trying to do within anyblok_wms_base (for its issue #26, with the m2o being from Avatar to Operation:

class Avatar:
    outcome_of = Many2One(index=True,
                          model=Model.Wms.Operation, nullable=False)

To reproduce, l


ERROR: test_whole_planned_execute_obliviate (anyblok_wms_base.core.operation.tests.test_move.TestMove)
Traceback (most recent call last):
  File "/home/gracinet/anybox/projets/Sensee/anyblok_wms/anyblok_wms_base/anyblok_wms_base/core/operation/tests/", line 80, in test_whole_planned_execute_obliviate
  File "/home/gracinet/anybox/projets/Sensee/anyblok_wms/anyblok_wms_base/anyblok_wms_base/core/operation/", line 559, in obliviate
  File "/home/gracinet/anybox/projets/Sensee/anyblok_wms/anyblok_wms_base/anyblok_wms_base/core/operation/", line 743, in obliviate_single
  File "/home/gracinet/anybox/projets/Sensee/anyblok_wms/anyblok_wms_base/anyblok_wms_base/core/operation/", line 697, in delete_outcomes
  File "/home/gracinet/anybox/projets/Sensee/anyblok_wms/anyblok/anyblok/bloks/anyblok_core/core/", line 577, in delete
  File "/home/gracinet/anybox/projets/Sensee/anyblok_wms/anyblok/anyblok/bloks/anyblok_core/core/", line 531, in expire_relationship_mapped
  File "/home/gracinet/anybox/projets/Sensee/anyblok_wms/anyblok/anyblok/bloks/anyblok_core/core/", line 552, in expire
    self.registry.expire(self, fields)
  File "/home/gracinet/anybox/projets/Sensee/anyblok_wms/anyblok/anyblok/", line 1093, in expire
  File "/home/gracinet/anybox/projets/Sensee/anyblok_wms/anyblok/anyblok/", line 121, in wrapper
    return method(*args, **kwargs)
  File "/home/gracinet/anybox/projets/Sensee/anyblok_wms/anyblok/anyblok/bloks/anyblok_core/core/", line 231, in get_hybrid_property_columns
    fd = cls.fields_description(*pks)
TypeError: fields_description() takes from 1 to 2 positional arguments but 3 were given

I checked with pdb:

-> fd = cls.fields_description(*pks)
(Pdb) l
226  	        inherited model if they come from polymorphisme
227  	        """
228  	        hybrid_property_columns = cls.hybrid_property_columns
229  	        if 'polymorphic_identity' in cls.__mapper_args__:
230  	            pks = cls.get_primary_keys()
231  ->	            fd = cls.fields_description(*pks)
232  	            for pk in pks:
233  	                if fd[pk].get('model'):
234  	                    Model = cls.registry.get(fd[pk]['model'])
235  	                    hybrid_property_columns.extend(
236  	                        Model.get_hybrid_property_columns())
(Pdb) pks
['id', 'id']

and I suspect these are the primary keys for the subclass (Move) as well as the polymorphic parent (Operation). Overall, I imagine theyre'd problems with m2os targetting Models with complex primary keyrs, too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment