Comments (6)
Duplicate/Related to #51111?
from rails.
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 nil
where the before Rails 7.1 came back as Float::INFINITY
, which I think is a change to the better.
This is about what how the data is going into the database. When a boundless end is sent to PostgreSQL it is sent as nil
which in PostgreSQL will be stored as an excluded end, but if it is sent as infinity
it will be stored as inclusive, and be returned as such.
It is possible that this could be considered a PostgreSQL problem too, because range = ["2024-01-01 00:00",infinity]
could be the same as range = ["2024-01-01 00:00",]
, but the latter is saved as ["2024-01-01 00:00",)
.
From what I can tell, the value that goes into the database has to be modified from nil
, to string infinity
. But I could be wrong.
from rails.
It's inserting as "[2024-01-01 00:00:00,]"
, and it looks like Postgres will convert it to "[2024-01-01 00:00:00,)"
(exclusive).
Looks like we have to be explicit with the infinity
.
from rails.
All of these ranges in your test case:
# range = (@time..Float::INFINITY)
# range = (@time..DateTime::Infinity.new)
# range = (@time..Date::Infinity.new)
Will pass with this change:
I'm still investigating if this change is the right approach ... haven't even run the rails tests yet.
If we detect if the range is a date/time range, then we could have (@time..)
with infinity
... but then you get into "special case land" and I'm not sure that's a path to go down.
from rails.
It's inserting as
"[2024-01-01 00:00:00,]"
, and it looks like Postgres will convert it to"[2024-01-01 00:00:00,)"
(exclusive).Looks like we have to be explicit with the
infinity
.
Exactly, that is true, they will convert like that, but if inserting the upper bound as infinity
will give a more expected result (imo).
I'm still investigating if this change is the right approach ... haven't even run the rails tests yet.
If we detect if the range is a date/time range, then we could have (@time..) with infinity ... but then you get into "special case land" and I'm not sure that's a path to go down.
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! 😄
from rails.
What do you think about this? main...justinko:rails:issue-51745
from rails.
Related Issues (20)
- rails restart doesn't work with puma HOT 3
- Missing documentation for "fixture" method
- [Rails 7.1.3.2] Invalid CSRF Token when submitting a form with data-turbo="false" when Turbo Drive is enabled HOT 2
- [ActiveRecord::Encryption] ignores key_provider in with_encryption_context HOT 4
- [Rails 6.1] Rails 6.1 vulerable to CVE-2024-34341 (trix and actiontext) HOT 1
- The password field is ignored when I use fetch or require #52010 HOT 1
- [Guides Enhancement] Add Search using Algolia or similar
- Database references and ActiveRecord references not match HOT 3
- Would be nice to be able to specify a table to use for `references` columns when generating a migration HOT 3
- Inconsistent charset case in redirect content type HOT 3
- The `select` method in [ActiveRecord] is producing incorrect results with PostgreSQL. HOT 6
- ActiveModel::Attributes API with a dynamic default appears to re-use values across instances HOT 3
- Chaining where clauses in scopes, behaving differently in rails 7.1 -- Is using merge required now? HOT 2
- railties tests get NoMethodError: undefined method `deprecator' with sprockets-rails 3.5.0 HOT 2
- ConnectionPool leak connections HOT 5
- rescue_from ActiveRecord::DeleteRestrictionError - uninitialized constant with eager load enabled HOT 10
- `PG::IndeterminateDatatype` on Rails 7.2 betas HOT 2
- `includes` loads wrong data for scoped `has_many :through` Association when eager loading nested self join
- Proposal of `Rails.application.message_encryptors` as centralized registry of MessageEncryptor and improved encryption/decryption UX HOT 1
- `RenderStreaming::StreamingTest` fail with since https://github.com/rack/rack/pull/2195 HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rails.