Skip to content

Commit e7e2587

Browse files
authored
Merge pull request rails#52464 from Shopify/sql-for-insert-no-binds
`sql_for_insert` doesn't need to concern itself about binds
2 parents 310aa1a + fff9256 commit e7e2587

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def exec_query(sql, name = "SQL", binds = [], prepare: false)
155155
# `nil` is the default value and maintains default behavior. If an array of column names is passed -
156156
# the result will contain values of the specified columns from the inserted row.
157157
def exec_insert(sql, name = nil, binds = [], pk = nil, sequence_name = nil, returning: nil)
158-
sql, binds = sql_for_insert(sql, pk, binds, returning)
158+
sql = sql_for_insert(sql, pk, returning)
159159
internal_exec_query(sql, name, binds)
160160
end
161161

@@ -707,7 +707,7 @@ def select(sql, name = nil, binds = [], prepare: false, async: false, allow_retr
707707
end
708708
end
709709

710-
def sql_for_insert(sql, pk, binds, returning) # :nodoc:
710+
def sql_for_insert(sql, pk, returning) # :nodoc:
711711
if supports_insert_returning?
712712
if pk.nil?
713713
# Extract the table from the insert sql. Yuck.
@@ -721,7 +721,7 @@ def sql_for_insert(sql, pk, binds, returning) # :nodoc:
721721
sql = "#{sql} RETURNING #{returning_columns_statement}" if returning_columns.any?
722722
end
723723

724-
[sql, binds]
724+
sql
725725
end
726726

727727
def last_inserted_id(result)

activerecord/lib/active_record/connection_adapters/trilogy/database_statements.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module ConnectionAdapters
55
module Trilogy
66
module DatabaseStatements
77
def exec_insert(sql, name, binds, pk = nil, sequence_name = nil, returning: nil) # :nodoc:
8-
sql, _binds = sql_for_insert(sql, pk, binds, returning)
8+
sql = sql_for_insert(sql, pk, returning)
99
internal_execute(sql, name)
1010
end
1111

0 commit comments

Comments
 (0)