File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -2959,4 +2959,30 @@ def test_in_batches_executes_range_queries_when_constrained_and_opted_in_into_ra
29592959 relations . each { |relation | assert_kind_of Post , relation . first }
29602960 end
29612961 end
2962+
2963+ # Match SQL Server SQL format.
2964+ coerce_tests! :test_in_batches_should_unscope_cursor_after_pluck
2965+ def test_in_batches_should_unscope_cursor_after_pluck_coerced
2966+ all_ids = Post . limit ( 2 ) . pluck ( :id )
2967+ found_ids = [ ]
2968+ # only a single clause on id (i.e. not 'id IN (?,?) AND id = ?', but only 'id = ?')
2969+ assert_queries_match ( /WHERE #{ Regexp . escape ( quote_table_name ( "posts.id" ) ) } = \S + ORDER BY/ ) do
2970+ Post . where ( id : all_ids ) . in_batches ( of : 1 ) do |relation |
2971+ found_ids << relation . pick ( :id )
2972+ end
2973+ end
2974+ assert_equal all_ids . sort , found_ids
2975+ end
2976+
2977+ # Match SQL Server SQL format.
2978+ coerce_tests! :test_in_batches_loaded_should_unscope_cursor_after_pluck
2979+ def test_in_batches_loaded_should_unscope_cursor_after_pluck_coerced
2980+ all_ids = Post . limit ( 2 ) . pluck ( :id )
2981+ # only a single clause on id (i.e. not 'id IN (?,?) AND id = ?', but only 'id = ?')
2982+ assert_queries_match ( /WHERE #{ Regexp . escape ( quote_table_name ( "posts.id" ) ) } = \S +;/ ) do
2983+ Post . where ( id : all_ids ) . in_batches ( of : 1 , load : true ) do |relation |
2984+ relation . delete_all
2985+ end
2986+ end
2987+ end
29622988end
You can’t perform that action at this time.
0 commit comments