logidze icon indicating copy to clipboard operation
logidze copied to clipboard

Issue with time traveling

Open dixpac opened this issue 1 year ago • 1 comments

Tell us about your environment

Ruby Version: ruby-3.3.5

Rails Version: 8.0.0

PostgreSQL Version: PostgreSQL 14.11 (Postgres.app) on aarch64-apple-darwin20.6.0, compiled by Apple clang version 12.0.5 (clang-1205.0.22.9), 64-bit

Logidze Version: 1.3.1

What did you do?

I'm trying to time-travel base on updated_at, book.at(time: book.updated_at), but I looks like it is not working properly:

Screenshot 2024-12-08 at 12 44 32

It's a simple dummy project User has many Books, here is structure.sql

What did you expect to happen?

When I run book.at(time: book.updated_at) I expect to get the latest version. (v3 in this case)

What actually happened?

I get second_to_last version (v2 in this case)

dixpac avatar Dec 08 '24 11:12 dixpac

Looks like a timestamp precision/rounding issue: the log entry has a timestamp 1733657731644 == 2024-12-08 11:35:31.644, but the updated_at contains a slightly smaller value — 2024-12-08 11:35:31.643674.

That's an interesting use case (and it seems no one tried it before or paid attention to it)—getting the version at the last updated at time (which is supposed to be the current version).

I think, we should at least round the input time information down to milliseconds to match the log entry precision.

palkan avatar Dec 09 '24 19:12 palkan