[proposal]When bitemporal_at exists inside the nest, the specified date was not prioritized, so the date of the inner bitemporal_at is now prioritized.#121
Merged
bonobono555 merged 3 commits intokufu:masterfrom Feb 28, 2023
Conversation
… prioritized, so the date of the inner bitemporal_at is now prioritized.
wata727
reviewed
Feb 21, 2023
lib/activerecord-bitemporal/scope.rb
Outdated
|
|
||
| if !ActiveRecord::Bitemporal.ignore_valid_datetime? | ||
| relation = relation.valid_at(ActiveRecord::Bitemporal.valid_datetime || datetime) | ||
| relation = relation.valid_at(datetime || ActiveRecord::Bitemporal.valid_datetime || Time.current) |
Contributor
There was a problem hiding this comment.
Calling Time.current on valid time and transaction time respectively can give different results in milliseconds. Is it better to use the same time? e.g.
current_time = Time.current
if !ActiveRecord::Bitemporal.ignore_transaction_datetime?
relation = relation.transaction_at(datetime || ActiveRecord::Bitemporal.transaction_datetime || current_time)
end
if !ActiveRecord::Bitemporal.ignore_valid_datetime?
relation = relation.valid_at(datetime || ActiveRecord::Bitemporal.valid_datetime || current_time)
end
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
I think it's unnatural that the given date is not given priority when
bitemporal_atexists inside the nest, and I want to give priority to the date of the innerbitemporal_atreason
valid_atandtransaction_atbehave to give priority to the inner date, butbitemporal_atdoes not give priority to the inner date, so I thought it would be more natural to matchvalid_atandtransaction_at.ex. inner
valid_attakes precedencebitemporal_at before
bitemporal_atdoes not take precedencebitemporal_at after
bitemporal_attakes precedence