Skip to content
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

Remove custom tsrange parser #268

Merged
merged 1 commit into from
Feb 27, 2024
Merged

Conversation

tagliala
Copy link
Member

@tagliala tagliala commented Feb 22, 2024

This commit removes the custom tsrange parser implemented in
Chronomodel in favor of the standard Rails tsrange parser.

Implementation:

Motivation:

Considerations:

  • Applications relying on validity.last might require migration
    strategies due to open-ended ranges.

Benefits:

  • Simplified codebase
  • Enhanced Rails compatibility
  • Future-proofed against potential API changes

Close #269

Ref:

@tagliala tagliala force-pushed the feature/267-remove-tsrange-override branch from 489a4fb to 545fbbf Compare February 22, 2024 16:03
@tagliala tagliala force-pushed the feature/267-remove-tsrange-override branch from 545fbbf to 47e8585 Compare February 22, 2024 16:19
@tagliala tagliala changed the title [WIP] Remove TS Range override Remove custom TSRange parser Feb 23, 2024
@tagliala tagliala marked this pull request as ready for review February 23, 2024 11:47
@tagliala tagliala force-pushed the feature/267-remove-tsrange-override branch from 47e8585 to b6db434 Compare February 23, 2024 11:48
@tagliala tagliala marked this pull request as draft February 26, 2024 11:07
@tagliala
Copy link
Member Author

tagliala commented Feb 26, 2024

Time-zone awareness on tsrange

# config/application.rb
ActiveRecord::Base.time_zone_aware_types += [:tsrange]

Before:

> Activity.last.history.first.validity
NoMethodError: undefined method `begin' for [2024-01-05 14:40:18.656918 UTC, 2024-01-05 14:40:29.405929 UTC]:Array
from ./activerecord-7.0.8.1/lib/active_record/connection_adapters/postgresql/oid/range.rb:51:in `map'

After removal of custom parser:

> Activity.last.history.first.validity
=> Fri, 05 Jan 2024 15:40:18.656918000 CET +01:00...Fri, 05 Jan 2024 15:40:29.405929000 CET +01:00

@tagliala tagliala force-pushed the feature/267-remove-tsrange-override branch from 0d559ef to 061ebd2 Compare February 26, 2024 11:33
@tagliala tagliala changed the title Remove custom TSRange parser Remove custom tsrange parser Feb 26, 2024
This commit removes the custom `tsrange` parser implemented in
Chronomodel in favor of the standard Rails `tsrange` parser.

Implementation:
- To maintain compatibility with Rails 7.0, continue returning `nil`
  instead of Infinity values, preserving the existing behavior of
  `valid_from` and `valid_to`. Ref: rails/rails#45099
- Bump major version because this is a potential breaking change

Motivation:
- Resolved dependencies:
  - Ruby 2.6+ now supports open-ended ranges, addressing the limitation
    in https://bugs.ruby-lang.org/issues/6864
  - Rails `tsrange` stability issues in rails/rails#13793 and
    rails/rails#14010
- Standardized usage:
  - Aligns Chronomodel with Rails conventions, improving compatibility
    and reducing code complexity.
  - Allow to add `tsrange` to `ActiveRecord::Base.time_zone_aware_types`
- Leverage official API:
  - Accesses potential future improvements and bug fixes in the standard
    `tsrange`.

Considerations:
- Applications relying on `validity.last` might require migration
  strategies due to open-ended ranges.

Benefits:
- Simplified codebase
- Enhanced Rails compatibility
- Future-proofed against potential API changes

Close #269

Ref:
- rails/rails#45099
@tagliala tagliala force-pushed the feature/267-remove-tsrange-override branch from 061ebd2 to fffafa5 Compare February 26, 2024 11:49
@tagliala tagliala marked this pull request as ready for review February 27, 2024 08:07
@tagliala tagliala merged commit b9fbfe7 into master Feb 27, 2024
13 of 14 checks passed
@tagliala tagliala deleted the feature/267-remove-tsrange-override branch February 27, 2024 08:12
tagliala added a commit that referenced this pull request Feb 27, 2024
This method was used in features that were removed (#268 and #271) and
the reason for converting ts values selected from the timeline query
is not explicitly documented in the commit history and appears to
be redundant (they are already timestamps)
tagliala added a commit that referenced this pull request Feb 27, 2024
This method was used in features that were removed (#268 and #271) and
the reason for converting ts values selected from the timeline query
is not explicitly documented in the commit history and appears to
be redundant (they are already timestamps)

After conducting manual tests on the `usec`s, it was determined that
the issue reported in issue #32 is no longer valid.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove the custom TSRange
3 participants