Re: [Django] #29998: pk setup for MTI to parent get confused by multiple OneToOne references.

2020-01-15 Thread Django
#29998: pk setup for MTI to parent get confused by multiple OneToOne references.
-+-
 Reporter:  Mārtiņš Šulcs|Owner:  felixxm
 Type:  Bug  |   Status:  closed
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:  fixed
 Keywords:   | Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by GitHub ):

 * status:  assigned => closed
 * resolution:   => fixed


Comment:

 In [changeset:"bf77669453b9e9f64291da6701fe06fd5ba47e29" bf776694]:
 {{{
 #!CommitTicketReference repository=""
 revision="bf77669453b9e9f64291da6701fe06fd5ba47e29"
 Fixed #29998 -- Allowed multiple OneToOneFields to the parent model.

 We assumed that any OneToOneField's in a child model must be the
 parent link and raised an error when parent_link=True was not
 specified. This patch allows to specify multiple OneToOneField's to
 the parent model.

 OneToOneField's without a custom related_name will raise fields.E304
 and fields.E305 so this should warn users when they try to override
 the auto-created OneToOneField.
 }}}

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.cee356b3dbc37b26d238230f8baefb73%40djangoproject.com.


Re: [Django] #29998: pk setup for MTI to parent get confused by multiple OneToOne references.

2020-01-15 Thread Django
#29998: pk setup for MTI to parent get confused by multiple OneToOne references.
-+-
 Reporter:  Mārtiņš Šulcs|Owner:  felixxm
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Carlton Gibson):

 * stage:  Accepted => Ready for checkin


-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.cf1b137db304c04d3c6fdea96802b6eb%40djangoproject.com.


Re: [Django] #29998: pk setup for MTI to parent get confused by multiple OneToOne references.

2020-01-15 Thread Django
#29998: pk setup for MTI to parent get confused by multiple OneToOne references.
-+-
 Reporter:  Mārtiņš Šulcs|Owner:  felixxm
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Mariusz Felisiak ):

 In [changeset:"8712027b226f1400ea31f9c0500fbfe359dd9d07" 8712027]:
 {{{
 #!CommitTicketReference repository=""
 revision="8712027b226f1400ea31f9c0500fbfe359dd9d07"
 [3.0.x] Refs #29998 -- Corrected auto-created OneToOneField parent_link in
 MTI docs.

 Backport of d202846ced2f58d7a34ad80bfe2bde8a542a70b9 from master
 }}}

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.add587a35c98c1d1f4026f823a5c4640%40djangoproject.com.


Re: [Django] #29998: pk setup for MTI to parent get confused by multiple OneToOne references.

2020-01-15 Thread Django
#29998: pk setup for MTI to parent get confused by multiple OneToOne references.
-+-
 Reporter:  Mārtiņš Šulcs|Owner:  felixxm
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by GitHub ):

 In [changeset:"d202846ced2f58d7a34ad80bfe2bde8a542a70b9" d202846c]:
 {{{
 #!CommitTicketReference repository=""
 revision="d202846ced2f58d7a34ad80bfe2bde8a542a70b9"
 Refs #29998 -- Corrected auto-created OneToOneField parent_link in MTI
 docs.
 }}}

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.50d8dfe6c372eb59cf66018f42720bf5%40djangoproject.com.


Re: [Django] #29998: pk setup for MTI to parent get confused by multiple OneToOne references.

2020-01-15 Thread Django
#29998: pk setup for MTI to parent get confused by multiple OneToOne references.
-+-
 Reporter:  Mārtiņš Šulcs|Owner:  felixxm
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by felixxm):

 * owner:  Can Sarıgöl => felixxm
 * version:  2.1 => master


Comment:

 [https://github.com/django/django/pull/12325 PR]

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.045c568aaf0637c8374b8db21ce78af5%40djangoproject.com.


Re: [Django] #29998: pk setup for MTI to parent get confused by multiple OneToOne references.

2019-10-17 Thread Django
#29998: pk setup for MTI to parent get confused by multiple OneToOne references.
-+-
 Reporter:  Mārtiņš Šulcs|Owner:  Can
 |  Sarıgöl
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  2.1
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by brianmaissy):

 What's the status on this? I'm encountering the same issue.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.66c0ef37365ab5dafc102e4ba67cc3ff%40djangoproject.com.


Re: [Django] #29998: pk setup for MTI to parent get confused by multiple OneToOne references.

2019-06-25 Thread Django
#29998: pk setup for MTI to parent get confused by multiple OneToOne references.
-+-
 Reporter:  Mārtiņš Šulcs|Owner:  Can
 |  Sarıgöl
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  2.1
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Can Sarıgöl):

 * owner:  nobody => Can Sarıgöl
 * status:  new => assigned
 * has_patch:  0 => 1


-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.2cd26e35e1a45d8d6e203d01f9c43fea%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #29998: pk setup for MTI to parent get confused by multiple OneToOne references.

2019-05-21 Thread Django
#29998: pk setup for MTI to parent get confused by multiple OneToOne references.
-+-
 Reporter:  Mārtiņš Šulcs|Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  2.1
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Can Sarıgöl):

 * cc: Can Sarıgöl (added)


Comment:

 Hi, Could this approach be appropriate? {{{parent_links}}}'s params can be
 base and related class instance therefore just last sample columns are
 added into parent_links.
 We can extend key logic with related_name, e.g ('app', 'document',
 'picking').
 Or using this method, we can always ensure that the {{{parent_link=True}}}
 field is guaranteed into {{{self.parents}}}.


 {{{
 +++ b/django/db/models/base.py
 @@ -196,10 +196,11 @@ class ModelBase(type):
  if base != new_class and not base._meta.abstract:
  continue
  # Locate OneToOneField instances.
 -for field in base._meta.local_fields:
 -if isinstance(field, OneToOneField):
 -related = resolve_relation(new_class,
 field.remote_field.model)
 -parent_links[make_model_tuple(related)] = field
 +fields = [field for field in base._meta.local_fields if
 isinstance(field, OneToOneField)]
 +for field in sorted(fields, key=lambda x:
 x.remote_field.parent_link, reverse=True):
 +related_key =
 make_model_tuple(resolve_relation(new_class, field.remote_field.model))
 +if related_key not in parent_links:
 +parent_links[related_key] = field

  # Track fields inherited from base models.
  inherited_attributes = set()
 }}}

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.47b8edf7ef3a0f4b8c3f95fc6db9df20%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #29998: pk setup for MTI to parent get confused by multiple OneToOne references.

2019-03-05 Thread Django
#29998: pk setup for MTI to parent get confused by multiple OneToOne references.
-+-
 Reporter:  Mārtiņš Šulcs|Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  2.1
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Ben Beecher):

 Been able to replicate this bug with a simpler case:

 {{{
 class Document(models.Model):
 pass

 class Picking(Document):
 some_unrelated_document = models.OneToOneField(Document,
 related_name='something', on_delete=models.PROTECT)
 }}}

 Produces the same error against some_unrelated_document.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.f80d87e42c96d75a01bd0ff2a90703fa%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #29998: pk setup for MTI to parent get confused by multiple OneToOne references.

2018-11-30 Thread Django
#29998: pk setup for MTI to parent get confused by multiple OneToOne references.
-+-
 Reporter:  Mārtiņš Šulcs|Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  2.1
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Mārtiņš Šulcs):

 Replying to [comment:2 Mārtiņš Šulcs]:
 > Replying to [comment:1 Simon Charette]:
 >
 > It does go away primary_key.
 > Why is parent_link even necessary in that case? Having pk OneToOne with
 to MTI child should imply it's parent link.
 I have an update. The warning goes away with primary_key, but model itself
 is still broken(complains about document_ptr_id not populated) unless
 field order is correct.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.9bcb30dd35a4023b7f3f2cb01bd4e62d%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #29998: pk setup for MTI to parent get confused by multiple OneToOne references.

2018-11-29 Thread Django
#29998: pk setup for MTI to parent get confused by multiple OneToOne references.
-+-
 Reporter:  Mārtiņš Šulcs|Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  2.1
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Mārtiņš Šulcs):

 Replying to [comment:1 Simon Charette]:

 It does go away primary_key.
 Why is parent_link even necessary in that case? Having pk OneToOne with to
 MTI child should imply it's parent link.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.7328a62c77bc3722529841f07b520a9f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #29998: pk setup for MTI to parent get confused by multiple OneToOne references.

2018-11-29 Thread Django
#29998: pk setup for MTI to parent get confused by multiple OneToOne references.
-+-
 Reporter:  Mārtiņš Šulcs|Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  2.1
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Simon Charette):

 * stage:  Unreviewed => Accepted


Comment:

 That seems to be a bug, managed to reproduce.

 Does the error go away if you add `primary_key=True` to `document_ptr`
 like I assume you wanted to do? This makes me realized that the
 [https://docs.djangoproject.com/en/2.1/topics/db/models/#multi-table-
 inheritance MTI documentation] is not completely correcy,
 
[https://github.com/django/django/blob/7d1123e5ada60963ba3c708a8932e57342278706/django/db/models/options.py#L225-L244
 the automatically added `place_ptr` field end up with `primary_key=True`].

 Not sure why we're not checking `and field.remote_field.parent_link` on
 
[https://github.com/django/django/blob/7d1123e5ada60963ba3c708a8932e57342278706/django/db/models/base.py#L183
 parent links connection].

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.196991a5d39e721b4f10c8eddda0eabd%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


[Django] #29998: pk setup for MTI to parent get confused by multiple OneToOne references.

2018-11-29 Thread Django
#29998: pk setup for MTI to parent get confused by multiple OneToOne references.
-+-
   Reporter:  shulcsm|  Owner:  nobody
   Type:  Bug| Status:  new
  Component:  Database   |Version:  2.1
  layer (models, ORM)|
   Severity:  Normal |   Keywords:
   Triage Stage: |  Has patch:  0
  Unreviewed |
Needs documentation:  0  |Needs tests:  0
Patch needs improvement:  0  |  Easy pickings:  0
  UI/UX:  0  |
-+-
 {{{
 class Document(models.Model):
 pass

 class Picking(Document):
 document_ptr = models.OneToOneField(Document,
 on_delete=models.CASCADE, parent_link=True, related_name='+')
 origin = models.OneToOneField(Document, related_name='picking',
 on_delete=models.PROTECT)
 }}}

 produces django.core.exceptions.ImproperlyConfigured: Add parent_link=True
 to appname.Picking.origin.

 {{{
 class Picking(Document):
 origin = models.OneToOneField(Document, related_name='picking',
 on_delete=models.PROTECT)
 document_ptr = models.OneToOneField(Document,
 on_delete=models.CASCADE, parent_link=True, related_name='+')
 }}}
 Works

 First issue is that order seems to matter?
 Even if ordering is required "by design"(It shouldn't be we have explicit
 parent_link marker) shouldn't it look from top to bottom like it does with
 managers and other things?

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/050.ae645d239f76f7242d8da2b03142c60f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.