> Or better still, can I do the query without SQL (pure ruby) ?
There sure is. Try this:
a = Person.find_by_name("???")
Andy
On Apr 18, 2007, at 2:33 PM, Crazy wrote:
>
> 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!
>
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---