activerecord-sqlserver-adapter 6.1.3.0 → 7.0.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +11 -69
  3. data/Gemfile +2 -4
  4. data/MIT-LICENSE +1 -1
  5. data/README.md +7 -7
  6. data/VERSION +1 -1
  7. data/activerecord-sqlserver-adapter.gemspec +2 -2
  8. data/lib/active_record/connection_adapters/sqlserver/core_ext/preloader.rb +7 -15
  9. data/lib/active_record/connection_adapters/sqlserver/database_statements.rb +13 -6
  10. data/lib/active_record/connection_adapters/sqlserver/quoting.rb +2 -4
  11. data/lib/active_record/connection_adapters/sqlserver/schema_creation.rb +9 -11
  12. data/lib/active_record/connection_adapters/sqlserver/schema_statements.rb +15 -1
  13. data/lib/active_record/connection_adapters/sqlserver/type/data.rb +3 -1
  14. data/lib/active_record/connection_adapters/sqlserver/type/date.rb +1 -1
  15. data/lib/active_record/connection_adapters/sqlserver/type/datetime.rb +1 -1
  16. data/lib/active_record/connection_adapters/sqlserver/type/time.rb +1 -1
  17. data/lib/active_record/connection_adapters/sqlserver_adapter.rb +92 -87
  18. data/lib/arel/visitors/sqlserver.rb +2 -0
  19. data/test/cases/coerced_tests.rb +287 -89
  20. data/test/cases/column_test_sqlserver.rb +58 -58
  21. data/test/cases/eager_load_too_many_ids_test_sqlserver.rb +18 -0
  22. data/test/cases/schema_dumper_test_sqlserver.rb +2 -2
  23. data/test/migrations/transaction_table/1_table_will_never_be_created.rb +1 -1
  24. data/test/support/coerceable_test_sqlserver.rb +4 -4
  25. data/test/support/marshal_compatibility_fixtures/SQLServer/rails_6_1_topic.dump +0 -0
  26. data/test/support/marshal_compatibility_fixtures/SQLServer/rails_6_1_topic_associations.dump +0 -0
  27. data/test/support/rake_helpers.rb +3 -1
  28. metadata +19 -19
  29. data/test/cases/active_schema_test_sqlserver.rb +0 -55
  30. data/test/support/marshal_compatibility_fixtures/SQLServer/rails_6_0_topic.dump +0 -0
  31. data/test/support/marshal_compatibility_fixtures/SQLServer/rails_6_0_topic_associations.dump +0 -0
@@ -277,8 +277,8 @@ class ColumnTestSQLServer < ActiveRecord::TestCase
277
277
  _(col.sql_type).must_equal "date"
278
278
  _(col.type).must_equal :date
279
279
  _(col.null).must_equal true
280
- _(col.default).must_equal connection_dblib_73? ? Date.civil(0001, 1, 1) : "0001-01-01"
281
- _(obj.date).must_equal Date.civil(0001, 1, 1)
280
+ _(col.default).must_equal connection_dblib_73? ? Date.civil(1, 1, 1) : "0001-01-01"
281
+ _(obj.date).must_equal Date.civil(1, 1, 1)
282
282
  _(col.default_function).must_be_nil
283
283
  type = connection.lookup_cast_type_from_column(col)
284
284
  _(type).must_be_instance_of Type::Date
@@ -287,22 +287,22 @@ class ColumnTestSQLServer < ActiveRecord::TestCase
287
287
  _(type.scale).must_be_nil
288
288
  # Can cast strings. SQL Server format.
289
289
  obj.date = "04-01-0001"
290
- _(obj.date).must_equal Date.civil(0001, 4, 1)
290
+ _(obj.date).must_equal Date.civil(1, 4, 1)
291
291
  obj.save!
292
- _(obj.date).must_equal Date.civil(0001, 4, 1)
292
+ _(obj.date).must_equal Date.civil(1, 4, 1)
293
293
  obj.reload
294
- _(obj.date).must_equal Date.civil(0001, 4, 1)
294
+ _(obj.date).must_equal Date.civil(1, 4, 1)
295
295
  # Can cast strings. ISO format.
296
296
  obj.date = "0001-04-01"
297
- _(obj.date).must_equal Date.civil(0001, 4, 1)
297
+ _(obj.date).must_equal Date.civil(1, 4, 1)
298
298
  obj.save!
299
- _(obj.date).must_equal Date.civil(0001, 4, 1)
299
+ _(obj.date).must_equal Date.civil(1, 4, 1)
300
300
  obj.reload
301
- _(obj.date).must_equal Date.civil(0001, 4, 1)
301
+ _(obj.date).must_equal Date.civil(1, 4, 1)
302
302
  # Can filter by date range
303
303
  _(obj).must_equal obj.class.where(date: obj.date..Date::Infinity.new).first
304
304
  # Can keep and return assigned date.
305
- assert_obj_set_and_save :date, Date.civil(1972, 04, 14)
305
+ assert_obj_set_and_save :date, Date.civil(1972, 4, 14)
306
306
  # Can accept and cast time objects.
307
307
  obj.date = Time.utc(2010, 4, 14, 12, 34, 56, 3000)
308
308
  _(obj.date).must_equal Date.civil(2010, 4, 14)
@@ -315,7 +315,7 @@ class ColumnTestSQLServer < ActiveRecord::TestCase
315
315
  _(col.sql_type).must_equal "datetime"
316
316
  _(col.type).must_equal :datetime
317
317
  _(col.null).must_equal true
318
- time = Time.utc 1753, 01, 01, 00, 00, 00, 123000
318
+ time = Time.utc 1753, 1, 1, 0, 0, 0, 123000
319
319
  _(col.default).must_equal time, "Microseconds were <#{col.default.usec}> vs <123000>"
320
320
  _(obj.datetime).must_equal time, "Microseconds were <#{obj.datetime.usec}> vs <123000>"
321
321
  _(col.default_function).must_be_nil
@@ -327,7 +327,7 @@ class ColumnTestSQLServer < ActiveRecord::TestCase
327
327
  obj.save!
328
328
  _(obj).must_equal obj.class.where(datetime: time).first
329
329
  # Can save to proper accuracy and return again.
330
- time = Time.utc 2010, 04, 01, 12, 34, 56, 3000
330
+ time = Time.utc 2010, 4, 1, 12, 34, 56, 3000
331
331
  obj.datetime = time
332
332
  _(obj.datetime).must_equal time, "Microseconds were <#{obj.datetime.usec}> vs <3000>"
333
333
  obj.save!
@@ -338,8 +338,8 @@ class ColumnTestSQLServer < ActiveRecord::TestCase
338
338
  # Can filter by datetime range
339
339
  _(obj).must_equal obj.class.where(datetime: time..DateTime::Infinity.new).first
340
340
  # Will cast to true DB value on attribute write, save and return again.
341
- time = Time.utc 2010, 04, 01, 12, 34, 56, 234567
342
- time2 = Time.utc 2010, 04, 01, 12, 34, 56, 233000
341
+ time = Time.utc 2010, 4, 1, 12, 34, 56, 234567
342
+ time2 = Time.utc 2010, 4, 1, 12, 34, 56, 233000
343
343
  obj.datetime = time
344
344
  _(obj.datetime).must_equal time2, "Microseconds were <#{obj.datetime.usec}> vs <233000>"
345
345
  obj.save!
@@ -427,8 +427,8 @@ class ColumnTestSQLServer < ActiveRecord::TestCase
427
427
  _(col.sql_type).must_equal "datetimeoffset(7)"
428
428
  _(col.type).must_equal :datetimeoffset
429
429
  _(col.null).must_equal true
430
- _(col.default).must_equal Time.new(1984, 01, 24, 04, 20, 00, -28800).change(nsec: 123456700), "Nanoseconds <#{col.default.nsec}> vs <123456700>"
431
- _(obj.datetimeoffset_7).must_equal Time.new(1984, 01, 24, 04, 20, 00, -28800).change(nsec: 123456700), "Nanoseconds were <#{obj.datetimeoffset_7.nsec}> vs <999999900>"
430
+ _(col.default).must_equal Time.new(1984, 1, 24, 4, 20, 0, -28800).change(nsec: 123456700), "Nanoseconds <#{col.default.nsec}> vs <123456700>"
431
+ _(obj.datetimeoffset_7).must_equal Time.new(1984, 1, 24, 4, 20, 0, -28800).change(nsec: 123456700), "Nanoseconds were <#{obj.datetimeoffset_7.nsec}> vs <999999900>"
432
432
  _(col.default_function).must_be_nil
433
433
  type = connection.lookup_cast_type_from_column(col)
434
434
  _(type).must_be_instance_of Type::DateTimeOffset
@@ -436,12 +436,12 @@ class ColumnTestSQLServer < ActiveRecord::TestCase
436
436
  _(type.precision).must_equal 7
437
437
  _(type.scale).must_be_nil
438
438
  # Can save 100 nanosecond precisoins and return again.
439
- obj.datetimeoffset_7 = Time.new(2010, 04, 01, 12, 34, 56, +18000).change(nsec: 123456755)
440
- _(obj.datetimeoffset_7).must_equal Time.new(2010, 04, 01, 12, 34, 56, +18000).change(nsec: 123456800), "Nanoseconds were <#{obj.datetimeoffset_7.nsec}> vs <123456800>"
439
+ obj.datetimeoffset_7 = Time.new(2010, 4, 1, 12, 34, 56, +18000).change(nsec: 123456755)
440
+ _(obj.datetimeoffset_7).must_equal Time.new(2010, 4, 1, 12, 34, 56, +18000).change(nsec: 123456800), "Nanoseconds were <#{obj.datetimeoffset_7.nsec}> vs <123456800>"
441
441
  obj.save!
442
- _(obj.datetimeoffset_7).must_equal Time.new(2010, 04, 01, 12, 34, 56, +18000).change(nsec: 123456800), "Nanoseconds were <#{obj.datetimeoffset_7.nsec}> vs <123456800>"
442
+ _(obj.datetimeoffset_7).must_equal Time.new(2010, 4, 1, 12, 34, 56, +18000).change(nsec: 123456800), "Nanoseconds were <#{obj.datetimeoffset_7.nsec}> vs <123456800>"
443
443
  obj.reload
444
- _(obj.datetimeoffset_7).must_equal Time.new(2010, 04, 01, 12, 34, 56, +18000).change(nsec: 123456800), "Nanoseconds were <#{obj.datetimeoffset_7.nsec}> vs <123456800>"
444
+ _(obj.datetimeoffset_7).must_equal Time.new(2010, 4, 1, 12, 34, 56, +18000).change(nsec: 123456800), "Nanoseconds were <#{obj.datetimeoffset_7.nsec}> vs <123456800>"
445
445
  # Maintains the timezone
446
446
  time = ActiveSupport::TimeZone["America/Los_Angeles"].local 2010, 12, 31, 23, 59, 59, Rational(123456800, 1000)
447
447
  obj.datetimeoffset_7 = time
@@ -470,8 +470,8 @@ class ColumnTestSQLServer < ActiveRecord::TestCase
470
470
  _(col.sql_type).must_equal "smalldatetime"
471
471
  _(col.type).must_equal :smalldatetime
472
472
  _(col.null).must_equal true
473
- _(col.default).must_equal Time.utc(1901, 01, 01, 15, 45, 00, 000)
474
- _(obj.smalldatetime).must_equal Time.utc(1901, 01, 01, 15, 45, 00, 000)
473
+ _(col.default).must_equal Time.utc(1901, 1, 1, 15, 45, 0, 0)
474
+ _(obj.smalldatetime).must_equal Time.utc(1901, 1, 1, 15, 45, 0, 0)
475
475
  _(col.default_function).must_be_nil
476
476
  type = connection.lookup_cast_type_from_column(col)
477
477
  _(type).must_be_instance_of Type::SmallDateTime
@@ -479,12 +479,12 @@ class ColumnTestSQLServer < ActiveRecord::TestCase
479
479
  _(type.precision).must_be_nil
480
480
  _(type.scale).must_be_nil
481
481
  # Will remove fractional seconds and return again.
482
- obj.smalldatetime = Time.utc(2078, 06, 05, 4, 20, 00, 3000)
483
- _(obj.smalldatetime).must_equal Time.utc(2078, 06, 05, 4, 20, 00, 0), "Microseconds were <#{obj.smalldatetime.usec}> vs <0>"
482
+ obj.smalldatetime = Time.utc(2078, 6, 5, 4, 20, 0, 3000)
483
+ _(obj.smalldatetime).must_equal Time.utc(2078, 6, 5, 4, 20, 0, 0), "Microseconds were <#{obj.smalldatetime.usec}> vs <0>"
484
484
  obj.save!
485
- _(obj.smalldatetime).must_equal Time.utc(2078, 06, 05, 4, 20, 00, 0), "Microseconds were <#{obj.reload.smalldatetime.usec}> vs <0>"
485
+ _(obj.smalldatetime).must_equal Time.utc(2078, 6, 5, 4, 20, 0, 0), "Microseconds were <#{obj.reload.smalldatetime.usec}> vs <0>"
486
486
  obj.reload
487
- _(obj.smalldatetime).must_equal Time.utc(2078, 06, 05, 4, 20, 00, 0), "Microseconds were <#{obj.reload.smalldatetime.usec}> vs <0>"
487
+ _(obj.smalldatetime).must_equal Time.utc(2078, 6, 5, 4, 20, 0, 0), "Microseconds were <#{obj.reload.smalldatetime.usec}> vs <0>"
488
488
  end
489
489
 
490
490
  it "time(7)" do
@@ -493,7 +493,7 @@ class ColumnTestSQLServer < ActiveRecord::TestCase
493
493
  _(col.sql_type).must_equal "time(7)"
494
494
  _(col.type).must_equal :time
495
495
  _(col.null).must_equal true
496
- _(col.default).must_equal Time.utc(1900, 01, 01, 04, 20, 00, Rational(288321500, 1000)), "Nanoseconds were <#{col.default.nsec}> vs <288321500>"
496
+ _(col.default).must_equal Time.utc(1900, 1, 1, 4, 20, 0, Rational(288321500, 1000)), "Nanoseconds were <#{col.default.nsec}> vs <288321500>"
497
497
  _(col.default_function).must_be_nil
498
498
  type = connection.lookup_cast_type_from_column(col)
499
499
  _(type).must_be_instance_of Type::Time
@@ -501,22 +501,22 @@ class ColumnTestSQLServer < ActiveRecord::TestCase
501
501
  _(type.precision).must_equal 7
502
502
  _(type.scale).must_be_nil
503
503
  # Time's #usec precision (low micro)
504
- obj.time_7 = Time.utc(2000, 01, 01, 15, 45, 00, 300)
505
- _(obj.time_7).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 300), "Microseconds were <#{obj.time_7.usec}> vs <0>"
506
- _(obj.time_7).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 300), "Nanoseconds were <#{obj.time_7.nsec}> vs <300>"
504
+ obj.time_7 = Time.utc(2000, 1, 1, 15, 45, 0, 300)
505
+ _(obj.time_7).must_equal Time.utc(2000, 1, 1, 15, 45, 0, 300), "Microseconds were <#{obj.time_7.usec}> vs <0>"
506
+ _(obj.time_7).must_equal Time.utc(2000, 1, 1, 15, 45, 0, 300), "Nanoseconds were <#{obj.time_7.nsec}> vs <300>"
507
507
  obj.save!; obj.reload
508
- _(obj.time_7).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 300), "Microseconds were <#{obj.time_7.usec}> vs <0>"
509
- _(obj.time_7).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 300), "Nanoseconds were <#{obj.time_7.nsec}> vs <300>"
508
+ _(obj.time_7).must_equal Time.utc(2000, 1, 1, 15, 45, 0, 300), "Microseconds were <#{obj.time_7.usec}> vs <0>"
509
+ _(obj.time_7).must_equal Time.utc(2000, 1, 1, 15, 45, 0, 300), "Nanoseconds were <#{obj.time_7.nsec}> vs <300>"
510
510
  # Time's #usec precision (high micro)
511
- obj.time_7 = Time.utc(2000, 01, 01, 15, 45, 00, 234567)
512
- _(obj.time_7).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 234567), "Microseconds were <#{obj.time_7.usec}> vs <234567>"
511
+ obj.time_7 = Time.utc(2000, 1, 1, 15, 45, 0, 234567)
512
+ _(obj.time_7).must_equal Time.utc(2000, 1, 1, 15, 45, 0, 234567), "Microseconds were <#{obj.time_7.usec}> vs <234567>"
513
513
  obj.save!; obj.reload
514
- _(obj.time_7).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 234567), "Microseconds were <#{obj.time_7.usec}> vs <234567>"
514
+ _(obj.time_7).must_equal Time.utc(2000, 1, 1, 15, 45, 0, 234567), "Microseconds were <#{obj.time_7.usec}> vs <234567>"
515
515
  # Time's #usec precision (high nano rounded)
516
- obj.time_7 = Time.utc(2000, 01, 01, 15, 45, 00, Rational(288321545, 1000))
517
- _(obj.time_7).must_equal Time.utc(2000, 01, 01, 15, 45, 00, Rational(288321500, 1000)), "Nanoseconds were <#{obj.time_7.nsec}> vs <288321500>"
516
+ obj.time_7 = Time.utc(2000, 1, 1, 15, 45, 0, Rational(288321545, 1000))
517
+ _(obj.time_7).must_equal Time.utc(2000, 1, 1, 15, 45, 0, Rational(288321500, 1000)), "Nanoseconds were <#{obj.time_7.nsec}> vs <288321500>"
518
518
  obj.save!; obj.reload
519
- _(obj.time_7).must_equal Time.utc(2000, 01, 01, 15, 45, 00, Rational(288321500, 1000)), "Nanoseconds were <#{obj.time_7.nsec}> vs <288321500>"
519
+ _(obj.time_7).must_equal Time.utc(2000, 1, 1, 15, 45, 0, Rational(288321500, 1000)), "Nanoseconds were <#{obj.time_7.nsec}> vs <288321500>"
520
520
  end
521
521
 
522
522
  it "time(2)" do
@@ -533,20 +533,20 @@ class ColumnTestSQLServer < ActiveRecord::TestCase
533
533
  _(type.precision).must_equal 2
534
534
  _(type.scale).must_be_nil
535
535
  # Always uses TinyTDS/Windows 2000-01-01 convention too.
536
- obj.time_2 = Time.utc(2015, 01, 10, 15, 45, 00, 0)
537
- _(obj.time_2).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 0)
536
+ obj.time_2 = Time.utc(2015, 1, 10, 15, 45, 0, 0)
537
+ _(obj.time_2).must_equal Time.utc(2000, 1, 1, 15, 45, 0, 0)
538
538
  obj.save!; obj.reload
539
- _(obj.time_2).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 0)
539
+ _(obj.time_2).must_equal Time.utc(2000, 1, 1, 15, 45, 0, 0)
540
540
  # Time's #usec precision (barely in 2 precision equal to 0.03 seconds)
541
- obj.time_2 = Time.utc(2000, 01, 01, 15, 45, 00, 30000)
542
- _(obj.time_2).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 30000), "Microseconds were <#{obj.time_2.usec}> vs <30000>"
541
+ obj.time_2 = Time.utc(2000, 1, 1, 15, 45, 0, 30000)
542
+ _(obj.time_2).must_equal Time.utc(2000, 1, 1, 15, 45, 0, 30000), "Microseconds were <#{obj.time_2.usec}> vs <30000>"
543
543
  obj.save!; obj.reload
544
- _(obj.time_2).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 30000), "Microseconds were <#{obj.time_2.usec}> vs <30000>"
544
+ _(obj.time_2).must_equal Time.utc(2000, 1, 1, 15, 45, 0, 30000), "Microseconds were <#{obj.time_2.usec}> vs <30000>"
545
545
  # Time's #usec precision (below 2 precision)
546
- obj.time_2 = Time.utc(2000, 01, 01, 15, 45, 00, 4000)
547
- _(obj.time_2).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 0), "Microseconds were <#{obj.time_2.usec}> vs <0>"
546
+ obj.time_2 = Time.utc(2000, 1, 1, 15, 45, 0, 4000)
547
+ _(obj.time_2).must_equal Time.utc(2000, 1, 1, 15, 45, 0, 0), "Microseconds were <#{obj.time_2.usec}> vs <0>"
548
548
  obj.save!; obj.reload
549
- _(obj.time_2).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 0), "Microseconds were <#{obj.time_2.usec}> vs <0>"
549
+ _(obj.time_2).must_equal Time.utc(2000, 1, 1, 15, 45, 0, 0), "Microseconds were <#{obj.time_2.usec}> vs <0>"
550
550
  end
551
551
 
552
552
  it "time using default precision" do
@@ -555,7 +555,7 @@ class ColumnTestSQLServer < ActiveRecord::TestCase
555
555
  _(col.sql_type).must_equal "time(7)"
556
556
  _(col.type).must_equal :time
557
557
  _(col.null).must_equal true
558
- _(col.default).must_equal Time.utc(1900, 01, 01, 15, 03, 42, Rational(62197800, 1000)), "Nanoseconds were <#{col.default.nsec}> vs <62197800>"
558
+ _(col.default).must_equal Time.utc(1900, 1, 1, 15, 3, 42, Rational(62197800, 1000)), "Nanoseconds were <#{col.default.nsec}> vs <62197800>"
559
559
  _(col.default_function).must_be_nil
560
560
  type = connection.lookup_cast_type_from_column(col)
561
561
  _(type).must_be_instance_of Type::Time
@@ -563,22 +563,22 @@ class ColumnTestSQLServer < ActiveRecord::TestCase
563
563
  _(type.precision).must_equal 7
564
564
  _(type.scale).must_be_nil
565
565
  # Time's #usec precision (low micro)
566
- obj.time_default = Time.utc(2000, 01, 01, 15, 45, 00, 300)
567
- _(obj.time_default).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 300), "Microseconds were <#{obj.time_default.usec}> vs <0>"
568
- _(obj.time_default).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 300), "Nanoseconds were <#{obj.time_default.nsec}> vs <300>"
566
+ obj.time_default = Time.utc(2000, 1, 1, 15, 45, 0, 300)
567
+ _(obj.time_default).must_equal Time.utc(2000, 1, 1, 15, 45, 0, 300), "Microseconds were <#{obj.time_default.usec}> vs <0>"
568
+ _(obj.time_default).must_equal Time.utc(2000, 1, 1, 15, 45, 0, 300), "Nanoseconds were <#{obj.time_default.nsec}> vs <300>"
569
569
  obj.save!; obj.reload
570
- _(obj.time_default).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 300), "Microseconds were <#{obj.time_default.usec}> vs <0>"
571
- _(obj.time_default).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 300), "Nanoseconds were <#{obj.time_default.nsec}> vs <300>"
570
+ _(obj.time_default).must_equal Time.utc(2000, 1, 1, 15, 45, 0, 300), "Microseconds were <#{obj.time_default.usec}> vs <0>"
571
+ _(obj.time_default).must_equal Time.utc(2000, 1, 1, 15, 45, 0, 300), "Nanoseconds were <#{obj.time_default.nsec}> vs <300>"
572
572
  # Time's #usec precision (high micro)
573
- obj.time_default = Time.utc(2000, 01, 01, 15, 45, 00, 234567)
574
- _(obj.time_default).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 234567), "Microseconds were <#{obj.time_default.usec}> vs <234567>"
573
+ obj.time_default = Time.utc(2000, 1, 1, 15, 45, 0, 234567)
574
+ _(obj.time_default).must_equal Time.utc(2000, 1, 1, 15, 45, 0, 234567), "Microseconds were <#{obj.time_default.usec}> vs <234567>"
575
575
  obj.save!; obj.reload
576
- _(obj.time_default).must_equal Time.utc(2000, 01, 01, 15, 45, 00, 234567), "Microseconds were <#{obj.time_default.usec}> vs <234567>"
576
+ _(obj.time_default).must_equal Time.utc(2000, 1, 1, 15, 45, 0, 234567), "Microseconds were <#{obj.time_default.usec}> vs <234567>"
577
577
  # Time's #usec precision (high nano rounded)
578
- obj.time_default = Time.utc(2000, 01, 01, 15, 45, 00, Rational(288321545, 1000))
579
- _(obj.time_default).must_equal Time.utc(2000, 01, 01, 15, 45, 00, Rational(288321500, 1000)), "Nanoseconds were <#{obj.time_default.nsec}> vs <288321500>"
578
+ obj.time_default = Time.utc(2000, 1, 1, 15, 45, 0, Rational(288321545, 1000))
579
+ _(obj.time_default).must_equal Time.utc(2000, 1, 1, 15, 45, 0, Rational(288321500, 1000)), "Nanoseconds were <#{obj.time_default.nsec}> vs <288321500>"
580
580
  obj.save!; obj.reload
581
- _(obj.time_default).must_equal Time.utc(2000, 01, 01, 15, 45, 00, Rational(288321500, 1000)), "Nanoseconds were <#{obj.time_default.nsec}> vs <288321500>"
581
+ _(obj.time_default).must_equal Time.utc(2000, 1, 1, 15, 45, 0, Rational(288321500, 1000)), "Nanoseconds were <#{obj.time_default.nsec}> vs <288321500>"
582
582
  end
583
583
 
584
584
  # Character Strings
@@ -0,0 +1,18 @@
1
+ require "cases/helper_sqlserver"
2
+ require "models/citation"
3
+ require "models/book"
4
+
5
+ class EagerLoadingTooManyIdsTest < ActiveRecord::TestCase
6
+ fixtures :citations
7
+
8
+ def test_batch_preloading_too_many_ids
9
+ in_clause_length = 10_000
10
+
11
+ # We Monkey patch Preloader to work with batches of 10_000 records.
12
+ # Expect: N Books queries + Citation query
13
+ expected_query_count = (Citation.count / in_clause_length.to_f).ceil + 1
14
+ assert_queries(expected_query_count) do
15
+ Citation.preload(:reference_of).to_a.size
16
+ end
17
+ end
18
+ end
@@ -67,7 +67,7 @@ class SchemaDumperTestSQLServer < ActiveRecord::TestCase
67
67
  _(columns["float_col"].sql_type).must_equal "float"
68
68
  _(columns["string_col"].sql_type).must_equal "nvarchar(4000)"
69
69
  _(columns["text_col"].sql_type).must_equal "nvarchar(max)"
70
- _(columns["datetime_col"].sql_type).must_equal "datetime"
70
+ _(columns["datetime_col"].sql_type).must_equal "datetime2(6)"
71
71
  _(columns["timestamp_col"].sql_type).must_equal "datetime"
72
72
  _(columns["time_col"].sql_type).must_equal "time(7)"
73
73
  _(columns["date_col"].sql_type).must_equal "date"
@@ -79,7 +79,7 @@ class SchemaDumperTestSQLServer < ActiveRecord::TestCase
79
79
  assert_line :float_col, type: "float", limit: nil, precision: nil, scale: nil, default: nil
80
80
  assert_line :string_col, type: "string", limit: nil, precision: nil, scale: nil, default: nil
81
81
  assert_line :text_col, type: "text", limit: nil, precision: nil, scale: nil, default: nil
82
- assert_line :datetime_col, type: "datetime", limit: nil, precision: nil, scale: nil, default: nil
82
+ assert_line :datetime_col, type: "datetime", limit: nil, precision: 6, scale: nil, default: nil
83
83
  assert_line :timestamp_col, type: "datetime", limit: nil, precision: nil, scale: nil, default: nil
84
84
  assert_line :time_col, type: "time", limit: nil, precision: 7, scale: nil, default: nil
85
85
  assert_line :date_col, type: "date", limit: nil, precision: nil, scale: nil, default: nil
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class TableWillNeverBeCreated < ActiveRecord::Migration
3
+ class TableWillNeverBeCreated < ActiveRecord::Migration[5.2]
4
4
  def self.up
5
5
  create_table(:sqlserver_trans_table1) {}
6
6
  create_table(:sqlserver_trans_table2) { raise("HELL") }
@@ -13,7 +13,7 @@ module ARTest
13
13
  module ClassMethods
14
14
  def coerce_tests!(*methods)
15
15
  methods.each do |method|
16
- self.coerced_tests.push(method)
16
+ coerced_tests.push(method)
17
17
  coerced_test_warning(method)
18
18
  end
19
19
  end
@@ -24,7 +24,7 @@ module ARTest
24
24
 
25
25
  undef_method(method)
26
26
  end
27
- STDOUT.puts "🙉 🙈 🙊 Undefined all tests: #{self.name}"
27
+ STDOUT.puts "🙉 🙈 🙊 Undefined all tests: #{name}"
28
28
  end
29
29
 
30
30
  private
@@ -43,9 +43,9 @@ module ARTest
43
43
  end
44
44
 
45
45
  if result.blank?
46
- STDOUT.puts "🐳 Unfound coerced test: #{self.name}##{m}"
46
+ STDOUT.puts "🐳 Unfound coerced test: #{name}##{m}"
47
47
  else
48
- STDOUT.puts "🐵 Undefined coerced test: #{self.name}##{m}"
48
+ STDOUT.puts "🐵 Undefined coerced test: #{name}##{m}"
49
49
  end
50
50
  end
51
51
  end
@@ -25,7 +25,9 @@ end
25
25
 
26
26
  def ar_cases
27
27
  @ar_cases ||= begin
28
- Dir.glob("#{ARTest::SQLServer.root_activerecord}/test/cases/**/*_test.rb").reject { |x| x =~ /\/adapters\// }.sort
28
+ Dir.glob("#{ARTest::SQLServer.root_activerecord}/test/cases/**/*_test.rb").reject {
29
+ |x| x.include?("/adapters/") || x.include?("/encryption/performance")
30
+ }.sort
29
31
  end
30
32
  end
31
33
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-sqlserver-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.1.3.0
4
+ version: 7.0.0.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ken Collins
@@ -11,10 +11,10 @@ authors:
11
11
  - Shawn Balestracci
12
12
  - Joe Rafaniello
13
13
  - Tom Ward
14
- autorequire:
14
+ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
- date: 2023-03-15 00:00:00.000000000 Z
17
+ date: 2022-01-18 00:00:00.000000000 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: activerecord
@@ -22,14 +22,14 @@ dependencies:
22
22
  requirements:
23
23
  - - "~>"
24
24
  - !ruby/object:Gem::Version
25
- version: 6.1.0
25
+ version: 7.0.0
26
26
  type: :runtime
27
27
  prerelease: false
28
28
  version_requirements: !ruby/object:Gem::Requirement
29
29
  requirements:
30
30
  - - "~>"
31
31
  - !ruby/object:Gem::Version
32
- version: 6.1.0
32
+ version: 7.0.0
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: tiny_tds
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -142,7 +142,6 @@ files:
142
142
  - test/bin/install-freetds.sh
143
143
  - test/bin/install-openssl.sh
144
144
  - test/bin/setup.sh
145
- - test/cases/active_schema_test_sqlserver.rb
146
145
  - test/cases/adapter_test_sqlserver.rb
147
146
  - test/cases/change_column_collation_test_sqlserver.rb
148
147
  - test/cases/change_column_null_test_sqlserver.rb
@@ -150,6 +149,7 @@ files:
150
149
  - test/cases/column_test_sqlserver.rb
151
150
  - test/cases/connection_test_sqlserver.rb
152
151
  - test/cases/disconnected_test_sqlserver.rb
152
+ - test/cases/eager_load_too_many_ids_test_sqlserver.rb
153
153
  - test/cases/execute_procedure_test_sqlserver.rb
154
154
  - test/cases/fetch_test_sqlserver.rb
155
155
  - test/cases/fully_qualified_identifier_test_sqlserver.rb
@@ -213,8 +213,8 @@ files:
213
213
  - test/support/connection_reflection.rb
214
214
  - test/support/core_ext/query_cache.rb
215
215
  - test/support/load_schema_sqlserver.rb
216
- - test/support/marshal_compatibility_fixtures/SQLServer/rails_6_0_topic.dump
217
- - test/support/marshal_compatibility_fixtures/SQLServer/rails_6_0_topic_associations.dump
216
+ - test/support/marshal_compatibility_fixtures/SQLServer/rails_6_1_topic.dump
217
+ - test/support/marshal_compatibility_fixtures/SQLServer/rails_6_1_topic_associations.dump
218
218
  - test/support/minitest_sqlserver.rb
219
219
  - test/support/paths_sqlserver.rb
220
220
  - test/support/rake_helpers.rb
@@ -225,9 +225,9 @@ licenses:
225
225
  - MIT
226
226
  metadata:
227
227
  bug_tracker_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/issues
228
- changelog_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/blob/v6.1.3.0/CHANGELOG.md
229
- source_code_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/v6.1.3.0
230
- post_install_message:
228
+ changelog_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/blob/v7.0.0.0.rc1/CHANGELOG.md
229
+ source_code_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/v7.0.0.0.rc1
230
+ post_install_message:
231
231
  rdoc_options: []
232
232
  require_paths:
233
233
  - lib
@@ -235,15 +235,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
235
235
  requirements:
236
236
  - - ">="
237
237
  - !ruby/object:Gem::Version
238
- version: 2.5.0
238
+ version: 2.7.0
239
239
  required_rubygems_version: !ruby/object:Gem::Requirement
240
240
  requirements:
241
- - - ">="
241
+ - - ">"
242
242
  - !ruby/object:Gem::Version
243
- version: '0'
243
+ version: 1.3.1
244
244
  requirements: []
245
- rubygems_version: 3.2.33
246
- signing_key:
245
+ rubygems_version: 3.2.22
246
+ signing_key:
247
247
  specification_version: 4
248
248
  summary: ActiveRecord SQL Server Adapter.
249
249
  test_files:
@@ -252,7 +252,6 @@ test_files:
252
252
  - test/bin/install-freetds.sh
253
253
  - test/bin/install-openssl.sh
254
254
  - test/bin/setup.sh
255
- - test/cases/active_schema_test_sqlserver.rb
256
255
  - test/cases/adapter_test_sqlserver.rb
257
256
  - test/cases/change_column_collation_test_sqlserver.rb
258
257
  - test/cases/change_column_null_test_sqlserver.rb
@@ -260,6 +259,7 @@ test_files:
260
259
  - test/cases/column_test_sqlserver.rb
261
260
  - test/cases/connection_test_sqlserver.rb
262
261
  - test/cases/disconnected_test_sqlserver.rb
262
+ - test/cases/eager_load_too_many_ids_test_sqlserver.rb
263
263
  - test/cases/execute_procedure_test_sqlserver.rb
264
264
  - test/cases/fetch_test_sqlserver.rb
265
265
  - test/cases/fully_qualified_identifier_test_sqlserver.rb
@@ -323,8 +323,8 @@ test_files:
323
323
  - test/support/connection_reflection.rb
324
324
  - test/support/core_ext/query_cache.rb
325
325
  - test/support/load_schema_sqlserver.rb
326
- - test/support/marshal_compatibility_fixtures/SQLServer/rails_6_0_topic.dump
327
- - test/support/marshal_compatibility_fixtures/SQLServer/rails_6_0_topic_associations.dump
326
+ - test/support/marshal_compatibility_fixtures/SQLServer/rails_6_1_topic.dump
327
+ - test/support/marshal_compatibility_fixtures/SQLServer/rails_6_1_topic_associations.dump
328
328
  - test/support/minitest_sqlserver.rb
329
329
  - test/support/paths_sqlserver.rb
330
330
  - test/support/rake_helpers.rb
@@ -1,55 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "cases/helper_sqlserver"
4
-
5
- class ActiveSchemaTestSQLServer < ActiveRecord::TestCase
6
- before do
7
- connection.create_table :schema_test_table, force: true, id: false do |t|
8
- t.column :foo, :string, limit: 100
9
- t.column :state, :string
10
- end
11
- end
12
-
13
- after do
14
- connection.drop_table :schema_test_table rescue nil
15
- end
16
-
17
- it 'default index' do
18
- assert_sql('CREATE INDEX [index_schema_test_table_on_foo] ON [schema_test_table] ([foo])') do
19
- connection.add_index :schema_test_table, "foo"
20
- end
21
- end
22
-
23
- it 'unique index' do
24
- assert_sql('CREATE UNIQUE INDEX [index_schema_test_table_on_foo] ON [schema_test_table] ([foo])') do
25
- connection.add_index :schema_test_table, "foo", unique: true
26
- end
27
- end
28
-
29
- it 'where condition on index' do
30
- assert_sql("CREATE INDEX [index_schema_test_table_on_foo] ON [schema_test_table] ([foo]) WHERE state = 'active'") do
31
- connection.add_index :schema_test_table, "foo", where: "state = 'active'"
32
- end
33
- end
34
-
35
- it 'if index does not exist' do
36
- assert_sql("IF NOT EXISTS (SELECT name FROM sysindexes WHERE name = 'index_schema_test_table_on_foo') " \
37
- "CREATE INDEX [index_schema_test_table_on_foo] ON [schema_test_table] ([foo])") do
38
- connection.add_index :schema_test_table, "foo", if_not_exists: true
39
- end
40
- end
41
-
42
- describe "index types" do
43
- it 'clustered index' do
44
- assert_sql('CREATE CLUSTERED INDEX [index_schema_test_table_on_foo] ON [schema_test_table] ([foo])') do
45
- connection.add_index :schema_test_table, "foo", type: :clustered
46
- end
47
- end
48
-
49
- it 'nonclustered index' do
50
- assert_sql('CREATE NONCLUSTERED INDEX [index_schema_test_table_on_foo] ON [schema_test_table] ([foo])') do
51
- connection.add_index :schema_test_table, "foo", type: :nonclustered
52
- end
53
- end
54
- end
55
- end