How to escape ? in queries

Hi,

  I have a simple table with id and name fields and which has some data which includes ? and '' characters. If I try to find the rows which have these elements, the query fails with the following error:

irb(main):013:0* a = Person.find(:all, :conditions => ["name = ???"]) ActiveRecord::PreparedStatementInvalid: wrong number of bind variables (0 for 3) in: name = ???         from /activerecord-1.15.2/lib/active_record/base.rb:1463:in `raise_if_bind_arity_mismatch'         from /activerecord-1.15.2/lib/active_record/base.rb:1426:in `replace_bind_variables'         from /activerecord-1.15.2/lib/active_record/base.rb:1417:in `sanitize_sql_array'         from /activerecord-1.15.2/lib/active_record/base.rb:1388:in `sanitize_sql'         from /activerecord-1.15.2/lib/active_record/base.rb:1164:in `add_conditions!'         from /activerecord-1.15.2/lib/active_record/base.rb:1097:in `construct_finder_sql'         from /activerecord-1.15.2/lib/active_record/base.rb:997:in `find_every'         from /activerecord-1.15.2/lib/active_record/base.rb:418:in `find'         from (irb):13         from /usr/lib/site_ruby/1.8/rubygems.rb:78

So my question is: is there any way to escape the query ? Or better still, can I do the query without SQL (pure ruby) ?

Thanks!

Or better still, can I do the query without SQL (pure ruby) ?

There sure is. Try this:

a = Person.find_by_name("???")

Andy