diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2016-01-08 01:34:31 -0200 |
---|---|---|
committer | Rafael França <rafaelmfranca@gmail.com> | 2016-01-08 01:34:31 -0200 |
commit | 2a1312eb9f2314e6fdd19058b2477b3a4464774f (patch) | |
tree | 9ac1151bb96d4abd39096ab73e4935f98c4d6040 | |
parent | 6dbc5e7fb870e997ce9cf959f9ecffc3561dcfd5 (diff) | |
parent | c90f141fb1a1f883f859d9bca8b98de2cc889006 (diff) | |
download | rails-2a1312eb9f2314e6fdd19058b2477b3a4464774f.tar.gz rails-2a1312eb9f2314e6fdd19058b2477b3a4464774f.tar.bz2 rails-2a1312eb9f2314e6fdd19058b2477b3a4464774f.zip |
Merge pull request #22971 from kamipo/insert_sql_is_almost_same_as_insert
`{update|delete}_sql` are almost the same as `{update|delete}`
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 |