diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-10-26 13:02:14 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-10-26 13:44:11 -0700 |
commit | e73b0b84d939af241dfbba8931d8add9724595e4 (patch) | |
tree | 39fa3b203de14130f8579bca1f7989d2a693f6fa /activerecord | |
parent | 104d0b263e5d9b17216f06c72d422d26ca5a537f (diff) | |
download | rails-e73b0b84d939af241dfbba8931d8add9724595e4.tar.gz rails-e73b0b84d939af241dfbba8931d8add9724595e4.tar.bz2 rails-e73b0b84d939af241dfbba8931d8add9724595e4.zip |
renaming bind_values to binds where it makes sense
Diffstat (limited to 'activerecord')
5 files changed, 19 insertions, 19 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 825b86f068..06a388cd21 100644 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -448,8 +448,8 @@ module ActiveRecord #:nodoc: # # You can use the same string replacement techniques as you can with ActiveRecord#find # Post.find_by_sql ["SELECT title FROM posts WHERE author = ? AND created > ?", author_id, start_date] # > [#<Post:0x36bff9c @attributes={"first_name"=>"The Cheap Man Buys Twice"}>, ...] - def find_by_sql(sql, bind_values = []) - connection.select_all(sanitize_sql(sql), "#{name} Load", bind_values).collect! { |record| instantiate(record) } + def find_by_sql(sql, binds = []) + connection.select_all(sanitize_sql(sql), "#{name} Load", binds).collect! { |record| instantiate(record) } end # Creates an object (or multiple objects) and saves it to the database, if validations pass. diff --git a/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb index 16d01f051b..6178130c00 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb @@ -3,12 +3,12 @@ module ActiveRecord module DatabaseStatements # Returns an array of record hashes with the column names as keys and # column values as values. - def select_all(sql, name = nil, bind_values = []) + def select_all(sql, name = nil, binds = []) if supports_statement_cache? - select(sql, name, bind_values) + select(sql, name, binds) else - return select(sql, name) if bind_values.empty? - binds = bind_values.dup + return select(sql, name) if binds.empty? + binds = binds.dup select sql.gsub('?') { quote(*binds.shift.reverse) }, name @@ -48,7 +48,7 @@ module ActiveRecord undef_method :execute # Executes +sql+ statement in the context of this connection using - # +bind_values+ as the bind substitutes. +name+ is logged along with + # +binds+ as the bind substitutes. +name+ is logged along with # the executed +sql+ statement. def exec(sql, name = 'SQL', binds = []) end @@ -274,7 +274,7 @@ module ActiveRecord protected # Returns an array of record hashes with the column names as keys and # column values as values. - def select(sql, name = nil, bind_values = []) + def select(sql, name = nil, binds = []) end undef_method :select diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb index 6f014bf9f1..42d6f2bb21 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb @@ -99,8 +99,8 @@ module ActiveRecord end # Returns a bind substitution value given a +column+ and list of current - # +bind_values+ - def substitute_for(column, bind_values) + # +binds+ + def substitute_for(column, binds) Arel.sql '?' end diff --git a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb index 36817fcbfd..7d47d06ae1 100644 --- a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb @@ -326,12 +326,12 @@ module ActiveRecord @statements.clear end - def exec(sql, name = 'SQL', bind_values = []) + def exec(sql, name = 'SQL', binds = []) log(sql, name) do result = nil cache = {} - if bind_values.empty? + if binds.empty? stmt = @connection.prepare(sql) else cache = @statements[sql] ||= { @@ -340,7 +340,7 @@ module ActiveRecord stmt = cache[:stmt] end - stmt.execute(*bind_values.map { |col, val| + stmt.execute(*binds.map { |col, val| col ? col.type_cast(val) : val }) if metadata = stmt.result_metadata @@ -353,7 +353,7 @@ module ActiveRecord end stmt.free_result - stmt.close if bind_values.empty? + stmt.close if binds.empty? result end diff --git a/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb index d95b950e18..a4d7d12298 100644 --- a/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb @@ -143,11 +143,11 @@ module ActiveRecord # DATABASE STATEMENTS ====================================== - def exec(sql, name = nil, bind_values = []) + def exec(sql, name = nil, binds = []) log(sql, name) do # Don't cache statements without bind values - if bind_values.empty? + if binds.empty? stmt = @connection.prepare(sql) cols = stmt.columns else @@ -157,7 +157,7 @@ module ActiveRecord stmt = cache[:stmt] cols = cache[:cols] ||= stmt.columns stmt.reset! - stmt.bind_params bind_values.map { |col, val| + stmt.bind_params binds.map { |col, val| col ? col.type_cast(val) : val } end @@ -313,8 +313,8 @@ module ActiveRecord end protected - def select(sql, name = nil, bind_values = []) #:nodoc: - exec(sql, name, bind_values).map do |row| + def select(sql, name = nil, binds = []) #:nodoc: + exec(sql, name, binds).map do |row| record = {} row.each do |key, value| record[key.sub(/^"?\w+"?\./, '')] = value if key.is_a?(String) |