From 959ef0ed712b3b3f87ccd9184cd372e2a549d990 Mon Sep 17 00:00:00 2001 From: Aidan Haran Date: Fri, 27 Sep 2024 15:44:16 +0100 Subject: [PATCH] Handle insert returning using symbol Support using symbol for returning. Eg: "Book.insert!({ name: book_name }, returning: :id)" --- .../connection_adapters/sqlserver/database_statements.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/active_record/connection_adapters/sqlserver/database_statements.rb b/lib/active_record/connection_adapters/sqlserver/database_statements.rb index 7a825101d..ebf933e9e 100644 --- a/lib/active_record/connection_adapters/sqlserver/database_statements.rb +++ b/lib/active_record/connection_adapters/sqlserver/database_statements.rb @@ -142,11 +142,7 @@ def build_insert_sql(insert) # :nodoc: sql = +"INSERT #{insert.into}" if returning = insert.send(:insert_all).returning - returning_sql = if returning.is_a?(String) - returning - else - returning.map { |column| "INSERTED.#{quote_column_name(column)}" }.join(", ") - end + returning_sql = Array(returning).map { |column| "INSERTED.#{quote_column_name(column)}" }.join(", ") sql << " OUTPUT #{returning_sql}" end