From ea1dcbbc9965f82361f45d5b098207de738d7bb9 Mon Sep 17 00:00:00 2001 From: Takeshi AKIMA Date: Thu, 28 Jul 2016 11:19:08 +0900 Subject: [PATCH] Add the TABLE_SCHEMA condition to the SELECT statement in table_comment (#25945) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [Rafael Mendonça França + Takeshi AKIMA] --- activerecord/CHANGELOG.md | 4 ++++ .../connection_adapters/abstract_mysql_adapter.rb | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index d3e1cf68a2..14a6c3c9f7 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,3 +1,7 @@ +* Fix the SELECT statement in `#table_comment` for MySQL. + + *Takeshi Akima* + * Virtual attributes will no longer raise when read on models loaded from the database diff --git a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb index 25e3939b62..01395d8ceb 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb @@ -413,7 +413,8 @@ module ActiveRecord select_value(<<-SQL.strip_heredoc, 'SCHEMA') SELECT table_comment FROM information_schema.tables - WHERE table_name=#{quote(table_name)} + WHERE table_schema=#{quote(current_database)} + AND table_name=#{quote(table_name)} SQL end