mirror of
https://github.com/meineerde/redmine.git
synced 2026-02-16 16:42:01 +00:00
SQL error with MySQL (#19657).
git-svn-id: http://svn.redmine.org/redmine/trunk@14633 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
f0323575f9
commit
8eb1e94f4d
@ -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
|
||||
|
||||
@ -44,6 +44,11 @@ module Redmine
|
||||
end
|
||||
end
|
||||
|
||||
# Returns true if the database is MySQL
|
||||
def mysql?
|
||||
(ActiveRecord::Base.connection.adapter_name =~ /mysql/i).present?
|
||||
end
|
||||
|
||||
# Returns a SQL statement for case/accent (if possible) insensitive match
|
||||
def like(left, right, options={})
|
||||
neg = (options[:match] == false ? 'NOT ' : '')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user