diff options
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/core.rb | 4 | ||||
-rw-r--r-- | activerecord/lib/active_record/statement_cache.rb | 10 |
2 files changed, 7 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/core.rb b/activerecord/lib/active_record/core.rb index e4e8fc44d4..4b77e0e01a 100644 --- a/activerecord/lib/active_record/core.rb +++ b/activerecord/lib/active_record/core.rb @@ -139,7 +139,7 @@ module ActiveRecord where(key => params[key]).limit(1) } } - record = s.execute(key => id).first + record = s.execute({key => id}, self, connection).first unless record raise RecordNotFound, "Couldn't find #{name} with '#{primary_key}'=#{id}" end @@ -167,7 +167,7 @@ module ActiveRecord } } begin - s.execute(hash).first + s.execute(hash, self, connection).first rescue TypeError => e raise ActiveRecord::StatementInvalid.new(e.message, e) end diff --git a/activerecord/lib/active_record/statement_cache.rb b/activerecord/lib/active_record/statement_cache.rb index c6341744ca..c70d2f2d11 100644 --- a/activerecord/lib/active_record/statement_cache.rb +++ b/activerecord/lib/active_record/statement_cache.rb @@ -74,19 +74,19 @@ module ActiveRecord end end - attr_reader :bind_map, :query_builder, :klass + attr_reader :bind_map, :query_builder def initialize(block = Proc.new) relation = block.call Params.new @bind_map = BindMap.new relation.bind_values - @klass = relation.klass - @query_builder = make_query_builder @klass.connection, relation.arel + klass = relation.klass + @query_builder = make_query_builder klass.connection, relation.arel end - def execute(params) + def execute(params, klass, connection) bind_values = bind_map.bind params - sql = query_builder.sql_for bind_values, klass.connection + sql = query_builder.sql_for bind_values, connection klass.find_by_sql sql, bind_values end |