Re: [Django] #30343: Prefetch related is not working when used GFK for model that uses UUID field as PK.

2019-04-14 Thread Django
#30343: Prefetch related is not working when used GFK for model that uses UUID
field as PK.
-+-
 Reporter:  Timur|Owner:  felixxm
 Type:  Bug  |   Status:  closed
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:  fixed
 Keywords:  prefetch_related,| Triage Stage:  Ready for
  UUID, generic foreign key  |  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:"1afbc96a75bd1765a56054f57ea2d4b238af3f4d" 1afbc96]:
 {{{
 #!CommitTicketReference repository=""
 revision="1afbc96a75bd1765a56054f57ea2d4b238af3f4d"
 Fixed #30343 -- Fixed prefetch_related() for GenericForeignKey when PK of
 related field is UUIDField.
 }}}

-- 
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/072.81cc46a710a4b57d4165efab0fe50206%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #30343: Prefetch related is not working when used GFK for model that uses UUID field as PK.

2019-04-13 Thread Django
#30343: Prefetch related is not working when used GFK for model that uses UUID
field as PK.
-+-
 Reporter:  Timur|Owner:  felixxm
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  prefetch_related,| Triage Stage:  Ready for
  UUID, generic foreign key  |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Simon Charette):

 * 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 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/072.dec85e7428c9cd9c6cffaa226566ad01%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #30343: Prefetch related is not working when used GFK for model that uses UUID field as PK.

2019-04-13 Thread Django
#30343: Prefetch related is not working when used GFK for model that uses UUID
field as PK.
-+-
 Reporter:  Timur|Owner:  felixxm
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  prefetch_related,| Triage Stage:  Accepted
  UUID, generic foreign key  |
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Timur):

 Replying to [comment:6 felixxm]: Thanks for your work!
 > [https://github.com/django/django/pull/11211 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 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/072.f5868301b628a2fc40fcc46eb1b2c7d8%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #30343: Prefetch related is not working when used GFK for model that uses UUID field as PK.

2019-04-13 Thread Django
#30343: Prefetch related is not working when used GFK for model that uses UUID
field as PK.
-+-
 Reporter:  Timur|Owner:  felixxm
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  prefetch_related,| Triage Stage:  Accepted
  UUID, generic foreign key  |
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by felixxm):

 * has_patch:  0 => 1


Comment:

 [https://github.com/django/django/pull/11211 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 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/072.1a65b5c7cec406bda466b0edbbd26ad7%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #30343: Prefetch related is not working when used GFK for model that uses UUID field as PK.

2019-04-13 Thread Django
#30343: Prefetch related is not working when used GFK for model that uses UUID
field as PK.
-+-
 Reporter:  Timur|Owner:  felixxm
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  prefetch_related,| Triage Stage:  Accepted
  UUID, generic foreign key  |
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by felixxm):

 * owner:  nobody => felixxm
 * status:  new => assigned


-- 
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/072.688152d1de784b83b6fd513727b25568%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #30343: Prefetch related is not working when used GFK for model that uses UUID field as PK.

2019-04-09 Thread Django
#30343: Prefetch related is not working when used GFK for model that uses UUID
field as PK.
-+-
 Reporter:  timur-orudzhov   |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  prefetch_related,| Triage Stage:  Accepted
  UUID, generic foreign key  |
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Simon Charette):

 Yeah that seems like the correct approach. I was about to suggest

 {{{#!diff
 diff --git a/django/contrib/contenttypes/fields.py
 b/django/contrib/contenttypes/fields.py
 index ed98ecb48c..6098b71a39 100644
 --- a/django/contrib/contenttypes/fields.py
 +++ b/django/contrib/contenttypes/fields.py
 @@ -202,7 +202,7 @@ class GenericForeignKey(FieldCacheMixin):
  else:
  model = self.get_content_type(id=ct_id,
 using=obj._state.db).model_class()
 -return (model._meta.pk.get_prep_value(getattr(obj,
 self.fk_field)),
 +return (model._meta.pk.to_python(getattr(obj,
 self.fk_field)),
  model)
 }}}

 But it looks like this is really just an issue with `UUIDField`.

-- 
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/072.6df430451e35d0a15da02d8f06e3fc9d%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #30343: Prefetch related is not working when used GFK for model that uses UUID field as PK.

2019-04-09 Thread Django
#30343: Prefetch related is not working when used GFK for model that uses UUID
field as PK.
-+-
 Reporter:  timur-orudzhov   |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  prefetch_related,| Triage Stage:  Accepted
  UUID, generic foreign key  |
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by felixxm):

 IMO, adding `get_prep_value()` to the `UUIDField` should fix this issue
 樂:
 {{{
 diff --git a/django/db/models/fields/__init__.py
 b/django/db/models/fields/__init__.py
 index 2307dcae25..0a7a6b9736 100644
 --- a/django/db/models/fields/__init__.py
 +++ b/django/db/models/fields/__init__.py
 @@ -2335,6 +2335,12 @@ class UUIDField(Field):
  return value
  return value.hex

 +def get_prep_value(self, value):
 +value = super().get_prep_value(value)
 +if value is None:
 +return None
 +return self.to_python(value)
 +
  def to_python(self, value):
  if value is not None and not isinstance(value, uuid.UUID):
  input_form = 'int' if isinstance(value, int) else 'hex'
 }}}

-- 
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/072.346846c5527f9e54b1fbdf499c65374c%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #30343: Prefetch related is not working when used GFK for model that uses UUID field as PK.

2019-04-09 Thread Django
#30343: Prefetch related is not working when used GFK for model that uses UUID
field as PK.
-+-
 Reporter:  timur-orudzhov   |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  prefetch_related,| Triage Stage:  Accepted
  UUID, generic foreign key  |
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by felixxm):

 * Attachment "30343-test.diff" added.


-- 
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/072.3c65d12eee701f68b7e80884c7da99f7%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #30343: Prefetch related is not working when used GFK for model that uses UUID field as PK.

2019-04-09 Thread Django
#30343: Prefetch related is not working when used GFK for model that uses UUID
field as PK.
-+-
 Reporter:  timur-orudzhov   |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  prefetch_related,| Triage Stage:  Accepted
  UUID, generic foreign key  |
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by felixxm):

 * status:  closed => new
 * resolution:  wontfix =>
 * stage:  Unreviewed => Accepted


Comment:

 Sorry for previous comment.

 This should work. Currently it works when `foo_object_id` is an
 `UUIDField` but doesn't work when it is a `CharField`.

-- 
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/072.b5176315c5efb26d8d82f34aa5462686%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.