Re: [Django] #30633: Group by concat(field1, field2) producing wrong result. (was: Group by concat(field1, field2) producing wrong result)

2019-07-11 Thread Django
#30633: Group by concat(field1,field2) producing wrong result.
-+-
 Reporter:  bishwadeep   |Owner:  nobody
 Type:  Uncategorized|   Status:  closed
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:  invalid
 Keywords:  mysql group by   | Triage Stage:
 |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by felixxm):

 * status:  new => closed
 * component:  Uncategorized => Database layer (models, ORM)
 * version:  2.2 => master
 * resolution:   => invalid


Comment:

 I'm not sure what exactly you want to achieve because your expected query
 and Django queryset are slightly different, but my understanding is that
 `values()` is missing:
 {{{
 query.annotate(person=Concat('field1',
 'field2')).values('person').annotate(Count('person', distinct=True))
 }}}

 Moreover this is a support question not a bug in Django, please use one of
 [https://code.djangoproject.com/wiki/TicketClosingReasons/UseSupportChannels
 support channels].

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


[Django] #30633: Group by concat(field1, field2) producing wrong result

2019-07-11 Thread Django
#30633: Group by concat(field1,field2) producing wrong result
-+
   Reporter:  bishwadeep |  Owner:  nobody
   Type:  Uncategorized  | Status:  new
  Component:  Uncategorized  |Version:  2.2
   Severity:  Normal |   Keywords:  mysql group by
   Triage Stage:  Unreviewed |  Has patch:  0
Needs documentation:  0  |Needs tests:  0
Patch needs improvement:  0  |  Easy pickings:  0
  UI/UX:  0  |
-+
 I am new to Django and I am enjoying it. I ran into an issue while
 creating a SQL query for my project. I want the following query to run
 using Django
 Query:
 Select id,field1,field2,field3 FROM table WHERE field1 = somevalue
 Group by concat(field1,field2) ORDER BY somefield

 However I am not able to get the desired query. It keeps on adding group
 by id which is not what I want.
 Django query:
 result = query.annotate(person=Concat(F('field1'),
 F('field2'))).annotate(Count('person', distinct=True))
 Outputs:
 SELECT id FROM table WHERE my condition GROUP BY id ORDER BY field

 Please let me know if you have any questions.

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