Skip to content

Commit e9dc25a

Browse files
committed
Replace octal values with integers
1 parent 19bf226 commit e9dc25a

File tree

1 file changed

+58
-58
lines changed

1 file changed

+58
-58
lines changed

test/cases/column_test_sqlserver.rb

Lines changed: 58 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,8 @@ def assert_obj_set_and_save(attribute, value)
277277
_(col.sql_type).must_equal "date"
278278
_(col.type).must_equal :date
279279
_(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)
282282
_(col.default_function).must_be_nil
283283
type = connection.lookup_cast_type_from_column(col)
284284
_(type).must_be_instance_of Type::Date
@@ -287,22 +287,22 @@ def assert_obj_set_and_save(attribute, value)
287287
_(type.scale).must_be_nil
288288
# Can cast strings. SQL Server format.
289289
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)
291291
obj.save!
292-
_(obj.date).must_equal Date.civil(0001, 4, 1)
292+
_(obj.date).must_equal Date.civil(1, 4, 1)
293293
obj.reload
294-
_(obj.date).must_equal Date.civil(0001, 4, 1)
294+
_(obj.date).must_equal Date.civil(1, 4, 1)
295295
# Can cast strings. ISO format.
296296
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)
298298
obj.save!
299-
_(obj.date).must_equal Date.civil(0001, 4, 1)
299+
_(obj.date).must_equal Date.civil(1, 4, 1)
300300
obj.reload
301-
_(obj.date).must_equal Date.civil(0001, 4, 1)
301+
_(obj.date).must_equal Date.civil(1, 4, 1)
302302
# Can filter by date range
303303
_(obj).must_equal obj.class.where(date: obj.date..Date::Infinity.new).first
304304
# 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)
306306
# Can accept and cast time objects.
307307
obj.date = Time.utc(2010, 4, 14, 12, 34, 56, 3000)
308308
_(obj.date).must_equal Date.civil(2010, 4, 14)
@@ -315,7 +315,7 @@ def assert_obj_set_and_save(attribute, value)
315315
_(col.sql_type).must_equal "datetime"
316316
_(col.type).must_equal :datetime
317317
_(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
319319
_(col.default).must_equal time, "Microseconds were <#{col.default.usec}> vs <123000>"
320320
_(obj.datetime).must_equal time, "Microseconds were <#{obj.datetime.usec}> vs <123000>"
321321
_(col.default_function).must_be_nil
@@ -327,7 +327,7 @@ def assert_obj_set_and_save(attribute, value)
327327
obj.save!
328328
_(obj).must_equal obj.class.where(datetime: time).first
329329
# 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
331331
obj.datetime = time
332332
_(obj.datetime).must_equal time, "Microseconds were <#{obj.datetime.usec}> vs <3000>"
333333
obj.save!
@@ -338,8 +338,8 @@ def assert_obj_set_and_save(attribute, value)
338338
# Can filter by datetime range
339339
_(obj).must_equal obj.class.where(datetime: time..DateTime::Infinity.new).first
340340
# 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
343343
obj.datetime = time
344344
_(obj.datetime).must_equal time2, "Microseconds were <#{obj.datetime.usec}> vs <233000>"
345345
obj.save!
@@ -427,21 +427,21 @@ def assert_obj_set_and_save(attribute, value)
427427
_(col.sql_type).must_equal "datetimeoffset(7)"
428428
_(col.type).must_equal :datetimeoffset
429429
_(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>"
432432
_(col.default_function).must_be_nil
433433
type = connection.lookup_cast_type_from_column(col)
434434
_(type).must_be_instance_of Type::DateTimeOffset
435435
_(type.limit).must_be_nil
436436
_(type.precision).must_equal 7
437437
_(type.scale).must_be_nil
438438
# 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>"
441441
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>"
443443
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>"
445445
# Maintains the timezone
446446
time = ActiveSupport::TimeZone["America/Los_Angeles"].local 2010, 12, 31, 23, 59, 59, Rational(123456800, 1000)
447447
obj.datetimeoffset_7 = time
@@ -470,21 +470,21 @@ def assert_obj_set_and_save(attribute, value)
470470
_(col.sql_type).must_equal "smalldatetime"
471471
_(col.type).must_equal :smalldatetime
472472
_(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)
475475
_(col.default_function).must_be_nil
476476
type = connection.lookup_cast_type_from_column(col)
477477
_(type).must_be_instance_of Type::SmallDateTime
478478
_(type.limit).must_be_nil
479479
_(type.precision).must_be_nil
480480
_(type.scale).must_be_nil
481481
# 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>"
484484
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>"
486486
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>"
488488
end
489489

490490
it "time(7)" do
@@ -493,30 +493,30 @@ def assert_obj_set_and_save(attribute, value)
493493
_(col.sql_type).must_equal "time(7)"
494494
_(col.type).must_equal :time
495495
_(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>"
497497
_(col.default_function).must_be_nil
498498
type = connection.lookup_cast_type_from_column(col)
499499
_(type).must_be_instance_of Type::Time
500500
_(type.limit).must_be_nil
501501
_(type.precision).must_equal 7
502502
_(type.scale).must_be_nil
503503
# 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>"
507507
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>"
510510
# 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>"
513513
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>"
515515
# 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>"
518518
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>"
520520
end
521521

522522
it "time(2)" do
@@ -533,20 +533,20 @@ def assert_obj_set_and_save(attribute, value)
533533
_(type.precision).must_equal 2
534534
_(type.scale).must_be_nil
535535
# 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)
538538
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)
540540
# 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>"
543543
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>"
545545
# 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>"
548548
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>"
550550
end
551551

552552
it "time using default precision" do
@@ -555,30 +555,30 @@ def assert_obj_set_and_save(attribute, value)
555555
_(col.sql_type).must_equal "time(7)"
556556
_(col.type).must_equal :time
557557
_(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>"
559559
_(col.default_function).must_be_nil
560560
type = connection.lookup_cast_type_from_column(col)
561561
_(type).must_be_instance_of Type::Time
562562
_(type.limit).must_be_nil
563563
_(type.precision).must_equal 7
564564
_(type.scale).must_be_nil
565565
# 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>"
569569
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>"
572572
# 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>"
575575
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>"
577577
# 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>"
580580
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>"
582582
end
583583

584584
# Character Strings

0 commit comments

Comments
 (0)