@@ -376,6 +376,22 @@ def test_payload_row_count_on_raw_sql_coerced
376
376
end
377
377
378
378
class CalculationsTest < ActiveRecord ::TestCase
379
+ # SELECT columns must be in the GROUP clause.
380
+ coerce_tests! :test_should_count_with_group_by_qualified_name_on_loaded
381
+ def test_should_count_with_group_by_qualified_name_on_loaded_coerced
382
+ accounts = Account . group ( "accounts.id" ) . select ( "accounts.id" )
383
+
384
+ expected = { 1 => 1 , 2 => 1 , 3 => 1 , 4 => 1 , 5 => 1 , 6 => 1 }
385
+
386
+ assert_not_predicate accounts , :loaded?
387
+ assert_equal expected , accounts . count
388
+
389
+ accounts . load
390
+
391
+ assert_predicate accounts , :loaded?
392
+ assert_equal expected , accounts . count ( :id )
393
+ end
394
+
379
395
# Fix randomly failing test. The loading of the model's schema was affecting the test.
380
396
coerce_tests! :test_offset_is_kept
381
397
def test_offset_is_kept_coerced
@@ -2200,35 +2216,6 @@ class EnumTest < ActiveRecord::TestCase
2200
2216
end
2201
2217
end
2202
2218
2203
- require "models/task"
2204
- class QueryCacheExpiryTest < ActiveRecord ::TestCase
2205
- # SQL Server does not support skipping or upserting duplicates.
2206
- coerce_tests! :test_insert_all
2207
- def test_insert_all_coerced
2208
- assert_raises ( ArgumentError , /does not support skipping duplicates/ ) do
2209
- Task . cache { Task . insert ( { starting : Time . now } ) }
2210
- end
2211
-
2212
- assert_raises ( ArgumentError , /does not support upsert/ ) do
2213
- Task . cache { Task . upsert ( { starting : Time . now } ) }
2214
- end
2215
-
2216
- assert_raises ( ArgumentError , /does not support upsert/ ) do
2217
- Task . cache { Task . upsert_all ( [ { starting : Time . now } ] ) }
2218
- end
2219
-
2220
- Task . cache do
2221
- assert_called ( ActiveRecord ::Base . connection_pool . query_cache , :clear , times : 1 ) do
2222
- Task . insert_all! ( [ starting : Time . now ] )
2223
- end
2224
-
2225
- assert_called ( ActiveRecord ::Base . connection_pool . query_cache , :clear , times : 1 ) do
2226
- Task . insert! ( { starting : Time . now } )
2227
- end
2228
- end
2229
- end
2230
- end
2231
-
2232
2219
require "models/citation"
2233
2220
class EagerLoadingTooManyIdsTest < ActiveRecord ::TestCase
2234
2221
fixtures :citations
@@ -2542,21 +2529,6 @@ def invalid_add_column_option_exception_message(key)
2542
2529
end
2543
2530
end
2544
2531
2545
- # SQL Server does not support upsert. Removed dependency on `insert_all` that uses upsert.
2546
- class ActiveRecord ::Encryption ::ConcurrencyTest < ActiveRecord ::EncryptionTestCase
2547
- undef_method :thread_encrypting_and_decrypting
2548
- def thread_encrypting_and_decrypting ( thread_label )
2549
- posts = 100 . times . collect { |index | EncryptedPost . create! title : "Article #{ index } (#{ thread_label } )" , body : "Body #{ index } (#{ thread_label } )" }
2550
-
2551
- Thread . new do
2552
- posts . each . with_index do |article , index |
2553
- assert_encrypted_attribute article , :title , "Article #{ index } (#{ thread_label } )"
2554
- article . decrypt
2555
- assert_not_encrypted_attribute article , :title , "Article #{ index } (#{ thread_label } )"
2556
- end
2557
- end
2558
- end
2559
- end
2560
2532
2561
2533
# Need to use `install_unregistered_type_fallback` instead of `install_unregistered_type_error` so that message-pack
2562
2534
# can read and write `ActiveRecord::ConnectionAdapters::SQLServer::Type::Data` objects.
0 commit comments