diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2016-01-08 10:30:59 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2016-01-08 11:44:29 +0900 |
commit | c90f141fb1a1f883f859d9bca8b98de2cc889006 (patch) | |
tree | 175122b0f0da4e6ffca3068db022d5fa182a54ce /activerecord/lib | |
parent | 43ccebc1db072ba0c96a67de0b3db78fd8fd0973 (diff) | |
download | rails-c90f141fb1a1f883f859d9bca8b98de2cc889006.tar.gz rails-c90f141fb1a1f883f859d9bca8b98de2cc889006.tar.bz2 rails-c90f141fb1a1f883f859d9bca8b98de2cc889006.zip |
`{update|delete}_sql` are almost the same as `{update|delete}`
Simply `{update|delete}_sql` aliases to `{update|delete}`.
Diffstat (limited to 'activerecord/lib')
4 files changed, 2 insertions, 25 deletions
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 4d12c19b47..24418db2e9 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb @@ -123,11 +123,13 @@ module ActiveRecord def update(arel, name = nil, binds = []) exec_update(to_sql(arel, binds), name, binds) end + alias update_sql update # Executes the delete statement and returns the number of rows affected. def delete(arel, name = nil, binds = []) exec_delete(to_sql(arel, binds), name, binds) end + alias delete_sql delete # Returns +true+ when the connection adapter supports prepared statement # caching, otherwise returns +false+ @@ -375,16 +377,6 @@ module ActiveRecord exec_query(sql, name, binds, prepare: true) end - # Executes the update statement and returns the number of rows affected. - def update_sql(sql, name = nil) - execute(sql, name) - end - - # Executes the delete statement and returns the number of rows affected. - def delete_sql(sql, name = nil) - update_sql(sql, name) - end - def sql_for_insert(sql, pk, id_value, sequence_name, binds) [sql, binds] end diff --git a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb index b55995bc8d..f63074ac21 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb @@ -393,11 +393,6 @@ module ActiveRecord yield execute(sql, name) end - def update_sql(sql, name = nil) #:nodoc: - super - @connection.affected_rows - end - def begin_db_transaction execute "BEGIN" end diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb b/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb index ba3dc18398..2dcc10c5cb 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb @@ -184,11 +184,6 @@ module ActiveRecord end end - # Executes an UPDATE query and returns the number of affected tuples. - def update_sql(sql, name = nil) - super.cmd_tuples - end - # Begins a transaction. def begin_db_transaction execute "BEGIN" diff --git a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb index b1cfb87a12..d1893f35f5 100644 --- a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb @@ -280,11 +280,6 @@ module ActiveRecord log(sql, name) { @connection.execute(sql) } end - def update_sql(sql, name = nil) #:nodoc: - super - @connection.changes - end - def select_rows(sql, name = nil, binds = []) exec_query(sql, name, binds).rows end |