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

Fix _id restriction in aggregation $project stage #3508

Merged

Conversation

chilagrow
Copy link
Member

@chilagrow chilagrow commented Oct 6, 2023

Description

Closes #2826.

Readiness checklist

  • I added/updated unit tests (and they pass).
  • I added/updated integration/compatibility tests (and they pass).
  • I added/updated comments and checked rendering.
  • I made spot refactorings.
  • I updated user documentation.
  • I ran task all, and it passed.
  • I ensured that PR title is good enough for the changelog.
  • (for maintainers only) I set Reviewers (@FerretDB/core), Milestone (Next), Labels, Project and project's Sprint fields.
  • I marked all done items in this checklist.

@chilagrow chilagrow added the code/bug Some user-visible feature works incorrectly label Oct 6, 2023
@chilagrow chilagrow added this to the Next milestone Oct 6, 2023
@chilagrow chilagrow self-assigned this Oct 6, 2023
@chilagrow chilagrow marked this pull request as ready for review October 6, 2023 03:27
@chilagrow chilagrow requested a review from a team as a code owner October 6, 2023 03:27
@chilagrow chilagrow requested review from AlekSi, rumyantseva, a team and noisersup October 6, 2023 03:27
@codecov
Copy link

codecov bot commented Oct 6, 2023

Codecov Report

Merging #3508 (824efc4) into main (b932d0f) will decrease coverage by 6.29%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3508      +/-   ##
==========================================
- Coverage   73.54%   67.25%   -6.29%     
==========================================
  Files         427      427              
  Lines       27122    27124       +2     
==========================================
- Hits        19946    18242    -1704     
- Misses       5983     7613    +1630     
- Partials     1193     1269      +76     
Files Coverage Δ
...ommon/aggregations/stages/projection/projection.go 86.61% <0.00%> (-0.37%) ⬇️

... and 74 files with indirect coverage changes

Flag Coverage Δ
filter-true 60.60% <0.00%> (-6.64%) ⬇️
hana-1 ?
integration 60.60% <0.00%> (-6.64%) ⬇️
mongodb-1 4.50% <0.00%> (-0.01%) ⬇️
pg-1 42.48% <0.00%> (+3.51%) ⬆️
pg-2 39.94% <0.00%> (-1.99%) ⬇️
pg-3 ?
sort-false 60.60% <0.00%> (-6.64%) ⬇️
sqlite-1 41.86% <0.00%> (+3.75%) ⬆️
sqlite-2 39.12% <0.00%> (-2.16%) ⬇️
sqlite-3 ?
unit 25.90% <0.00%> (+<0.01%) ⬆️

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

@chilagrow chilagrow enabled auto-merge (squash) October 6, 2023 03:29
@chilagrow
Copy link
Member Author

👋 @princejha95 I also imported same fix to the aggregation $project stage 🤗

@princejha95
Copy link
Contributor

@chilagrow I also think that in future, we should create a constants file which will store string constants like _id otherwise we will be using strings everywhere and we need to make change everywhere if there's a change in string value. What are your suggestions on this ? Can it be a improvement task ?

Thanks

@rumyantseva
Copy link
Contributor

@princejha95 could you give an example of what change in string value might be needed in the future, please?

Copy link
Contributor

@rumyantseva rumyantseva left a comment

Choose a reason for hiding this comment

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

LGTM

@princejha95
Copy link
Contributor

@princejha95 could you give an example of what change in string value might be needed in the future, please?

What i meant was if we create a file like MongoConstants.go and define a constant like MONGO_ID = "_id", then we can use MONGO_ID everywhere instead of "_id" as it might get written wrongly by mistake. So it's a good practice to keep all such constants which never gets changed inside a file and use them everywhere from the file itself. Generally it is considered a good practice.

Thanks

@chilagrow chilagrow merged commit be0f7b6 into FerretDB:main Oct 9, 2023
23 of 28 checks passed
@chilagrow
Copy link
Member Author

@princejha95 could you give an example of what change in string value might be needed in the future, please?

What i meant was if we create a file like MongoConstants.go and define a constant like MONGO_ID = "_id", then we can use MONGO_ID everywhere instead of "_id" as it might get written wrongly by mistake. So it's a good practice to keep all such constants which never gets changed inside a file and use them everywhere from the file itself. Generally it is considered a good practice.

Thanks

👋 @princejha95 thanks for your comment. For a short one like _id, creating a constant for it doesn't add additional context. Also it's hard to mistype without tests failing somewhere. 🤗 So I don't think it's necessary for _id.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code/bug Some user-visible feature works incorrectly
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Relax restrictions when _id is not the first field in projection
5 participants