Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Activerecordtosdb_subrecord_array self.sanitize_sql function not working with rails 3 #20

Open
dpiao opened this issue Jan 12, 2011 · 2 comments

Comments

@dpiao
Copy link

dpiao commented Jan 12, 2011

For example,
class Store < SimpleRecord::Base
has_many :visitors
end
class Visitor < SimpleRecord::Base
belongs_to :store
end

The following call,
Store.first.visitors.find(:all, :conditions => "gender = 'male'")
will generate these error:

ruby-1.9.2-p0 :010 > Store.first.visitors.find(:all,:conditions => "gender = 'M'")
NoMethodError: protected method sanitize_sql' called for ActiveRecord::Base:Class from /home/park/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.1/lib/active_record/base.rb:1016:inmethod_missing'
from /home/park/.rvm/gems/ruby-1.9.2-p0/gems/simple_record-2.0.5/lib/simple_record.rb:1002:in sanitize_sql' from /home/park/.rvm/gems/ruby-1.9.2-p0/gems/simple_record-2.0.5/lib/simple_record.rb:1112:infind'
from (irb):10
from /home/park/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.1/lib/rails/commands/console.rb:44:in start' from /home/park/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.1/lib/rails/commands/console.rb:8:instart'
from /home/park/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.1/lib/rails/commands.rb:23:in <top (required)>' from script/rails:6:inrequire'
from script/rails:6:in `

'

@appoxy
Copy link
Collaborator

appoxy commented Jan 12, 2011

You have ActiveRecord involved in this? Seems that might be the issue.

@bessey
Copy link

bessey commented Aug 13, 2012

I'm having exactly this problem too. Not doing anything ActiveRecordy explicitly. The problem seems to stem from using a string instead of a key/value pair in the :conditions array. eg

:conditions => { :date => Date.today } works fine

:conditions => [ "date >= ?", Date.today ] gives the error protected method 'sanitize_sql' called for ActiveRecord::Base:Class

The class is an extension of SimpleRecord. I'm guessing you were using ActiveRecord's sanitisation stuff and perhaps they made the function protected in a recent version?

Relevant info:
ActiveRecord 3.1.0
SimpleRecord 2.2.0
Rails 3.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants