#11332: Group by doesn't work properly with PostgreSQL
---------------------------+------------------------------------------------
 Reporter:  Loststylus     |       Owner:  nobody    
   Status:  new            |   Milestone:            
Component:  Uncategorized  |     Version:  1.0       
 Keywords:                 |       Stage:  Unreviewed
Has_patch:  0              |  
---------------------------+------------------------------------------------
 I am trying to execute a query running Django 1.0.2 with PostgreSQL 8.3:

 >>> from accounts import models as m
 >>> from django.contrib.auth.models import User
 >>> me = User.objects.get(pk=1)
 >>> me
 <User: root>
 >>> messages_from_me = m.PersonalMessage.objects.filter(from_id = me,
 hide_from = False).order_by('-time','-pk')
 >>> messages_from_me.query.group_by=['-to_id_id']

 I get the following error:

 Traceback (most recent call last):
   File "<console>", line 1, in <module>
   File "/usr/local/lib/python2.6/dist-packages/django/db/models/query.py",
 line 147, in __repr__
     data = list(self[:REPR_OUTPUT_SIZE + 1])
   File "/usr/local/lib/python2.6/dist-packages/django/db/models/query.py",
 line 162, in __len__
     self._result_cache.extend(list(self._iter))
   File "/usr/local/lib/python2.6/dist-packages/django/db/models/query.py",
 line 275, in iterator
     for row in self.query.results_iter():
   File "/usr/local/lib/python2.6/dist-
 packages/django/db/models/sql/query.py", line 206, in results_iter
     for rows in self.execute_sql(MULTI):
   File "/usr/local/lib/python2.6/dist-
 packages/django/db/models/sql/query.py", line 1734, in execute_sql
     cursor.execute(sql, params)
   File "/usr/local/lib/python2.6/dist-
 packages/django/db/backends/util.py", line 19, in execute
     return self.cursor.execute(sql, params)
 ProgrammingError: колонка "accounts_personalmessage.id" должна
 фигурировать в выражении GROUP BY или использоваться в агрегатной функции

 The last line is in Russian, it says something like column
 "accounts_personalmessage.id" should be in GROUP BY expression or should
 be used in aggregation function.


 The same code works normally for sqlite.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/11332>
Django <http://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 post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to