File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -145,8 +145,27 @@ def test_belongs_to_with_primary_key_joins_on_correct_column_coerced
145145
146146module ActiveRecord
147147 class BindParameterTest < ActiveRecord ::TestCase
148- # Never finds `sql` since we use `EXEC sp_executesql` wrappers .
148+ # Same as original coerced test except log is found using `EXEC sp_executesql` wrapper .
149149 coerce_tests! :test_binds_are_logged
150+ def test_binds_are_logged_coerced
151+ sub = Arel ::Nodes ::BindParam . new ( 1 )
152+ binds = [ Relation ::QueryAttribute . new ( "id" , 1 , Type ::Value . new ) ]
153+ sql = "select * from topics where id = #{ sub . to_sql } "
154+
155+ @connection . exec_query ( sql , "SQL" , binds )
156+
157+ logged_sql = "EXEC sp_executesql N'#{ sql } ', N'#{ sub . to_sql } int', #{ sub . to_sql } = 1"
158+ message = @subscriber . calls . find { |args | args [ 4 ] [ :sql ] == logged_sql }
159+
160+ assert_equal binds , message [ 4 ] [ :binds ]
161+ end
162+
163+ # SQL Server adapter does not use a statement cache as query plans are already reused using `EXEC sp_executesql`.
164+ coerce_tests! :test_statement_cache
165+ coerce_tests! :test_statement_cache_with_query_cache
166+ coerce_tests! :test_statement_cache_with_find_by
167+ coerce_tests! :test_statement_cache_with_in_clause
168+ coerce_tests! :test_statement_cache_with_sql_string_literal
150169 end
151170end
152171
You can’t perform that action at this time.
0 commit comments