mirror of
https://github.com/FerretDB/documentdb.git
synced 2026-11-25 11:49:53 -05:00
### Does this PR have any customer impact?
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
### Are you introducing any new config? If yes, do you have tests with and without them being set?
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
### Description
This PR contains 2 fixes
- In $merge `on` field cannot contain duplicate element: `{ "$merge" : {"on" : [a,a] }`
- we were missing a case while validating on field against index array.
```
let's say indexSpec : { "x" : 1, "y" : 1, "z" : 1}
then below cases also expected to be fail as index array has extra element.
`{ "$merge" : {"on" : [x,z] }`
`{ "$merge" : {"on" : [x,y] }`
```
----
#### AI description (iteration 1)
#### PR Classification
Bug fix
#### PR Summary
Fixes a bug in the `$merge` operation by ensuring proper detection of compound unique indexes and handling duplicate fields.
- `bson_aggregation_output_pipeline.c`: Corrected logic to check for compound unique indexes and added error handling for duplicate fields.
- `bson_aggregation_stage_merge_tests.sql` and related test output files: Added tests to verify the detection of duplicate fields and proper index checking.
- `helio_conversion_codes.c`: Added a new error code for duplicate field detection.
- Updated error code mappings in `mongoerrors.csv`, `helioerrors.csv`, `helio_codes.txt`, and `mongo_codes.csv`.