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 dot notation negative index errors #2246

Merged

Conversation

w84thesun
Copy link
Contributor

@w84thesun w84thesun commented Mar 21, 2023

Description

Closes #2050.

Readiness checklist

  • I added/updated unit tests.
  • I added/updated integration/compatibility tests.
  • 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), Assignee, Labels, Project and project's Sprint fields.
  • I marked all done items in this checklist.

Dmitry added 2 commits March 21, 2023 16:25
@w84thesun w84thesun added the code/bug Some user-visible feature works incorrectly label Mar 21, 2023
@w84thesun w84thesun self-assigned this Mar 21, 2023
@AlekSi AlekSi added this to the v1.0.0 GA milestone Mar 27, 2023
@w84thesun w84thesun added no ci and removed no ci labels Mar 27, 2023
@w84thesun w84thesun removed the no ci label Mar 27, 2023
@w84thesun w84thesun marked this pull request as ready for review March 28, 2023 10:11
@w84thesun w84thesun requested review from a team and AlekSi as code owners March 28, 2023 10:11
@w84thesun w84thesun enabled auto-merge (squash) March 28, 2023 10:11
@codecov
Copy link

codecov bot commented Mar 28, 2023

Codecov Report

Merging #2246 (985cdd0) into main (2b3dcbc) will increase coverage by 0.03%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2246      +/-   ##
==========================================
+ Coverage   71.24%   71.27%   +0.03%     
==========================================
  Files         377      377              
  Lines       17604    17625      +21     
==========================================
+ Hits        12542    12563      +21     
  Misses       4030     4030              
  Partials     1032     1032              
Impacted Files Coverage Δ
internal/handlers/common/update.go 87.17% <100.00%> (+0.09%) ⬆️
internal/types/path.go 95.49% <100.00%> (+0.29%) ⬆️

... and 1 file with indirect coverage changes

Flag Coverage Δ
integration 67.18% <100.00%> (+0.03%) ⬆️
mongodb 5.07% <0.00%> (-0.01%) ⬇️
pg 55.45% <100.00%> (+0.05%) ⬆️
tigris 47.30% <57.14%> (+0.01%) ⬆️
unit 27.13% <0.00%> (-0.01%) ⬇️

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

@w84thesun w84thesun requested review from a team and noisersup March 28, 2023 11:01
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.

The changes look consistent with the other places in the code.

Taskfile.yml Outdated Show resolved Hide resolved
Copy link
Member

@AlekSi AlekSi left a comment

Choose a reason for hiding this comment

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

TestAggregateCompatGroupDocDotNotation fails, and seems to be a genuine failure

@chilagrow
Copy link
Member

chilagrow commented Mar 29, 2023

TestAggregateCompatGroupDocDotNotation fails, and seems to be a genuine failure

https://github.com/FerretDB/FerretDB/actions/runs/4550452790/jobs/8023489900

I see why, array [42] and non array 42 are the same in comparison order. So sorting can be different between compat and target. This can't be used in $group operators, which was the reason it was introduced initially. Unfortunately I think we need to delete this provider.

Update: actually we can update the value to 43 in one of them which will solve the issue.

2023-03-29T05:30:52.0700205Z                 	Error:      	Not equal: 
2023-03-29T05:30:52.0700475Z                 	            	expected: [
2023-03-29T05:30:52.0700686Z                 	            	  {
2023-03-29T05:30:52.0700940Z                 	            	    "$k": [
2023-03-29T05:30:52.0701318Z                 	            	      "_id"
2023-03-29T05:30:52.0701558Z                 	            	    ],
2023-03-29T05:30:52.0701844Z                 	            	    "_id": 42
2023-03-29T05:30:52.0702059Z                 	            	  },
2023-03-29T05:30:52.0702271Z                 	            	  {
2023-03-29T05:30:52.0702545Z                 	            	    "$k": [
2023-03-29T05:30:52.0702830Z                 	            	      "_id"
2023-03-29T05:30:52.0703163Z                 	            	    ],
2023-03-29T05:30:52.0703555Z                 	            	    "_id": [
2023-03-29T05:30:52.0703908Z                 	            	      42
2023-03-29T05:30:52.0704240Z                 	            	    ]
2023-03-29T05:30:52.0704461Z                 	            	  }
2023-03-29T05:30:52.0704644Z                 	            	]
2023-03-29T05:30:52.0704910Z                 	            	actual  : [
2023-03-29T05:30:52.0705119Z                 	            	  {
2023-03-29T05:30:52.0705386Z                 	            	    "$k": [
2023-03-29T05:30:52.0705664Z                 	            	      "_id"
2023-03-29T05:30:52.0705896Z                 	            	    ],
2023-03-29T05:30:52.0706174Z                 	            	    "_id": [
2023-03-29T05:30:52.0706422Z                 	            	      42
2023-03-29T05:30:52.0706651Z                 	            	    ]
2023-03-29T05:30:52.0706865Z                 	            	  },
2023-03-29T05:30:52.0707076Z                 	            	  {
2023-03-29T05:30:52.0707342Z                 	            	    "$k": [
2023-03-29T05:30:52.0707617Z                 	            	      "_id"
2023-03-29T05:30:52.0707857Z                 	            	    ],
2023-03-29T05:30:52.0708129Z                 	            	    "_id": 42
2023-03-29T05:30:52.0708338Z                 	            	  }
2023-03-29T05:30:52.0708531Z                 	            	]
2023-03-29T05:30:52.0708902Z                 	            	--- expected
2023-03-29T05:30:52.0709161Z                 	            	+++ actual
2023-03-29T05:30:52.0709506Z                 	            	@@ -1,8 +1,2 @@
2023-03-29T05:30:52.0709710Z                 	            	 [
2023-03-29T05:30:52.0709962Z                 	            	-  {
2023-03-29T05:30:52.0710272Z                 	            	-    "$k": [
2023-03-29T05:30:52.0710578Z                 	            	-      "_id"
2023-03-29T05:30:52.0710856Z                 	            	-    ],
2023-03-29T05:30:52.0711184Z                 	            	-    "_id": 42
2023-03-29T05:30:52.0711443Z                 	            	-  },
2023-03-29T05:30:52.0711645Z                 	            	   {
2023-03-29T05:30:52.0711988Z                 	            	@@ -14,2 +8,8 @@
2023-03-29T05:30:52.0712223Z                 	            	     ]
2023-03-29T05:30:52.0712444Z                 	            	+  },
2023-03-29T05:30:52.0712655Z                 	            	+  {
2023-03-29T05:30:52.0712924Z                 	            	+    "$k": [
2023-03-29T05:30:52.0713187Z                 	            	+      "_id"
2023-03-29T05:30:52.0713424Z                 	            	+    ],
2023-03-29T05:30:52.0713707Z                 	            	+    "_id": 42
2023-03-29T05:30:52.0713921Z                 	            	   }
2023-03-29T05:30:52.0714708Z                 	Test:       	TestAggregateCompatGroupDocDotNotation/DocDotNotation/TestAggregateCompatGroupDocDotNotation_ArrayAndDocuments

@w84thesun w84thesun merged commit 7772636 into FerretDB:main Mar 29, 2023
@w84thesun w84thesun deleted the issue-2050-negative-indexes-dot-notation branch March 29, 2023 09:41
efirs added a commit to tigrisdata-archive/ferretdb that referenced this pull request Apr 11, 2023
v1.0.0
https://github.com/FerretDB/FerretDB/releases/tag/v1.0.0
2023-04-03

We are delighted to announce the release of FerretDB 1.0 GA!

* Support `$sum` accumulator of `$group` aggregation by @chilagrow in FerretDB#2292
* Implement `createIndexes` command by @rumyantseva in FerretDB#2244
* Add basic `getMore` command by @AlekSi in FerretDB#2309
* Implement `dropIndexes` command by @chilagrow in FerretDB#2313
* Implement `$limit` aggregation pipeline stage by @noisersup in FerretDB#2270
* Add partial support for `collStats`, `dbStats` and `dataSize` by @AlekSi in FerretDB#2322
* Implement `$skip` aggregation pipeline stage by @w84thesun in FerretDB#2310
* Implement `$unwind` aggregation pipeline stage by @noisersup in FerretDB#2294
* Support `count` and `storageStats` fields in `$collStats` aggregation pipeline stage by @rumyantseva in FerretDB#2338

* Fix dot notation negative index errors by @w84thesun in FerretDB#2246
* Apply `skip` before `limit` by @AlekSi in FerretDB#2351

* Update supported command for `$sum` aggregation operator by @chilagrow in FerretDB#2318
* Add supported shells and GUIs images by @AlekSi in FerretDB#2323
* Publish FerretDB v0.9.4 blog post by @Fashander in FerretDB#2268
* Use dashes instead of underscores or spaces by @AlekSi in FerretDB#2329
* Update documentation sidebar by @Fashander in FerretDB#2347
* Update FerretDB descriptions by @AlekSi in FerretDB#2281
* Improve flags documentation by @AlekSi in FerretDB#2331
* Describe supported fields for `$collStats` aggregation stage by @rumyantseva in FerretDB#2352

* Use iterators for `sort`, `limit`, `skip`, and `projection` by @AlekSi in FerretDB#2254
* Bump dependencies by @AlekSi in FerretDB#2307
* Improve resource tracking by @AlekSi in FerretDB#2319
* Add tests for `find`'s and `count`'s `skip` argument by @w84thesun in FerretDB#2325
* Close iterator properly by @AlekSi in FerretDB#2333
* Improve large numbers initialization in test data by @noisersup in FerretDB#2324
* Ignore `unique` index option for now by @AlekSi in FerretDB#2350

All closed issues and pull requests: https://github.com/FerretDB/FerretDB/milestone/39?closed=1
All commits: FerretDB/FerretDB@v0.9.4...v1.0.0
efirs added a commit to tigrisdata-archive/ferretdb that referenced this pull request Apr 11, 2023
v1.0.0
https://github.com/FerretDB/FerretDB/releases/tag/v1.0.0
2023-04-03

We are delighted to announce the release of FerretDB 1.0 GA!

* Support `$sum` accumulator of `$group` aggregation by @chilagrow in FerretDB#2292
* Implement `createIndexes` command by @rumyantseva in FerretDB#2244
* Add basic `getMore` command by @AlekSi in FerretDB#2309
* Implement `dropIndexes` command by @chilagrow in FerretDB#2313
* Implement `$limit` aggregation pipeline stage by @noisersup in FerretDB#2270
* Add partial support for `collStats`, `dbStats` and `dataSize` by @AlekSi in FerretDB#2322
* Implement `$skip` aggregation pipeline stage by @w84thesun in FerretDB#2310
* Implement `$unwind` aggregation pipeline stage by @noisersup in FerretDB#2294
* Support `count` and `storageStats` fields in `$collStats` aggregation pipeline stage by @rumyantseva in FerretDB#2338

* Fix dot notation negative index errors by @w84thesun in FerretDB#2246
* Apply `skip` before `limit` by @AlekSi in FerretDB#2351

* Update supported command for `$sum` aggregation operator by @chilagrow in FerretDB#2318
* Add supported shells and GUIs images by @AlekSi in FerretDB#2323
* Publish FerretDB v0.9.4 blog post by @Fashander in FerretDB#2268
* Use dashes instead of underscores or spaces by @AlekSi in FerretDB#2329
* Update documentation sidebar by @Fashander in FerretDB#2347
* Update FerretDB descriptions by @AlekSi in FerretDB#2281
* Improve flags documentation by @AlekSi in FerretDB#2331
* Describe supported fields for `$collStats` aggregation stage by @rumyantseva in FerretDB#2352

* Use iterators for `sort`, `limit`, `skip`, and `projection` by @AlekSi in FerretDB#2254
* Bump dependencies by @AlekSi in FerretDB#2307
* Improve resource tracking by @AlekSi in FerretDB#2319
* Add tests for `find`'s and `count`'s `skip` argument by @w84thesun in FerretDB#2325
* Close iterator properly by @AlekSi in FerretDB#2333
* Improve large numbers initialization in test data by @noisersup in FerretDB#2324
* Ignore `unique` index option for now by @AlekSi in FerretDB#2350

All closed issues and pull requests: https://github.com/FerretDB/FerretDB/milestone/39?closed=1
All commits: FerretDB/FerretDB@v0.9.4...v1.0.0
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
None yet
Development

Successfully merging this pull request may close these issues.

Return error for negative array indexes in dot notation
5 participants