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

Added additional checks to the TestUpdateCollection #33

Merged
merged 3 commits into from
Apr 20, 2022

Conversation

segfault99
Copy link
Contributor

Hello. Current TestUpdateCollection test does not detect if the update operation modifies other fields in the document, so my tests were passing albeit update function was deleting all other fields those are not in updateMap. I forgot to add this on my previous pull request.

@ostafen
Copy link
Owner

ostafen commented Apr 20, 2022

Thank you, this is a good idea. While we are at it, I would make the check not only for a single document, but for each document matching the criteria.
That is to say, before calling Update, you call:

docs, err := db.Query("todos").Where(criteria).FindAll()

Then, after doing the Update, you retrieve each updated document by repeatedly performing following query (iterating on the docs slice):

updatedDoc, err := db.Query("todos").Where(c.Field("id").Eq(doc.Get("id"))).FindFirst()

What do you think? This should be even more robust :=)

@segfault99
Copy link
Contributor Author

segfault99 commented Apr 20, 2022

Yes it will be even better.

@ostafen ostafen merged commit afe84f2 into ostafen:main Apr 20, 2022
@ostafen
Copy link
Owner

ostafen commented Apr 20, 2022

@segfault99, thank you. If you have any suggestion about features you would like to see in clover, join our gitter channel, or simply open an issue :=)

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

Successfully merging this pull request may close these issues.

2 participants