@@ -349,7 +349,7 @@ def assert_obj_set_and_save(attribute, value)
349
349
end
350
350
351
351
it 'datetime2' do
352
- skip 'datetime2 not supported in this protocal version' unless connection_dblib_73?
352
+ skip 'datetime2 not supported in this protocol version' unless connection_dblib_73?
353
353
col = column ( 'datetime2_7' )
354
354
_ ( col . sql_type ) . must_equal 'datetime2(7)'
355
355
_ ( col . type ) . must_equal :datetime
@@ -414,7 +414,7 @@ def assert_obj_set_and_save(attribute, value)
414
414
end
415
415
416
416
it 'datetimeoffset' do
417
- skip 'datetimeoffset not supported in this protocal version' unless connection_dblib_73?
417
+ skip 'datetimeoffset not supported in this protocol version' unless connection_dblib_73?
418
418
col = column ( 'datetimeoffset_7' )
419
419
_ ( col . sql_type ) . must_equal 'datetimeoffset(7)'
420
420
_ ( col . type ) . must_equal :datetimeoffset
@@ -480,7 +480,7 @@ def assert_obj_set_and_save(attribute, value)
480
480
end
481
481
482
482
it 'time(7)' do
483
- skip 'time() not supported in this protocal version' unless connection_dblib_73?
483
+ skip 'time() not supported in this protocol version' unless connection_dblib_73?
484
484
col = column ( 'time_7' )
485
485
_ ( col . sql_type ) . must_equal 'time(7)'
486
486
_ ( col . type ) . must_equal :time
@@ -512,7 +512,7 @@ def assert_obj_set_and_save(attribute, value)
512
512
end
513
513
514
514
it 'time(2)' do
515
- skip 'time() not supported in this protocal version' unless connection_dblib_73?
515
+ skip 'time() not supported in this protocol version' unless connection_dblib_73?
516
516
col = column ( 'time_2' )
517
517
_ ( col . sql_type ) . must_equal 'time(2)'
518
518
_ ( col . type ) . must_equal :time
@@ -541,6 +541,38 @@ def assert_obj_set_and_save(attribute, value)
541
541
_ ( obj . time_2 ) . must_equal Time . utc ( 2000 , 01 , 01 , 15 , 45 , 00 , 0 ) , "Microseconds were <#{ obj . time_2 . usec } > vs <0>"
542
542
end
543
543
544
+ it 'time using default precision' do
545
+ skip 'time() not supported in this protocol version' unless connection_dblib_73?
546
+ col = column ( 'time_default' )
547
+ _ ( col . sql_type ) . must_equal 'time(7)'
548
+ _ ( col . type ) . must_equal :time
549
+ _ ( col . null ) . must_equal true
550
+ _ ( col . default ) . must_equal Time . utc ( 1900 , 01 , 01 , 15 , 03 , 42 , Rational ( 62197800 , 1000 ) ) , "Nanoseconds were <#{ col . default . nsec } > vs <62197800>"
551
+ _ ( col . default_function ) . must_be_nil
552
+ type = connection . lookup_cast_type_from_column ( col )
553
+ _ ( type ) . must_be_instance_of Type ::Time
554
+ _ ( type . limit ) . must_be_nil
555
+ _ ( type . precision ) . must_equal 7
556
+ _ ( type . scale ) . must_be_nil
557
+ # Time's #usec precision (low micro)
558
+ obj . time_default = Time . utc ( 2000 , 01 , 01 , 15 , 45 , 00 , 300 )
559
+ _ ( obj . time_default ) . must_equal Time . utc ( 2000 , 01 , 01 , 15 , 45 , 00 , 300 ) , "Microseconds were <#{ obj . time_default . usec } > vs <0>"
560
+ _ ( obj . time_default ) . must_equal Time . utc ( 2000 , 01 , 01 , 15 , 45 , 00 , 300 ) , "Nanoseconds were <#{ obj . time_default . nsec } > vs <300>"
561
+ obj . save! ; obj . reload
562
+ _ ( obj . time_default ) . must_equal Time . utc ( 2000 , 01 , 01 , 15 , 45 , 00 , 300 ) , "Microseconds were <#{ obj . time_default . usec } > vs <0>"
563
+ _ ( obj . time_default ) . must_equal Time . utc ( 2000 , 01 , 01 , 15 , 45 , 00 , 300 ) , "Nanoseconds were <#{ obj . time_default . nsec } > vs <300>"
564
+ # Time's #usec precision (high micro)
565
+ obj . time_default = Time . utc ( 2000 , 01 , 01 , 15 , 45 , 00 , 234567 )
566
+ _ ( obj . time_default ) . must_equal Time . utc ( 2000 , 01 , 01 , 15 , 45 , 00 , 234567 ) , "Microseconds were <#{ obj . time_default . usec } > vs <234567>"
567
+ obj . save! ; obj . reload
568
+ _ ( obj . time_default ) . must_equal Time . utc ( 2000 , 01 , 01 , 15 , 45 , 00 , 234567 ) , "Microseconds were <#{ obj . time_default . usec } > vs <234567>"
569
+ # Time's #usec precision (high nano rounded)
570
+ obj . time_default = Time . utc ( 2000 , 01 , 01 , 15 , 45 , 00 , Rational ( 288321545 , 1000 ) )
571
+ _ ( obj . time_default ) . must_equal Time . utc ( 2000 , 01 , 01 , 15 , 45 , 00 , Rational ( 288321500 , 1000 ) ) , "Nanoseconds were <#{ obj . time_default . nsec } > vs <288321500>"
572
+ obj . save! ; obj . reload
573
+ _ ( obj . time_default ) . must_equal Time . utc ( 2000 , 01 , 01 , 15 , 45 , 00 , Rational ( 288321500 , 1000 ) ) , "Nanoseconds were <#{ obj . time_default . nsec } > vs <288321500>"
574
+ end
575
+
544
576
# Character Strings
545
577
546
578
it 'char(10)' do
0 commit comments