Issue#update_nested_set_attributes comparing nil with empty string
|Assignee:||Jean-Philippe Lang||% Done:|
I had problem with slow issue update. Issue have ~20 subtasks and 1 related issue. Update on that task always ended with timeout error.
It's appears that Issue#update_nested_set_attributes (after_save hook) there is comparision parent_issue_id != parent_id.
In my case parent_issue_id was nil and parent_id empty string, it's leads to unnecessary code execution.
When I change:
elsif parent_issue_id != parent_id
elsif parent_issue_id.to_i != parent_id.to_i
update is now 4 times faster.
#1 Updated by Jean-Philippe Lang over 8 years ago
- Category changed from Issues to Code cleanup/refactoring
- Status changed from New to Closed
- Assignee set to Jean-Philippe Lang
- Target version set to 2.4.0
- Resolution set to Fixed
I fixed the root cause in
parent_issue_id= rather than the comparaison and added a few tests to make sure that this code is called only when needed (r12226), thanks for pointing this out.