You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This prevents pred and succ to be computed properly.
In the following example, I'm trying to fetch the most recent history record and its predecessor, but the pred method fails as it returns nil.
record=MyModel.find(123)# got the recordmost_recent=record.history.last# got the history recordmost_recent.valid_from.usec# => 129625most_recent.pred# => nil
In order to check that a predecessor actually exists, I computed it "manually" like this:
This way, I got the history record and then I checked its valid_to's microseconds:
computed_pred.valid_to.usec# => 129625
On the Ruby side, it is the same as most_recent record's valid_from. Where's the issue then? I checked on the PG side by executing the following query:
select validity fromhistory.my_tablewhere id=123order by recorded_at;
As you can see, microseconds differ in their last digit.
What happened?
Chronomodel was able to fetch the most_recent record because it doesn't use any timestamp in that query's conditions. But, when asking for most_recent.pred it passes most_recent.valid_from to Chronomodel::Conversions#time_to_utc_string in order to build the query condition, so '2017-02-06 09:46:31.129625' is passed to PG, and then no results are returned.
I am on the improve-amend-period branch with Ruby 2.3.3, PostgreSQL 9.4.9 and am using:
activerecord (5.0.1)
pg (0.19.0)
The text was updated successfully, but these errors were encountered:
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.
Seems like Time#usec used in Chronomodel::Conversions#time_to_utc_string sometimes returns a different number than the one actually stored in PG.
This prevents
pred
andsucc
to be computed properly.In the following example, I'm trying to fetch the most recent history record and its predecessor, but the
pred
method fails as it returnsnil
.In order to check that a predecessor actually exists, I computed it "manually" like this:
This way, I got the history record and then I checked its
valid_to
's microseconds:On the Ruby side, it is the same as
most_recent
record'svalid_from
. Where's the issue then? I checked on the PG side by executing the following query:and I got a result like this:
As you can see, microseconds differ in their last digit.
What happened?
Chronomodel was able to fetch the
most_recent
record because it doesn't use any timestamp in that query's conditions. But, when asking formost_recent.pred
it passesmost_recent.valid_from
toChronomodel::Conversions#time_to_utc_string
in order to build the query condition, so'2017-02-06 09:46:31.129625'
is passed to PG, and then no results are returned.I am on the improve-amend-period branch with Ruby 2.3.3, PostgreSQL 9.4.9 and am using:
The text was updated successfully, but these errors were encountered: