Skip to content

Skip persisting empty commits (with 0 snapshots) in SQL repository #505

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

Closed
mdii opened this issue Mar 1, 2017 · 11 comments
Closed

Skip persisting empty commits (with 0 snapshots) in SQL repository #505

mdii opened this issue Mar 1, 2017 · 11 comments

Comments

@mdii
Copy link
Contributor

mdii commented Mar 1, 2017

Hi,

I am using JaVers 3.0.0 with Spring Boot. I noticed that new entries are stored in jv_commit even when there is no change in the object. Since these commits are not referenced from other tables, they are kind of useless.

@bartoszwalacik
Copy link
Member

Hi, please follow the https://github.com/javers/javers/blob/master/CONTRIBUTING.md

Bug Reports have to contain:

- Clear description of your expectations versus reality
- Runnable test case which isolates the bug and allows us to easily reproduce it on our laptops. You can push this test case to your fork of this repository.

@mdii
Copy link
Contributor Author

mdii commented Mar 6, 2017

As you can see in the following example, the second commit creates an entry in jv_commit and no entries in jv_snapshots. When we auto-audit repositories this leads to a lot of entries in jv_commit that are not referenced from other tables because usually we don't check if the entity has been updated before calling repository.save(entity).

Javers javers = JaversBuilder.javers().build();
Person robert = new Person("bob", "Robert Martin");
javers.commit("user", robert); 

//creates an entry in jv_commit even though nothing has changed on the object
javers.commit("user", robert); 

The expected behavior would be that commits are persisted only when the commit has snapshots.

Sorry, I couldn't come up with a runnable test case.

@bartoszwalacik
Copy link
Member

You mean this is not OK that empty commits are persisted?

@mdii
Copy link
Contributor Author

mdii commented Mar 8, 2017

Yes, exactly.

@bartoszwalacik
Copy link
Member

Feel free to create a pull request. This issue is easy to implement so perfect for contribution.

@bartoszwalacik bartoszwalacik changed the title New commit entries even when nothing has changed Skip persisting empty commits in SQL repository (with 0 snapshots) Mar 9, 2017
@bartoszwalacik bartoszwalacik changed the title Skip persisting empty commits in SQL repository (with 0 snapshots) Skip persisting empty commits (with 0 snapshots) in SQL repository Mar 9, 2017
@mdii
Copy link
Contributor Author

mdii commented Mar 10, 2017

I can create a pull request.
Should this be applied only to SQL repository or to all repositories?

@bartoszwalacik
Copy link
Member

PR should be created from your fork. Looks like the problem could be solved in javerscore, before calling JaversRepository

mdii added a commit to mdii/javers that referenced this issue Mar 12, 2017
mdii added a commit to mdii/javers that referenced this issue Mar 12, 2017
@bartoszwalacik
Copy link
Member

PR merged to master

@bartoszwalacik
Copy link
Member

@mdii your commits are not bounded to your user. If you fix it, you will be listed on javers.org as a contributor

d81eb3c

@mdii
Copy link
Contributor Author

mdii commented Mar 13, 2017

It's done, thanks!

@bartoszwalacik
Copy link
Member

released in 3.0.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants