1
0
mirror of https://github.com/meineerde/redmine.git synced 2026-01-31 11:37:14 +00:00

Use tx_isolation for MySQL lower than 8. (#39437).

git-svn-id: https://svn.redmine.org/redmine/trunk@22464 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Marius Balteanu 2023-11-19 07:10:53 +00:00
parent 0a329dce2f
commit f24631a8bd
3 changed files with 9 additions and 1 deletions

View File

@ -61,6 +61,10 @@ module Redmine
/mysql/i.match?(ActiveRecord::Base.connection.adapter_name)
end
def mysql_version
mysql? ? ActiveRecord::Base.connection.select_value("SELECT VERSION()") : nil
end
# Returns a SQL statement for case/accent (if possible) insensitive match
def like(left, right, options={})
neg = (options[:match] == false ? 'NOT ' : '')

View File

@ -203,6 +203,10 @@ class ActiveSupport::TestCase
Redmine::Database.mysql?
end
def mysql8?
Gem::Version.new(Redmine::Database.mysql_version) >= Gem::Version.new('8.0.0')
end
def postgresql?
Redmine::Database.postgresql?
end

View File

@ -32,7 +32,7 @@ class IssueNestedSetConcurrencyTest < ActiveSupport::TestCase
skip if sqlite?
if mysql?
connection = ActiveRecord::Base.connection_db_config.configuration_hash.deep_dup
connection[:variables] = { transaction_isolation: "READ-COMMITTED" }
connection[:variables] = mysql8? ? { transaction_isolation: "READ-COMMITTED" } : { tx_isolation: "READ-COMMITTED" }
ActiveRecord::Base.establish_connection connection
end
User.current = nil