Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#20946 closed Cleanup/optimization (fixed)

Clean up related field foreign value fetching implementation

Reported by: Anssi Kääriäinen Owned by: nobody
Component: Database layer (models, ORM) Version: 1.5
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

There are currently two ways to fetch the foreign key value from the instance in fields/related.py. The other is get_foreign_related_value() and the other is ._get_fk_val(). The latter only works for single column foreign values. Also, these methods do slightly different things. So, getting rid of ._get_fk_val() seems like a good idea to me.

Change History (4)

comment:1 by Anssi Kääriäinen <akaariai@…>, 11 years ago

Resolution: fixed
Status: newclosed

In b065aeb17f9daf395e22d4d5f9f49c0e2c7f4522:

Fixed #20946 -- model inheritance + m2m failure

Cleaned up the internal implementation of m2m fields by removing
related.py _get_fk_val(). The _get_fk_val() was doing the wrong thing
if asked for the foreign key value on foreign key to parent model's
primary key when child model had different primary key field.

comment:2 by Andrew Godwin <andrew@…>, 11 years ago

In 244e2b71f512605f3d0a8e1ba4c9d6b538acf69d:

Fixed #20946 -- model inheritance + m2m failure

Cleaned up the internal implementation of m2m fields by removing
related.py _get_fk_val(). The _get_fk_val() was doing the wrong thing
if asked for the foreign key value on foreign key to parent model's
primary key when child model had different primary key field.

comment:3 by Ramiro Morales <cramm0@…>, 11 years ago

In 862e1ff2340a1e28a3e7c6904d2b0283085f34c8:

Fixed #22421 -- Regression in fixtures loading.

Loading fixtures were failing since the refactoring in 244e2b71f5 for
inheritance setups where the chain contains abstract models and the
root ancestor contains a M2M relation.

Thanks Stanislas Guerra for the report.

Refs #20946.

comment:4 by Tim Graham <timograham@…>, 11 years ago

In fb45e666c204d7188c38469ca1f661a9b113b85b:

[1.7.x] Fixed #22421 -- Regression in fixtures loading.

Loading fixtures were failing since the refactoring in 244e2b71f5 for
inheritance setups where the chain contains abstract models and the
root ancestor contains a M2M relation.

Thanks Stanislas Guerra for the report.

Refs #20946.

Backport of 862e1ff234 from master

Note: See TracTickets for help on using tickets.
Back to Top