Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#25535 closed Bug (fixed)

ForeignObject checks are too strict

Reported by: Antoine Catton Owned by: nobody
Component: Core (System checks) Version: dev
Severity: Normal Keywords: ForeignObject check framework
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Let's consider this test case:

class Parent(models.Model):
  a = models.Field()
  b = models.Field()

  class Meta:
    unique_together = (
      ('a', 'b'),
    )

class Child(models.Model):
  a = models.Field()
  b = models.Field()
  parent = ForeignObject(Parent, from_fields=('a', 'b'), to_fields=('a', 'b'))

I get the error: None of the fields 'a', 'b' on 'Parent' have a unique=True constraint. But a and b are unique together, the ForeignObject will be functional.

Change History (7)

comment:2 by Simon Charette, 9 years ago

Triage Stage: UnreviewedAccepted

comment:3 by Simon Charette, 9 years ago

Triage Stage: AcceptedReady for checkin
Type: New featureBug

I think this is more of a bug than a new feature. The provided patch looks good to me as I'm not convinced this is worth a mention in the release notes.

comment:4 by Anssi Kääriäinen, 9 years ago

ForeignObject and multicolumn foreign keys using it are private API. So, as long as we don't have changes to public API not release notes is OK for me.

comment:5 by Simon Charette <charette.s@…>, 9 years ago

Resolution: fixed
Status: newclosed

In 80dac8c3:

Fixed #25535 -- Made ForeignObject checks less strict.

Check that the foreign object from_fields are a subset of any unique
constraints on the foreign model.

comment:6 by Tim Graham <timograham@…>, 9 years ago

In c7aff313:

Refs #25535 -- Minor edits to ForeignObject check changes.

comment:7 by Tim Graham <timograham@…>, 9 years ago

In 38d6e1e2:

[1.9.x] Fixed #25535 -- Made ForeignObject checks less strict.

Check that the foreign object from_fields are a subset of any unique
constraints on the foreign model.

Backport of 80dac8c33e7f6f22577e4346f44e4c5ee89b648c and
c7aff31397a7228f6ac2e33c10ebdf36c4b7a9b7 from master

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