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

Explicitly disallow duplicate keys in data documents #1293

Merged

Conversation

rumyantseva
Copy link
Member

@rumyantseva rumyantseva commented Oct 20, 2022

Description

Closes #364.

As agreed with the team, quite a big refactoring was made. Now types.Document's internal representation consists of a slice of fields where each field has a string field and any value.
That approach allows having duplicated keys in documents in principle.

However, Document.ValidateData checks that there are no duplicates.

Minor refactoring: Document.Set's signature doesn't return error anymore, as, in fact, the implementation always returns nil. With that, there is no need to make the code more complicated (with all the checks for errors).

Readiness checklist

  • I added tests for new functionality or bugfixes.
  • I ran task all, and it passed.
  • I added/updated comments for both exported and unexported top-level declarations (functions, types, etc).
  • I checked comments rendering with task godocs.
  • I ensured that the title is good enough for the changelog.
  • (for maintainers only) I set Reviewers (@FerretDB/core), Assignee, Labels, Project and project's Sprint fields.
  • I marked all done items in this checklist.

@rumyantseva rumyantseva self-assigned this Oct 20, 2022
@rumyantseva rumyantseva added the code/feature Some user-visible feature is not implemented yet label Oct 20, 2022
@codecov
Copy link

codecov bot commented Oct 20, 2022

Codecov Report

Merging #1293 (0d5e4bb) into main (38b30b5) will increase coverage by 0.09%.
The diff coverage is 85.27%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1293      +/-   ##
==========================================
+ Coverage   67.31%   67.40%   +0.09%     
==========================================
  Files         276      276              
  Lines       13024    13021       -3     
==========================================
+ Hits         8767     8777      +10     
+ Misses       3337     3325      -12     
+ Partials      920      919       -1     
Impacted Files Coverage Δ
internal/handlers/tigris/msg_getparameter.go 0.00% <0.00%> (ø)
internal/util/version/version.go 48.52% <0.00%> (-4.42%) ⬇️
internal/handlers/tigris/msg_findandmodify.go 53.23% <60.00%> (ø)
internal/handlers/tigris/msg_update.go 51.63% <60.00%> (+0.31%) ⬆️
internal/types/document_validation.go 86.48% <84.61%> (-6.62%) ⬇️
internal/types/document.go 88.04% <88.40%> (+0.69%) ⬆️
internal/handlers/common/update.go 87.38% <93.75%> (+3.63%) ⬆️
internal/handlers/common/error.go 80.34% <100.00%> (ø)
internal/handlers/common/projection.go 64.37% <100.00%> (ø)
internal/handlers/common/serverstatus.go 86.95% <100.00%> (ø)
... and 25 more
Flag Coverage Δ
integration 63.31% <81.59%> (+0.09%) ⬆️
mongodb 14.19% <30.67%> (+0.06%) ⬆️
pg 52.86% <76.68%> (+0.12%) ⬆️
tigris 34.68% <58.89%> (+0.10%) ⬆️
unit 25.60% <53.37%> (+0.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

@vercel
Copy link

vercel bot commented Oct 20, 2022

Deployment failed with the following error:

Resource is limited - try again in 18 minutes (more than 100, code: "api-deployments-free-per-day").

@vercel
Copy link

vercel bot commented Oct 20, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
ferret-db ✅ Ready (Inspect) Visit Preview Oct 25, 2022 at 0:46AM (UTC)

@vercel vercel bot temporarily deployed to Preview October 20, 2022 20:58 Inactive
@vercel vercel bot temporarily deployed to Preview October 20, 2022 21:42 Inactive
@vercel vercel bot temporarily deployed to Preview October 20, 2022 22:23 Inactive
@vercel vercel bot temporarily deployed to Preview October 20, 2022 22:28 Inactive
@rumyantseva rumyantseva marked this pull request as ready for review October 20, 2022 22:33
@rumyantseva rumyantseva requested a review from a team as a code owner October 20, 2022 22:33
@rumyantseva rumyantseva requested review from AlekSi, w84thesun, a team, chilagrow and noisersup and removed request for a team October 20, 2022 22:33
@rumyantseva rumyantseva added the do not merge PRs that should not be merged label Oct 20, 2022
Copy link
Contributor

@chilagrow chilagrow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for great refactor too 💪

internal/types/document_validation.go Show resolved Hide resolved
internal/types/document.go Outdated Show resolved Hide resolved
@vercel vercel bot temporarily deployed to Preview October 21, 2022 09:46 Inactive
@vercel vercel bot temporarily deployed to Preview October 21, 2022 10:26 Inactive
@vercel vercel bot temporarily deployed to Preview October 24, 2022 07:56 Inactive
@vercel vercel bot temporarily deployed to Preview October 24, 2022 08:13 Inactive
@vercel vercel bot temporarily deployed to Preview October 24, 2022 09:06 Inactive
@vercel vercel bot temporarily deployed to Preview October 24, 2022 10:41 Inactive
@vercel vercel bot temporarily deployed to Preview October 24, 2022 11:45 Inactive
@vercel vercel bot temporarily deployed to Preview October 24, 2022 14:54 Inactive
@rumyantseva
Copy link
Member Author

@w84thesun, answering your questions about testing duplicates. Unfortunately, currently, such tests would fail because of #1263. I added a test with skip comment.

@vercel vercel bot temporarily deployed to Preview October 24, 2022 16:48 Inactive
@rumyantseva rumyantseva enabled auto-merge (squash) October 24, 2022 16:57
@vercel vercel bot temporarily deployed to Preview October 24, 2022 17:01 Inactive
@vercel vercel bot temporarily deployed to Preview October 25, 2022 00:46 Inactive
@rumyantseva rumyantseva merged commit 552683e into FerretDB:main Oct 25, 2022
@rumyantseva rumyantseva deleted the issue-264-disallow-duplicate-keys branch October 25, 2022 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code/feature Some user-visible feature is not implemented yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Explicitly disallow duplicate keys in data documents
5 participants