« Previous | Next » 

Revision 0f703cba

ID0f703cba6dbf738ef7edbccc8254c2a83170767c

Added by Georgios D. Tsoukalas about 11 years ago

fix user_visible_by_last_of_chain()

ProjectApplication.objects.user_visible_by_last_of_chain()
would erroneously list more than one application per chain.
This was due to this behaviour (bug?) in django:

x = objects.values('chain').annotate(last_id=Min('id'))
values('chain') sets "GROUP BY chain" 
and annotate(...) sets SELECT ..., min(id) as last_id

however, subsequent "values()" calls after x:

x.values_list('id', flat=true)

would append 'id' to the GROUP BY list, ruining the
previous selection.

This was fixed by actually instantiating the query
into a list at the first values() call, which sets the
correct GROUP BY list.

Files

  • added
  • modified
  • copied
  • renamed
  • deleted

View differences