Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

adds trailing +s to the output of EXPLAIN for MySQL

  • Loading branch information...
commit 17ecdd388c70f7faf002ef21be6a674b4c0df7ca 1 parent 1a8df8a
@fxn fxn authored
View
5 activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
@@ -282,8 +282,8 @@ def compute_column_widths(result)
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 @@ def release_savepoint
# 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
12 railties/guides/source/active_record_querying.textile
@@ -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>
Please sign in to comment.
Something went wrong with that request. Please try again.