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

Adding updated_at to $dontVersionable results in error when calling diff() #56

Open
CamilleScholtz opened this issue Mar 12, 2024 · 9 comments

Comments

@CamilleScholtz
Copy link

I don't really want to track updated_at, so I added it to the $dontVersionable variable in the model, however when calling the diff() method it gives me the following error:

Undefined array key "updated_at"

Full trace can be seen here: https://flareapp.io/share/Lm81QQJP#stack

@overtrue
Copy link
Owner

@mansoorkhan96 Please take a look. thanks.

@mansoorkhan96
Copy link
Contributor

mansoorkhan96 commented Mar 14, 2024

I don't really want to track updated_at, so I added it to the $dontVersionable variable in the model, however when calling the diff() method it gives me the following error:

Undefined array key "updated_at"

Full trace can be seen here: https://flareapp.io/share/Lm81QQJP#stack

Please provide complete code examples to help us help you.

Code examples can help us reproduce the issue.

@mansoorkhan96
Copy link
Contributor

@overtrue Seems like there are two issues with snapshot.

  1. Initial version does not contain any attributes, so its always null
  2. New versions are stored even though the $versionable attributes are not dirty

@mansoorkhan96
Copy link
Contributor

@overtrue I think maybe this is happening because user aaded the DIFF strategy initially but then switched to Snapshot?

So one version which was created using DIFF might have a few attributes and the other one created with Snapshot would ofcourse have all the $versionable attributes. So thats where the diff() method complains about not having attributes in hand.

@mansoorkhan96
Copy link
Contributor

I am able to reproduce.
Its the DIFF strategy which adds non $versionable attributes

@overtrue
Copy link
Owner

@overtrue I think maybe this is happening because user aaded the DIFF strategy initially but then switched to Snapshot?

So one version which was created using DIFF might have a few attributes and the other one created with Snapshot would ofcourse have all the $versionable attributes. So thats where the diff() method complains about not having attributes in hand.

ok, may be we can ignore this, or add some notes in readme.

@mansoorkhan96
Copy link
Contributor

@overtrue I beleive there shouldnt be the DIFF strategy it should only be snapshot. which stores all attributes by default unless you specifiy $versionable.

@overtrue
Copy link
Owner

so, let's drop the strategy feature? ok?

@mansoorkhan96
Copy link
Contributor

@overtrue yes that sounds good. plus a good mechanism to see if the changes are valid to create a new version.

plus some strictness maybe. throw an exception if user is using both properties i.e $versionable and $dontVersionfields. They should be using either of them?

If you want support both then maybe a way to get the intersection of both

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

No branches or pull requests

3 participants