Changes between Initial Version and Version 1 of Ticket #25977
- Timestamp:
- Dec 23, 2015, 8:56:27 AM (9 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #25977
- Property Component Uncategorized → Database layer (models, ORM)
- Property Type Bug → New feature
-
Ticket #25977 – Description
initial v1 1 1 This is the query I that appears to be impossible to implement using the ORM: 2 2 {{{ 3 3 SELECT id, name, start_date, 4 4 (SELECT count(state) FROM jobs_job WHERE state = 'F' and job_group_id = jg.id GROUP BY state) as badcount , 5 5 (SELECT count(state) FROM jobs_job WHERE state = 'C' and job_group_id = jg.id GROUP BY state) as goodcount 6 6 FROM jobs_jobgroup as jg 7 8 The main table represents a job group. The two queries tell how many successes and failures there are in the jobs for the job group. Currently, there is no way to have multiple aggregates with different filters on each one. You can't do annotate(fail_count=Count('job__state').filter(state='F'), good_count=Count('job__state').filter(state='C'))or something similar.7 }}} 8 The main table represents a job group. The two queries tell how many successes and failures there are in the jobs for the job group. Currently, there is no way to have multiple aggregates with different filters on each one. You can't do `annotate(fail_count=Count('job__state').filter(state='F'), good_count=Count('job__state').filter(state='C'))` or something similar.