@@ -349,7 +349,7 @@ def assert_obj_set_and_save(attribute, value)
349349 end
350350
351351 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?
353353 col = column ( 'datetime2_7' )
354354 _ ( col . sql_type ) . must_equal 'datetime2(7)'
355355 _ ( col . type ) . must_equal :datetime
@@ -414,7 +414,7 @@ def assert_obj_set_and_save(attribute, value)
414414 end
415415
416416 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?
418418 col = column ( 'datetimeoffset_7' )
419419 _ ( col . sql_type ) . must_equal 'datetimeoffset(7)'
420420 _ ( col . type ) . must_equal :datetimeoffset
@@ -480,7 +480,7 @@ def assert_obj_set_and_save(attribute, value)
480480 end
481481
482482 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?
484484 col = column ( 'time_7' )
485485 _ ( col . sql_type ) . must_equal 'time(7)'
486486 _ ( col . type ) . must_equal :time
@@ -512,7 +512,7 @@ def assert_obj_set_and_save(attribute, value)
512512 end
513513
514514 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?
516516 col = column ( 'time_2' )
517517 _ ( col . sql_type ) . must_equal 'time(2)'
518518 _ ( col . type ) . must_equal :time
@@ -541,6 +541,38 @@ def assert_obj_set_and_save(attribute, value)
541541 _ ( obj . time_2 ) . must_equal Time . utc ( 2000 , 01 , 01 , 15 , 45 , 00 , 0 ) , "Microseconds were <#{ obj . time_2 . usec } > vs <0>"
542542 end
543543
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+
544576 # Character Strings
545577
546578 it 'char(10)' do
0 commit comments