From 6ccfd78fafe2ee5f470f4973febba5d35f4c5707 Mon Sep 17 00:00:00 2001 From: Christian Rijke Date: Fri, 14 Jun 2013 12:16:55 +0200 Subject: [PATCH] Detect MySQL and throw an exception for version 5.6. The reporting engine is currently not compatible with MySQL 5.6 due to a bug in nested queries. see https://www.openproject.org/issues/967 --- lib/reporting_engine/engine.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/reporting_engine/engine.rb b/lib/reporting_engine/engine.rb index 0738606a5f..ab81acd0fb 100644 --- a/lib/reporting_engine/engine.rb +++ b/lib/reporting_engine/engine.rb @@ -10,6 +10,19 @@ module ReportingEngine Rails.application.config.assets.precompile += %w(reporting_engine.css reporting_engine.js) end + initializer 'check mysql version' do + connection = ActiveRecord::Base.connection + adapter_name = connection.adapter_name.to_s.downcase.to_sym + if [:mysql, :mysql2].include?(adapter_name) + mysql_version = connection.show_variable("VERSION") + if mysql_version.start_with?("5.6") + # The reporting engine is not compatible with mysql version 5.6 + # due to a bug in MySQL itself. + # see https://www.openproject.org/issues/967 for details. + raise "MySQL 5.6 is not yet supported." + end + end + end config.to_prepare do require 'reporting_engine/patches'