-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Range of dates with infinite end are stored incorrectly in Postgres database #51745
Comments
Duplicate/Related to #51111? |
Not really, that is about how data is read back from the database and the change that unbounded values now comes back as This is about what how the data is going into the database. When a boundless end is sent to PostgreSQL it is sent as It is possible that this could be considered a PostgreSQL problem too, because From what I can tell, the value that goes into the database has to be modified from |
It's inserting as Looks like we have to be explicit with the |
Exactly, that is true, they will convert like that, but if inserting the upper bound as
Make the same change while investigating this and to see if I could figure out a good solution, but I also quickly arrived to "special case land". But since this is a very specific case in just related to the postgres adapter maybe that can work anyway. I haven't yet been able to come up with a clean enough solution, got stuck with range value validation as this becomes a range with a mix of types dates and strings and it got even more into special case land 😃 Not sure if it at this point worth to put up a work in progress PR that we can discuss around and if that is an acceptable way of working with this to move foward. This is the first time I'm digging this deep into rails code. Fun stuff! 😄 |
What do you think about this? main...justinko:rails:issue-51745 |
In Rails 7.1.3 date ranges with unbounded end is stored incorrectly when the end is included and it is i stored with excluded end.
Steps to reproduce
(Date.today..)
and save it(Date.today...)
☝️ These assertions fails btw, except in
test_direct_insert
that all pass.Expected behavior
To save the range including unbounded end as it was specified.
Actual behavior
Range is saved in database excluding end and when it's read back into rails it is not the same value.
System configuration
Rails version:
7.1.3
Ruby version:
ruby 3.2.3 (2024-01-18 revision 52bb2ac0a6) [arm64-darwin23]
The text was updated successfully, but these errors were encountered: