rails-sqlserver / activerecord-sqlserver-adapter

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

Fix query cache filtering #1075

Closed aidanharan closed 11 months ago

aidanharan commented 11 months ago

The query cache key following https://github.com/rails/rails/commit/89a5d6ada51a09c37f61e32247f68536477fc825 can be either sql or [sql, binds]. This PR fixes the monkey-patch in our tests to handle this change.

Fixes "undefined method `=~'" CI errors like:

https://pipelines.actions.githubusercontent.com/serviceHosts/3cfa8887-b415-43d0-9425-f913b8e254ac/_apis/pipelines/1/runs/669/signedlogcontent/4?urlExpires=2023-08-10T12%3A46%3A11.3752396Z&urlSigningMethod=HMACV1&urlSignature=v0pmOLZPZpQJpwOgy4LOr1wFwhn7phKRXry2iqg8kbI%3D

2023-08-10T08:31:40.0282213Z NamedScopingTest#test_scopes_are_cached_on_associations:
2023-08-10T08:31:40.0284081Z NoMethodError: undefined method `=~' for ["SELECT [comments].* FROM [comments] WHERE [comments].[post_id] = @0 AND (comments.body LIKE '%e%')", [#<ActiveRecord::Relation::QueryAttribute:0x00007f03aa223170 @name="post_id", @value_before_type_cast=1, @type=#<ActiveRecord::ConnectionAdapters::SQLServer::Type::Integer:0x00007f03afcbef80 @precision=nil, @scale=nil, @limit=4, @range=-2147483648...2147483648>, @original_attribute=nil, @value=1, @_unboundable=nil, @value_for_database=1>]]:Array
2023-08-10T08:31:40.0285197Z     activerecord-sqlserver-adapter/test/support/core_ext/query_cache.rb:25:in `block in cache_sql'