Actions
Defect #6468
closedwrong update query in Issue model
Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
2010-09-23
Due date:
% Done:
0%
Estimated time:
Resolution:
Cant reproduce
Affected version:
Description
Redmine 1.0.1.devel (OracleEnhanced)
There was a problem during creating or updating issues. It happened in Issue instance method "update_nested_set_attributes". The update query was formed invalid. Like this:
update issues set root_id = , lgt = 21 ... * blank field
line 651 in Issue.rb:
Issue.update_all("root_id = #{root_id}, lft = #{lft}, rgt = #{rgt}", ["id = ?", id])
line 672-673 in Issue.rb:
Issue.update_all("root_id = #{root_id}, lft = lft + #{offset}, rgt = rgt + #{offset}", ["root_id = ? AND lft >= ? AND rgt <= ? ", old_root_id, lft, rgt])
in Redmine 1.0.1.stable.1536 (OracleEnhanced)
The query is generated in the same wrong way.
Here is my diff to make update query be well formed
svn diff --old=app/models/issue.rb@1537 --new=app/models/issue.rb@1548 Index: app/models/issue.rb =================================================================== --- app/models/issue.rb (revision 1537) +++ app/models/issue.rb (revision 1548) @@ -628,7 +628,7 @@ # issue was just created self.root_id = (@parent_issue.nil? ? id : @parent_issue.root_id) set_default_left_and_right - Issue.update_all("root_id = #{root_id}, lft = #{lft}, rgt = #{rgt}", ["id = ?", id]) + Issue.update_all(["root_id = ?, lft = ?, rgt = ?", root_id, lft, rgt], ["id = ?", id]) if @parent_issue move_to_child_of(@parent_issue) end @@ -649,8 +649,8 @@ self.root_id = (@parent_issue.nil? ? id : @parent_issue.root_id ) target_maxright = nested_set_scope.maximum(right_column_name) || 0 offset = target_maxright + 1 - lft - Issue.update_all("root_id = #{root_id}, lft = lft + #{offset}, rgt = rgt + #{offset}", - ["root_id = ? AND lft >= ? AND rgt <= ? ", old_root_id, lft, rgt]) + Issue.update_all("root_id = ?, lft = lft + #{offset}, rgt = rgt + #{offset}", + ["root_id = ? AND lft >= ? AND rgt <= ? ", root_id, old_root_id, lft, rgt]) self[left_column_name] = lft + offset self[right_column_name] = rgt + offset if @parent_issue
Actions