Resend: find problems => patch


#1

I’m fairly sure I sent a message like this last night but it has not
appeared on the list. I didn’t CC myself because I usually see
messages that I post. Anyway, pardon any resulting duplication.

I have just had this, and not that MySQL doesn’t actually display
where the errror is, only the code after it:

You have an error in your SQL syntax; check the manual that corresponds
to your MySQL server version for the right syntax to use near
‘?"00149246 " LIMIT 1’ at line 1
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/connection_adapters/mysql_adapter.rb:119:in
query' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/connection_adapters/mysql_adapter.rb:119:inexecute’
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/connection_adapters/mysql_adapter.rb:230:in
select' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/connection_adapters/mysql_adapter.rb:97:inselect_all’
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/base.rb:376:in
find_by_sql' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/base.rb:343:infind’
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/base.rb:341:in
find' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/deprecated_finders.rb:22:infind_first’

So I’d like to propose a patch of the following form:

— ./mysql_adapter.rb.orig 2005-11-09 19:15:20.575395000 -0800
+++ ./mysql_adapter.rb 2005-11-09 19:26:23.411710000 -0800
@@ -132,7 +132,7 @@
elsif 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 update mysql) and read
http://dev.mysql.com/doc/mysql/en/password-hashing.html for more
information.”
else

  •      raise
    
  •      raise exception.class.new(exception.message + ": SQL was: " + 
    

sql)
end
end

so we can see what the MySQL is when this fails. Is this a good idea,
the
right way to do this, etc?

    Thank you,
    Hugh