This project is archived and is in readonly mode.

#6092 ✓duplicate
Abel Muiño

Arel::Visitors::Mysql fail with subclasses of String like ActiveSupport::SafeBuffer

Reported by Abel Muiño | November 30th, 2010 @ 05:57 PM

Found on a real app with the mysql visitor when using some html_escaped text as the search value for a query:
https://gist.github.com/722028

Another related issue for postgresql visitors is https://github.com/ProtectedMethod/restful_acl/issues/issue/9

Example code:

class MyString < String; end
User.find_by_name(MyString.new("amuino"))

This is (a part of) the backtrace:

NoMethodError: undefined method `visit_MyString' for #<Arel::Visitors::MySQL:0x1060804d8>
from /Users/amuino/.rvm/gems/ruby-1.8.7-p302@collecturl/gems/arel-2.0.4/lib/arel/visitors/visitor.rb:15:in `send'
from /Users/amuino/.rvm/gems/ruby-1.8.7-p302@collecturl/gems/arel-2.0.4/lib/arel/visitors/visitor.rb:15:in `visit'
from /Users/amuino/.rvm/gems/ruby-1.8.7-p302@collecturl/gems/arel-2.0.4/lib/arel/visitors/to_sql.rb:235:in `visit_Arel_Nodes_Equality'
from /Users/amuino/.rvm/gems/ruby-1.8.7-p302@collecturl/gems/arel-2.0.4/lib/arel/visitors/visitor.rb:15:in `send'
from /Users/amuino/.rvm/gems/ruby-1.8.7-p302@collecturl/gems/arel-2.0.4/lib/arel/visitors/visitor.rb:15:in `visit'
from /Users/amuino/.rvm/gems/ruby-1.8.7-p302@collecturl/gems/arel-2.0.4/lib/arel/visitors/to_sql.rb:109:in `visit_Arel_Nodes_Grouping'
from /Users/amuino/.rvm/gems/ruby-1.8.7-p302@collecturl/gems/arel-2.0.4/lib/arel/visitors/visitor.rb:15:in `send'
from /Users/amuino/.rvm/gems/ruby-1.8.7-p302@collecturl/gems/arel-2.0.4/lib/arel/visitors/visitor.rb:15:in `visit'
from /Users/amuino/.rvm/gems/ruby-1.8.7-p302@collecturl/gems/arel-2.0.4/lib/arel/visitors/to_sql.rb:89:in `visit_Arel_Nodes_SelectCore'
from /Users/amuino/.rvm/gems/ruby-1.8.7-p302@collecturl/gems/arel-2.0.4/lib/arel/visitors/to_sql.rb:89:in `map'
from /Users/amuino/.rvm/gems/ruby-1.8.7-p302@collecturl/gems/arel-2.0.4/lib/arel/visitors/to_sql.rb:89:in `visit_Arel_Nodes_SelectCore'
from /Users/amuino/.rvm/gems/ruby-1.8.7-p302@collecturl/gems/arel-2.0.4/lib/arel/visitors/mysql.rb:15:in `visit_Arel_Nodes_SelectCore'
from /Users/amuino/.rvm/gems/ruby-1.8.7-p302@collecturl/gems/arel-2.0.4/lib/arel/visitors/to_sql.rb:77:in `visit_Arel_Nodes_SelectStatement'
from /Users/amuino/.rvm/gems/ruby-1.8.7-p302@collecturl/gems/arel-2.0.4/lib/arel/visitors/to_sql.rb:77:in `map'
from /Users/amuino/.rvm/gems/ruby-1.8.7-p302@collecturl/gems/arel-2.0.4/lib/arel/visitors/to_sql.rb:77:in `visit_Arel_Nodes_SelectStatement'
from /Users/amuino/.rvm/gems/ruby-1.8.7-p302@collecturl/gems/arel-2.0.4/lib/arel/visitors/mysql.rb:10:in `visit_Arel_Nodes_SelectStatement'
from /Users/amuino/.rvm/gems/ruby-1.8.7-p302@collecturl/gems/arel-2.0.4/lib/arel/visitors/visitor.rb:15:in `send'
from /Users/amuino/.rvm/gems/ruby-1.8.7-p302@collecturl/gems/arel-2.0.4/lib/arel/visitors/visitor.rb:15:in `visit'
from /Users/amuino/.rvm/gems/ruby-1.8.7-p302@collecturl/gems/arel-2.0.4/lib/arel/visitors/visitor.rb:5:in `accept'
from /Users/amuino/.rvm/gems/ruby-1.8.7-p302@collecturl/gems/arel-2.0.4/lib/arel/visitors/to_sql.rb:19:in `accept'

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages