Re: [Django] #32809: Filtering with Q and OR gets duplicated entries

2021-06-03 Thread Django
#32809: Filtering with Q and OR gets duplicated entries
-+-
 Reporter:  Ismael Jerez |Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:  Database layer   |  Version:  3.2
  (models, ORM)  |
 Severity:  Normal   |   Resolution:  needsinfo
 Keywords:  queryset, Q, | Triage Stage:
  filtering, OR, annotation, |   |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Mariusz Felisiak):

 * status:  new => closed
 * resolution:   => needsinfo


Comment:

 Thanks for extra details, however the described behavior is expected,
 [https://code.djangoproject.com/ticket/28292#comment:1 documented], and
 has not been changed in Django 3.2. Django < 3.2 behaves the same.

 Please reopen the ticket if you can debug your issue and provide way to
 reproduce a regression in Django 3.2

-- 
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/072.270ea8ce18f88f43c5a88bb3e00406d3%40djangoproject.com.


Re: [Django] #32809: Filtering with Q and OR gets duplicated entries

2021-06-02 Thread Django
#32809: Filtering with Q and OR gets duplicated entries
-+-
 Reporter:  Ismael Jerez |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  3.2
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  queryset, Q, | Triage Stage:
  filtering, OR, annotation, |   |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Ismael Jerez):

 Forgot to mention that the bug is only happening when the second Q filter
 is used but not with simple '__icontains' filters concatenated by OR
 expressions.

-- 
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/072.f78b35d80996062df21382fda1206e35%40djangoproject.com.


Re: [Django] #32809: Filtering with Q and OR gets duplicated entries

2021-06-02 Thread Django
#32809: Filtering with Q and OR gets duplicated entries
-+-
 Reporter:  Ismael Jerez |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  3.2
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  queryset, Q, | Triage Stage:
  filtering, OR, annotation, |   |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Ismael Jerez):

 * status:  closed => new
 * resolution:  needsinfo =>


Comment:

 Hi again:

 I am sorry for not being able to reproduce this before. Here is a simple
 example:

 1) models.py:
 {{{
 from django.contrib.auth.models import User
 from django.db import models


 class Example(models.Model):
 example_attr = models.CharField(max_length=100)
 users = models.ManyToManyField(User)
 }}}

 2) I created two User's instances from admin site:
 - username = 'admin'
 - username = 'other'

 And two Group's instances from admin site:
 - name = 'Group1'
 - name = 'Group2'

 Associate Group1 and Group2 to users 'admin' and 'other' from admin site
 too.

 3) Now the code:
 {{{
 from example.models import Example
 from django.db.models import Q
 from django.contrib.auth.models import User, Group

 example = Example.objects.create(example_attr='have a nice day')
 user1 = User.objects.get(username='admin')
 user2 = User.objects.get(username='other')
 example.users.add(user1, user2)
 filters = Q(example_attr__icontains='a') |
 
Q(users__in=User.objects.filter(groups__in=[Group.objects.get(name='Group1').pk]))
 print(Example.objects.count()) # This prints "1"
 print(Example.objects.filter(filters).count()) # This prints "2"
 }}}

 Hope this helps to reproduce the bug.

 This bug is happening since Django 3.2.0 until 3.2.4.


 Thanks in advance,
 Ismael.

-- 
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/072.43a29428a39000efe79d75c7e5998635%40djangoproject.com.


Re: [Django] #32809: Filtering with Q and OR gets duplicated entries

2021-06-02 Thread Django
#32809: Filtering with Q and OR gets duplicated entries
-+-
 Reporter:  Ismael Jerez |Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:  Database layer   |  Version:  3.2
  (models, ORM)  |
 Severity:  Normal   |   Resolution:  needsinfo
 Keywords:  queryset, Q, | Triage Stage:
  filtering, OR, annotation, |   |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Mariusz Felisiak):

 * status:  new => closed
 * resolution:   => needsinfo


Comment:

 Thanks for this report, unfortunately we will not be able to reproduce the
 issue or confirm that it's a regression without a queryset. It looks like
 a regression in c8b659430556dca0b2fe27cf2ea0f8290dbafecd but again it's
 hard to confirm without a queryset.

 Can you provide models and filters? Can you confirm that it's a regression
 in 3.2.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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/072.ddd864a4049829ec0dfb6f08b8a8e855%40djangoproject.com.


Re: [Django] #32809: Filtering with Q and OR gets duplicated entries

2021-06-02 Thread Django
#32809: Filtering with Q and OR gets duplicated entries
-+-
 Reporter:  Ismael Jerez |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  3.2
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  queryset, Q, | Triage Stage:
  filtering, OR, annotation, |   |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Ismael Jerez):

 * Attachment "ss2.png" 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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/072.6d6fd8bea23311182344e328a48fcac6%40djangoproject.com.


Re: [Django] #32809: Filtering with Q and OR gets duplicated entries

2021-06-02 Thread Django
#32809: Filtering with Q and OR gets duplicated entries
-+-
 Reporter:  Ismael Jerez |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  3.2
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  queryset, Q, | Triage Stage:
  filtering, OR, annotation, |   |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Ismael Jerez):

 * Attachment "ss1.png" 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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/072.48bb301fae27692a501617bbdbd04ac0%40djangoproject.com.


[Django] #32809: Filtering with Q and OR gets duplicated entries

2021-06-02 Thread Django
#32809: Filtering with Q and OR gets duplicated entries
-+-
   Reporter:  Ismael |  Owner:  nobody
  Jerez  |
   Type:  Bug| Status:  new
  Component:  Database   |Version:  3.2
  layer (models, ORM)|   Keywords:  queryset, Q,
   Severity:  Normal |  filtering, OR, annotation, |
   Triage Stage: |  Has patch:  0
  Unreviewed |
Needs documentation:  0  |Needs tests:  0
Patch needs improvement:  0  |  Easy pickings:  0
  UI/UX:  0  |
-+-
 Hi:

 Django version: 3.2.4
 Python version: 3.8

 I cannot reproduce this bug in a simple example, so I can only show you
 screenshots from my Pycharm Debug Tool, I am sorry.

 I have one queryset with 3 objects which contains annotations, CharField
 and ManyToManyField attributes. Then I filter by a query using Q like
 this:
 {{{
 (OR: ('created_date_dt_custom__icontains', 'a'), ('id__icontains', 'a'),
 ('title__unaccent__icontains', 'a'), ('created_date_dt_custom__icontains',
 'a'), ('id__icontains', 'a'), ('title__unaccent__icontains', 'a'),
 ('promoters__in', , ]>))
 }}}
 And gets a queryset with 4 objects as a result, one of the objects is
 duplicated. If I delete the last filter ('promoters__in', , ]>) it works fine, so the problem is on
 this filter or maybe the concatenation of filters with this kind.

 I have no problem on Django version ~= 2.

 Here are the screenshots of my debug tool showing the problem:
 - Screenshot of the code: https://i.ibb.co/Fnb53rn/ss1.png
 - Screenshot of debug tool with variable values (Project object (19)
 duplicated): https://i.ibb.co/b34FwSM/ss2.png

 Thank you in advance, hope it is fixed soon,
 Ismael.

-- 
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/057.8700912b37820876c310751b26753657%40djangoproject.com.