Improve comparision and sorting of arrays and documents
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.
The last point remains
Sure!
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.
I agree. I think let's check scalar types first (both comparing and sorting by them), then documents, then arrays (that are most difficult)
OK!
todo: check support in findAndModify
On hold for now, until we decide about edge cases and validation