rails-sqlserver / activerecord-sqlserver-adapter

SQL Server Adapter For Rails
MIT License
974 stars 563 forks source link

Handle insert returning using symbol #1226

Closed aidanharan closed 1 month ago

aidanharan commented 1 month ago

Support using symbol for returning. Eg: Book.insert!({ name: book_name }, returning: :id).

https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/actions/runs/11072196039/job/30765857801

 1) Error:
InsertAllTest#test_insert_with_type_casting_and_serialize_is_consistent:
NoMethodError: undefined method `map' for :id:Symbol
    lib/active_record/connection_adapters/sqlserver/database_statements.rb:148:in `build_insert_sql'
    /usr/local/bundle/bundler/gems/rails-13d5f8720892/activerecord/lib/active_record/insert_all.rb:193:in `to_sql'
    /usr/local/bundle/bundler/gems/rails-13d5f8720892/activerecord/lib/active_record/insert_all.rb:54:in `execute'
    /usr/local/bundle/bundler/gems/rails-13d5f8720892/activerecord/lib/active_record/insert_all.rb:13:in `block in execute'
    /usr/local/bundle/bundler/gems/rails-13d5f8720892/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:388:in `with_connection'
    /usr/local/bundle/bundler/gems/rails-13d5f8720892/activerecord/lib/active_record/connection_handling.rb:310:in `with_connection'
    /usr/local/bundle/bundler/gems/rails-13d5f8720892/activerecord/lib/active_record/insert_all.rb:12:in `execute'
    /usr/local/bundle/bundler/gems/rails-13d5f8720892/activerecord/lib/active_record/relation.rb:784:in `insert_all!'
    /usr/local/bundle/bundler/gems/rails-13d5f8720892/activerecord/lib/active_record/relation.rb:727:in `insert!'
    /usr/local/bundle/bundler/gems/rails-13d5f8720892/activerecord/lib/active_record/querying.rb:24:in `insert!'
    /usr/local/bundle/bundler/gems/rails-13d5f8720892/activerecord/test/cases/insert_all_test.rb:55:in `test_insert_with_type_casting_and_serialize_is_consistent'