summaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2015-09-30 20:59:47 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2015-09-30 20:59:47 +0000
commit8eb1e94f4d18a8e3d268392aa518b039dbc749c0 (patch)
treebf415c8464852cb83f4b9f61e44b4031172076e3 /app/models
parentf0323575f99bb2db7b4586499a46b0fc44719750 (diff)
downloadredmine-8eb1e94f4d18a8e3d268392aa518b039dbc749c0.tar.gz
redmine-8eb1e94f4d18a8e3d268392aa518b039dbc749c0.zip
SQL error with MySQL (#19657).
git-svn-id: http://svn.redmine.org/redmine/trunk@14633 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models')
-rw-r--r--app/models/enumeration.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/app/models/enumeration.rb b/app/models/enumeration.rb
index 4f5e1e377..2ec96dc1f 100644
--- a/app/models/enumeration.rb
+++ b/app/models/enumeration.rb
@@ -133,9 +133,14 @@ class Enumeration < ActiveRecord::Base
# get the same position as the overriden enumeration
def reset_positions_in_list
super
- self.class.
- where("parent_id IS NOT NULL").
- update_all("position = (SELECT MIN(position) FROM #{self.class.table_name} p WHERE p.id = #{self.class.table_name}.parent_id)")
+ # TODO: no database specific statement
+ if Redmine::Database.mysql?
+ 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")
+ else
+ self.class.
+ where("parent_id IS NOT NULL").
+ update_all("position = (SELECT MIN(position) FROM #{self.class.table_name} p WHERE p.id = #{self.class.table_name}.parent_id)")
+ end
end
private