Skip to content

Commit 27c193c

Browse files
authored
Fix casting of invalid time values (#1258)
1 parent f471cd4 commit 27c193c

File tree

1 file changed

+3
-2
lines changed
  • lib/active_record/connection_adapters/sqlserver/type

1 file changed

+3
-2
lines changed

‎lib/active_record/connection_adapters/sqlserver/type/time.rb

+3-2
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,10 @@ def quoted(value)
3636

3737
def cast_value(value)
3838
value = super
39-
return if value.blank?
4039

41-
value = value.change year: 2000, month: 01, day: 01
40+
return value unless value.is_a?(::Time)
41+
42+
value = value.change(year: 2000, month: 01, day: 01)
4243
apply_seconds_precision(value)
4344
end
4445

0 commit comments

Comments
 (0)