From 17ecdd388c70f7faf002ef21be6a674b4c0df7ca Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Mon, 7 Nov 2011 02:01:37 -0800 Subject: adds trailing +s to the output of EXPLAIN for MySQL --- .../connection_adapters/abstract_mysql_adapter.rb | 5 ++--- railties/guides/source/active_record_querying.textile | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) 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 1146323147..baf4c043c4 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb @@ -282,8 +282,8 @@ module ActiveRecord end def build_separator(widths) - # Each cell has one char of padding at both sides, that's why we add 2. - '+' + widths.map {|w| '-' * (w + 2)}.join('+') + padding = 1 + '+' + widths.map {|w| '-' * (w + (padding*2))}.join('+') + '+' end def build_cells(items, widths) @@ -364,7 +364,6 @@ module ActiveRecord # these, we must use a subquery. However, MySQL is too stupid to create a # temporary table for this automatically, so we have to give it some prompting # in the form of a subsubquery. Ugh! - def join_to_update(update, select) #:nodoc: if select.limit || select.offset || select.orders.any? subsubselect = select.clone diff --git a/railties/guides/source/active_record_querying.textile b/railties/guides/source/active_record_querying.textile index a132d85ef9..ad623ae434 100644 --- a/railties/guides/source/active_record_querying.textile +++ b/railties/guides/source/active_record_querying.textile @@ -1324,17 +1324,17 @@ User.where(:id => 1).includes(:posts).explain yields -+----+-------------+-------+-------+---------------+---------+---------+-------+------+------- ++----+-------------+-------+-------+---------------+---------+---------+-------+------+-------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | -+----+-------------+-------+-------+---------------+---------+---------+-------+------+------- ++----+-------------+-------+-------+---------------+---------+---------+-------+------+-------+ | 1 | SIMPLE | users | const | PRIMARY | PRIMARY | 4 | const | 1 | | -+----+-------------+-------+-------+---------------+---------+---------+-------+------+------- ++----+-------------+-------+-------+---------------+---------+---------+-------+------+-------+ 1 row in set (0.00 sec) -+----+-------------+-------+------+---------------+------+---------+------+------+------------- ++----+-------------+-------+------+---------------+------+---------+------+------+-------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | -+----+-------------+-------+------+---------------+------+---------+------+------+------------- ++----+-------------+-------+------+---------------+------+---------+------+------+-------------+ | 1 | SIMPLE | posts | ALL | NULL | NULL | NULL | NULL | 1 | Using where | -+----+-------------+-------+------+---------------+------+---------+------+------+------------- ++----+-------------+-------+------+---------------+------+---------+------+------+-------------+ 1 row in set (0.00 sec) -- cgit v1.2.3