@@ -133,9 +133,14 class Enumeration < ActiveRecord::Base | |||||
133 | # get the same position as the overriden enumeration |
|
133 | # get the same position as the overriden enumeration | |
134 | def reset_positions_in_list |
|
134 | def reset_positions_in_list | |
135 | super |
|
135 | super | |
136 | self.class. |
|
136 | # TODO: no database specific statement | |
137 | where("parent_id IS NOT NULL"). |
|
137 | if Redmine::Database.mysql? | |
138 | update_all("position = (SELECT MIN(position) FROM #{self.class.table_name} p WHERE p.id = #{self.class.table_name}.parent_id)") |
|
138 | self.class.connection.execute("UPDATE #{self.class.table_name} c JOIN #{self.class.table_name} p on p.id = c.parent_id SET c.position = p.position") | |
|
139 | else | |||
|
140 | self.class. | |||
|
141 | where("parent_id IS NOT NULL"). | |||
|
142 | update_all("position = (SELECT MIN(position) FROM #{self.class.table_name} p WHERE p.id = #{self.class.table_name}.parent_id)") | |||
|
143 | end | |||
139 | end |
|
144 | end | |
140 |
|
145 | |||
141 | private |
|
146 | private |
@@ -44,6 +44,11 module Redmine | |||||
44 | end |
|
44 | end | |
45 | end |
|
45 | end | |
46 |
|
46 | |||
|
47 | # Returns true if the database is MySQL | |||
|
48 | def mysql? | |||
|
49 | (ActiveRecord::Base.connection.adapter_name =~ /mysql/i).present? | |||
|
50 | end | |||
|
51 | ||||
47 | # Returns a SQL statement for case/accent (if possible) insensitive match |
|
52 | # Returns a SQL statement for case/accent (if possible) insensitive match | |
48 | def like(left, right, options={}) |
|
53 | def like(left, right, options={}) | |
49 | neg = (options[:match] == false ? 'NOT ' : '') |
|
54 | neg = (options[:match] == false ? 'NOT ' : '') |
General Comments 0
You need to be logged in to leave comments.
Login now