#36530: System check for ManyToManyField & Composite Primary Key checks only one
direction
-------------------------------------+-------------------------------------
     Reporter:  Jacob Walls          |                    Owner:  (none)
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  5.2
  (models, ORM)                      |
     Severity:  Release blocker      |               Resolution:
     Keywords:  compositeprimarykey  |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Natalia Bidart):

 * cc: Simon Charette (added)
 * easy:  1 => 0
 * stage:  Unreviewed => Accepted

Comment:

 Thank you Jacob! How about this for a regression test?
 {{{#!python
     def test_many_to_many_from_model_with_composite_primary_key(self):
         class Parent(models.Model):
             name = models.CharField(max_length=20)

         class Child(models.Model):
             pk = models.CompositePrimaryKey("version", "name")
             version = models.IntegerField()
             name = models.CharField(max_length=20)
             parents = models.ManyToManyField(Parent)

         field = Child._meta.get_field("parents")
         self.assertEqual(
             field.check(from_model=Child),
             [
                 Error(
                     "Field has a CompositePrimaryKey and defines a
 relation with model "
                     "'Parent' which is not supported.",
                     obj=field,
                     id="fields.E348",
                 ),
             ],
         )
 }}}
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36530#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/01070198519de0a1-0ab15cdc-c613-4c12-803a-515b0bcf2c62-000000%40eu-central-1.amazonses.com.

Reply via email to