adds trailing +s to the output of EXPLAIN for MySQL

This commit is contained in:
Xavier Noria
2011-11-07 02:01:37 -08:00
parent 1a8df8aa88
commit 17ecdd388c
2 changed files with 8 additions and 9 deletions

View File

@@ -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

View File

@@ -1324,17 +1324,17 @@ User.where(:id => 1).includes(:posts).explain
yields
<plain>
+----+-------------+-------+-------+---------------+---------+---------+-------+------+-------
+----+-------------+-------+-------+---------------+---------+---------+-------+------+-------+
| 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)
</plain>