Permalink
Browse files

Merge pull request #26051 from kamipo/make_name_and_binds_to_optional…

…_args

Make `name` and `binds` to optional args for `exec_{insert,update,delete}`
  • Loading branch information...
eileencodes committed Aug 5, 2016
2 parents af1680f + cdc4666 commit 2bd9ec6b3da82e5519baab787d42997c50c93c73
@@ -89,14 +89,14 @@ def exec_query(sql, name = 'SQL', binds = [], prepare: false)
# Executes insert +sql+ statement in the context of this connection using
# +binds+ as the bind substitutes. +name+ is logged along with
# the executed +sql+ statement.
def exec_insert(sql, name, binds, pk = nil, sequence_name = nil)
def exec_insert(sql, name = nil, binds = [], pk = nil, sequence_name = nil)
exec_query(sql, name, binds)
end
# Executes delete +sql+ statement in the context of this connection using
# +binds+ as the bind substitutes. +name+ is logged along with
# the executed +sql+ statement.
def exec_delete(sql, name, binds)
def exec_delete(sql, name = nil, binds = [])
exec_query(sql, name, binds)
end
@@ -108,7 +108,7 @@ def truncate(table_name, name = nil)
# Executes update +sql+ statement in the context of this connection using
# +binds+ as the bind substitutes. +name+ is logged along with
# the executed +sql+ statement.
def exec_update(sql, name, binds)
def exec_update(sql, name = nil, binds = [])
exec_query(sql, name, binds)
end
@@ -45,7 +45,7 @@ def exec_query(sql, name = 'SQL', binds = [], prepare: false)
end
end
def exec_delete(sql, name, binds)
def exec_delete(sql, name = nil, binds = [])
if without_prepared_statement?(binds)
execute_and_free(sql, name) { @connection.affected_rows }
else
@@ -112,7 +112,7 @@ def exec_query(sql, name = 'SQL', binds = [], prepare: false)
end
end
def exec_delete(sql, name = 'SQL', binds = [])
def exec_delete(sql, name = nil, binds = [])
execute_and_clear(sql, name, binds) {|result| result.cmd_tuples }
end
alias :exec_update :exec_delete
@@ -133,7 +133,7 @@ def sql_for_insert(sql, pk, id_value, sequence_name, binds) # :nodoc:
super
end
def exec_insert(sql, name, binds, pk = nil, sequence_name = nil)
def exec_insert(sql, name = nil, binds = [], pk = nil, sequence_name = nil)
val = exec_query(sql, name, binds)
if !use_insert_returning? && pk
unless sequence_name

0 comments on commit 2bd9ec6

Please sign in to comment.