FerretDB icon indicating copy to clipboard operation
FerretDB copied to clipboard

Improve comparision and sorting of arrays and documents

Open AlekSi opened this issue 4 years ago • 7 comments

We should check that our comparison and sorting of arrays and documents work as in MongoDB.

Things to check and/or implement:

  • [x] comparison of arrays without serialization (#676);
  • [ ] comparison of documents without reflection;
  • [x] comparison of [], [null] arrays;
  • [x] comparison of arrays with a different element order;
  • [x] comparison of arrays with a different element types;
  • [ ] comparison of documents with missing fields and nulls;
  • [ ] comparison of documents with different fields order;
  • [ ] comparison of documents with different fields types;
  • [ ] ascending and descending sorting:
    • [x] scalars;
    • [ ] documents;
    • [ ] arrays;
  • [ ] check that changes are ported to findAndModify.

We might have some of that tested already, but we should check that, add missing tests, and fix bugs.

AlekSi avatar Apr 08 '22 10:04 AlekSi

The last point remains

AlekSi avatar May 11 '22 16:05 AlekSi

Sure!

ribaraka avatar May 11 '22 17:05 ribaraka

To close the last point, I've got to first solve #522 PR. lessFunc uses Compare which returns compare result. The problem is we don't have comparing for Document and Array data types yet ( just matching ). Also I think we should first remove NotEqual, though it is a uniq solution for cases when we compare different types of data with each other (e.g. comparing string with int).. by the way we have got to handle comparing different data types with each other.

ribaraka avatar May 12 '22 14:05 ribaraka

I agree. I think let's check scalar types first (both comparing and sorting by them), then documents, then arrays (that are most difficult)

AlekSi avatar May 12 '22 14:05 AlekSi

OK!

ribaraka avatar May 12 '22 14:05 ribaraka

todo: check support in findAndModify

seeforschauer avatar May 26 '22 07:05 seeforschauer

On hold for now, until we decide about edge cases and validation

AlekSi avatar Aug 01 '22 18:08 AlekSi