Code

Opened 3 years ago

Closed 3 years ago

#15225 closed (invalid)

Using concrete model inheritance with OneToOneField(parent_link=True) seems to be ignored

Reported by: jdunck Owned by: nobody
Component: Database layer (models, ORM) Version: 1.2
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description (last modified by jdunck)

This seems to be because local_fields is always blank in these lines from django.db.models.base.ModelBase.new

        # Do the appropriate setup for any model parents.
        o2o_map = dict([(f.rel.to, f) for f in new_class._meta.local_fields
                if isinstance(f, OneToOneField)])

Which causes this elif branch to be taken:

                if base in o2o_map:
                    field = o2o_map[base]
                elif not is_proxy:
                    attr_name = '%s_ptr' % base._meta.module_name
                    field = OneToOneField(base, name=attr_name,
                            auto_created=True, parent_link=True)
                    new_class.add_to_class(attr_name, field)

This misses the point of parent_link.

I'll try to make a simple test case (for some value of "simple"), but can anyone verify? Kooky edge case, I know.

Attachments (0)

Change History (2)

comment:1 Changed 3 years ago by jdunck

  • Description modified (diff)

comment:2 Changed 3 years ago by jdunck

  • Resolution set to invalid
  • Status changed from new to closed

False alarm, I'm just an idiot.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.