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
I am trying to set versioning of belongs_to relation between Production and Decision models, both with has_logidze macro. I created a new Production without Decision, then updated Production with a fresh Decision instance, so my production.log_data right now looks like this:
#<Logidze::History:0x0000000126ea54a8
@data=
{"h"=>
[{"c"=>
{"id"=>3,
"date"=>"2023-03-08",
"reason"=>"ble ble ble",
"action_type"=>1,
"production_id"=>3,
"instant_action"=>"la la la"},
"m"=>{"_r"=>37},
"v"=>1,
"ts"=>1678289208579}],
"v"=>1}>
I expect that getting production.at(version:1).decision should give nil, but I am getting same instance of Decision as for production.at(version: 2).decision. Am I missing something?
The text was updated successfully, but these errors were encountered:
The expected behaviour should be similar to the following code:
production=Production.find(42)production_v1=production.at(version: 1)decision_v1=production.decision.at(time: 1678288950545)# the timestamp of the v1 log for production
The decision object has a timestamp equal to 1678289208579 == '2023-03-08 10:26:48 -0500', while 1678288950545 == '2023-03-08 10:22:30 -0500'. So, decision_v1 must be nil.
I think, if you set Logidze.return_self_if_log_data_is_empty = false, it would work as expected.
Probably, we should make this behaviour a default for associations.
Hi,
I am trying to set versioning of belongs_to relation between Production and Decision models, both with
has_logidze
macro. I created a new Production without Decision, then updated Production with a fresh Decision instance, so myproduction.log_data
right now looks like this:and production.decision.log_data
I expect that getting
production.at(version:1).decision
should givenil
, but I am getting same instance of Decision as forproduction.at(version: 2).decision
. Am I missing something?The text was updated successfully, but these errors were encountered: