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 update with query operator for upsert option #3028

Merged
merged 17 commits into from Jul 14, 2023

Conversation

chilagrow
Copy link
Contributor

@chilagrow chilagrow commented Jul 11, 2023

Description

Closes #2945.

This is not a finest implementation, it fixes the bug. I'm keeping upsert reorganisation in this issue #3040.

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), 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 Jul 11, 2023
@chilagrow chilagrow self-assigned this Jul 11, 2023
@codecov
Copy link

codecov bot commented Jul 12, 2023

Codecov Report

Merging #3028 (d19b018) into main (21f9faf) will increase coverage by 0.71%.
The diff coverage is 68.65%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3028      +/-   ##
==========================================
+ Coverage   72.39%   73.11%   +0.71%     
==========================================
  Files         383      386       +3     
  Lines       20840    21155     +315     
==========================================
+ Hits        15088    15468     +380     
+ Misses       4798     4724      -74     
- Partials      954      963       +9     
Impacted Files Coverage Δ
internal/handlers/pg/msg_findandmodify.go 74.09% <ø> (-6.03%) ⬇️
internal/handlers/sqlite/msg_update.go 77.69% <54.54%> (+14.88%) ⬆️
internal/handlers/pg/msg_update.go 78.40% <66.66%> (+0.82%) ⬆️
internal/handlers/common/filter.go 85.19% <83.33%> (-0.04%) ⬇️

... and 117 files with indirect coverage changes

Flag Coverage Δ
hana ?
integration 69.42% <68.65%> (-2.98%) ⬇️
mongodb 5.55% <0.00%> (?)
pg 60.33% <50.74%> (-5.97%) ⬇️
shard-1 35.80% <0.00%> (-18.14%) ⬇️
shard-2 55.10% <64.17%> (+5.39%) ⬆️
shard-3 51.75% <50.74%> (-5.32%) ⬇️
sqlite 41.80% <47.76%> (-0.24%) ⬇️
unit 24.21% <0.00%> (?)

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

@chilagrow chilagrow changed the title Fix update with upsert option Fix update with query operator for upsert option Jul 12, 2023
@chilagrow chilagrow marked this pull request as ready for review July 12, 2023 10:23
@chilagrow chilagrow requested a review from a team as a code owner July 12, 2023 10:23
@chilagrow chilagrow enabled auto-merge (squash) July 12, 2023 10:25
@chilagrow
Copy link
Contributor Author

$ task test-integration-sqlite TEST_RUN='TestUpdateFieldSet|TestUpdateFieldSetUpdateManyUpsert|TestUpdateFieldSetUpdateManyNoUpsert|TestUpdateCommandUpsertErrors'
task: [test-integration-sqlite] go test -count=1 -run='TestUpdateFieldSet|TestUpdateFieldSetUpdateManyUpsert|TestUpdateFieldSetUpdateManyNoUpsert|TestUpdateCommandUpsertErrors' -timeout=35m -race=true -tags=ferretdb_debug,ferretdb_hana -shuffle=on -coverpkg=../... -coverprofile=integration-sqlite.txt . -target-backend=ferretdb-sqlite -target-tls -compat-url='mongodb://username:password@127.0.0.1:47018/?tls=true&tlsCertificateKeyFile=../build/certs/client.pem&tlsCaFile=../build/certs/rootCA-cert.pem' -disable-filter-pushdown

ok      github.com/FerretDB/FerretDB/integration        0.784s  coverage: 40.0% of statements in ../...

@chilagrow
Copy link
Contributor Author

$ task test-integration-sqlite TEST_RUN='TestUpdateFieldSet|TestUpdateFieldSetUpdateManyUpsert|TestUpdateFieldSetUpdateManyNoUpsert|TestUpdateCommandUpsert'

task: [test-integration-sqlite] go test -count=1 -run='TestUpdateFieldSet|TestUpdateFieldSetUpdateManyUpsert|TestUpdateFieldSetUpdateManyNoUpsert|TestUpdateCommandUpsert' -timeout=35m -race=true -tags=ferretdb_debug,ferretdb_hana -shuffle=on -coverpkg=../... -coverprofile=integration-sqlite.txt . -target-backend=ferretdb-sqlite -target-tls -compat-url='mongodb://username:password@127.0.0.1:47018/?tls=true&tlsCertificateKeyFile=../build/certs/client.pem&tlsCaFile=../build/certs/rootCA-cert.pem' -disable-filter-pushdown

ok      github.com/FerretDB/FerretDB/integration        0.831s  coverage: 40.0% of statements in ../...

@chilagrow
Copy link
Contributor Author

$ task test-integration-sqlite TEST_RUN='TestUpdateFieldSetUpdateManyUpsert|TestUpdateCommandUpsert|TestUpdateFieldCompatSetMulti'
task: [test-integration-sqlite] go test -count=1 -run='TestUpdateFieldSetUpdateManyUpsert|TestUpdateCommandUpsert|TestUpdateFieldCompatSetMulti' -timeout=35m -race=true -tags=ferretdb_debug,ferretdb_hana -shuffle=on -coverpkg=../... -coverprofile=integration-sqlite.txt . -target-backend=ferretdb-sqlite -target-tls -compat-url='mongodb://username:password@127.0.0.1:47018/?tls=true&tlsCertificateKeyFile=../build/certs/client.pem&tlsCaFile=../build/certs/rootCA-cert.pem' -disable-filter-pushdown

ok      github.com/FerretDB/FerretDB/integration        12.979s coverage: 40.0% of statements in ../...

Copy link
Member

@noisersup noisersup left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@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.

As agreed, we wanted to solve a particular issue, and this solutions looks good to me!

@chilagrow chilagrow merged commit 70f33ed into FerretDB:main Jul 14, 2023
24 of 28 checks passed
@AlekSi AlekSi added this to the v1.6.0 milestone Jul 17, 2023
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.

updateMany with filter with no result and upsert true yields errors instead of creating new document
4 participants