aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorTakeshi AKIMA <akm2000@gmail.com>2016-07-28 11:19:08 +0900
committerRafael França <rafaelmfranca@gmail.com>2016-07-27 23:19:08 -0300
commitea1dcbbc9965f82361f45d5b098207de738d7bb9 (patch)
tree5fbca7d304dadab90b217880a5b71417083823dd /activerecord
parenta64d9835f11ea7919fae825bceb91e08a1480766 (diff)
downloadrails-ea1dcbbc9965f82361f45d5b098207de738d7bb9.tar.gz
rails-ea1dcbbc9965f82361f45d5b098207de738d7bb9.tar.bz2
rails-ea1dcbbc9965f82361f45d5b098207de738d7bb9.zip
Add the TABLE_SCHEMA condition to the SELECT statement in table_comment (#25945)
[Rafael Mendonça França + Takeshi AKIMA]
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/CHANGELOG.md4
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb3
2 files changed, 6 insertions, 1 deletions
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