rails-sqlserver / activerecord-sqlserver-adapter

SQL Server Adapter For Rails
MIT License
968 stars 558 forks source link

Reintroduce visit_Arel_Nodes_HomogeneousIn monkey-patch #1137

Closed aidanharan closed 7 months ago

aidanharan commented 7 months ago

The visit_Arel_Nodes_HomogeneousIn method was incorrectly removed in https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/1068. This PR adds the method back in while also fixing the method for Rails 7.1

This fixes the following failing test that started in Rails 7.1.2 (https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/actions/runs/6849256715/job/18621067933?pr=1136):

Failure:
ActiveRecord::BindParameterTest#test_bind_params_to_sql_with_prepared_statements_coerced [/activerecord-sqlserver-adapter/test/cases/coerced_tests.rb:298]:
Query pattern(s) "EXEC sp_executesql N'SELECT [authors].* FROM [authors] WHERE ([authors].[id] IN (@0, @1, @2) OR [authors].[id] IS NULL)', N'@0 bigint, @1 bigint, @2 bigint', @0 = 1, @1 = 2, @2 = 3" not found.
Queries:
EXEC sp_executesql N'SELECT [authors].* FROM [authors] WHERE ([authors].[id] IN (@0, @1, @2) OR [authors].[id] IS NULL)', N'@0 int, @1 int, @2 int', @0 = 1, @1 = 2, @2 = 3

bin/rails test /activerecord-sqlserver-adapter/test/cases/coerced_tests.rb:297

The method has also been updated for serialized columns so that the SerializedAttributeTest#test_where_by_serialized_attribute_with_hash_in_array test passes.