(required) Please include any relevant details about this Pull Request, with a focus on:
What does it fix.
Different times being considered equal.
ApplicationRecord.connection.execute("CREATE TABLE models (id UUID, my_date TIMESTAMP)")
class Model < ApplicationRecord
validates :my_date, date: { equal_to: ->(model) { model.my_date.end_of_day } }
end
model = Model.new
model.my_date = Time.current.end_of_day.change(usec: 0)
model.valid? # true
model.my_date == model.my_date.end_of_day # false
Why did you do things this way.
The previous implementation used .to_i to compare dates, this lead to a bug where a model would pass validation without actually being valid.
How does it fix the issue at hand.
Just changed the implementation to compare dates without .to_i
✍️ Description
(required) Please include any relevant details about this Pull Request, with a focus on:
Why did you do things this way. The previous implementation used .to_i to compare dates, this lead to a bug where a model would pass validation without actually being valid.
How does it fix the issue at hand. Just changed the implementation to compare dates without .to_i
Based on the test suite, it looks fine.