This repository has been archived by the owner on Sep 12, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue: Fix bug when ordering by duedate with labels
When using el.in(labels.id, labelIds) with odering by duedate, it generates a sql that is using join. like: select distinct t0.id c0, t0.title c1, t0.created_date c2, t0.updated_date c3, t0.author_id c4, t0.author_login_id c5, t0.author_name c6, t0.project_id c7, t0.number c8, t0.num_of_comments c9, t0.state c10, t0.due_date c11, t0.milestone_id c12, t0.assignee_id c13 from issue t0 join issue_issue_label u1z_ on u1z_.issue_id = t0.id join issue_label u1 on u1.id = u1z_.issue_label_id where t0.project_id = 42 and t0.state = 1 and u1.id in (33) order by case when due_date is null then cast('0001-01-01 00:00:00' as timestamp) else due_date end desc limit 16; This query must contains `case when due_date is null then cast('0001-01-01 00:00:00' as timestamp) else due_date end` in the select phrase, because when a @fomula(sql) is used in order by phrase with join, the sql should be in the select phrase too, but ebean doesn't generate query like that. So, I have changed it to not to use join query. like: select t0.id c0, t0.title c1, t0.created_date c2, t0.updated_date c3, t0.author_id c4, t0.author_login_id c5, t0.author_name c6, t0.project_id c7, t0.number c8, t0.num_of_comments c9, t0.state c10, t0.due_date c11, t0.milestone_id c12, t0.assignee_id c13 from issue t0 where t0.project_id = 42 and t0.state = 1 and t0.id in (123, 34, 234, 5345, 346, 34134) order by case when due_date is null then cast('0001-01-01 00:00:00' as timestamp) else due_date end desc limit 16; It will be more slower then now but it works.
- Loading branch information