Skip to content

Commit

Permalink
Fix casting of invalid time values (#1258)
Browse files Browse the repository at this point in the history
  • Loading branch information
aidanharan authored Nov 8, 2024
1 parent f471cd4 commit 27c193c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/active_record/connection_adapters/sqlserver/type/time.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ def quoted(value)

def cast_value(value)
value = super
return if value.blank?

value = value.change year: 2000, month: 01, day: 01
return value unless value.is_a?(::Time)

value = value.change(year: 2000, month: 01, day: 01)
apply_seconds_precision(value)
end

Expand Down

0 comments on commit 27c193c

Please sign in to comment.