Skip to content

Commit

Permalink
Stop logging SHOW FIELDS and SET SQL_AUTO_IS_NULL=0 for the MysqlAdap…
Browse files Browse the repository at this point in the history
…ter as they only clutter up the log and offer no value [DHH]
  • Loading branch information
dhh committed Nov 6, 2008
1 parent 55707da commit 0777732
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions activerecord/CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
*2.2.1 [RC2 or 2.2 final]*

* Stop logging SHOW FIELDS and SET SQL_AUTO_IS_NULL=0 as they only clutter up the log and offer no value [DHH]

* Ensure indices don't flip order in schema.rb #1266 [Jordi Bunster]

* Fixed that serialized strings should never be type-casted (i.e. turning "Yes" to a boolean) #857 [Andreas Korth]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,12 @@ def select_rows(sql, name = nil)
rows
end

def execute(sql, name = nil) #:nodoc:
log(sql, name) { @connection.query(sql) }
def execute(sql, name = nil, skip_logging = false) #:nodoc:
if skip_logging
@connection.query(sql)
else
log(sql, name) { @connection.query(sql) }
end
rescue ActiveRecord::StatementInvalid => exception
if exception.message.split(":").first =~ /Packets out of order/
raise ActiveRecord::StatementInvalid, "'Packets out of order' error was received from the database. Please update your mysql bindings (gem install mysql) and read http://dev.mysql.com/doc/mysql/en/password-hashing.html for more information. If you're on Windows, use the Instant Rails installer to get the updated mysql bindings."
Expand Down Expand Up @@ -437,7 +441,7 @@ def indexes(table_name, name = nil)#:nodoc:
def columns(table_name, name = nil)#:nodoc:
sql = "SHOW FIELDS FROM #{quote_table_name(table_name)}"
columns = []
execute(sql, name).each { |field| columns << MysqlColumn.new(field[0], field[4], field[1], field[2] == "YES") }
execute(sql, name, true).each { |field| columns << MysqlColumn.new(field[0], field[4], field[1], field[2] == "YES") }
columns
end

Expand Down Expand Up @@ -555,7 +559,7 @@ def configure_connection

# By default, MySQL 'where id is null' selects the last inserted id.
# Turn this off. http://dev.rubyonrails.org/ticket/6778
execute("SET SQL_AUTO_IS_NULL=0")
execute("SET SQL_AUTO_IS_NULL=0", "ID NULL OFF", true)
end

def select(sql, name = nil)
Expand Down

0 comments on commit 0777732

Please sign in to comment.