Fix multiple use of notEqualTo (#2882)
* Add failing test for multiple .notEqualTo on relation with same class * Fix multiple .notEqualTo on relations with the same class Multiple should use the union of all objectIds not the intersect Fixes ParsePlatform/parse-server#1596
This commit is contained in:
committed by
Florent Vilmart
parent
d8ba9e8b7d
commit
b88b0c578f
@@ -676,17 +676,12 @@ DatabaseController.prototype.addInObjectIdsIds = function(ids = null, query) {
|
||||
return query;
|
||||
}
|
||||
|
||||
DatabaseController.prototype.addNotInObjectIdsIds = function(ids = null, query) {
|
||||
let idsFromNin = query.objectId && query.objectId['$nin'] ? query.objectId['$nin'] : null;
|
||||
let allIds = [idsFromNin, ids].filter(list => list !== null);
|
||||
let totalLength = allIds.reduce((memo, list) => memo + list.length, 0);
|
||||
DatabaseController.prototype.addNotInObjectIdsIds = function(ids = [], query) {
|
||||
let idsFromNin = query.objectId && query.objectId['$nin'] ? query.objectId['$nin'] : [];
|
||||
let allIds = [...idsFromNin,...ids].filter(list => list !== null);
|
||||
|
||||
let idsIntersection = [];
|
||||
if (totalLength > 125) {
|
||||
idsIntersection = intersect.big(allIds);
|
||||
} else {
|
||||
idsIntersection = intersect(allIds);
|
||||
}
|
||||
// make a set and spread to remove duplicates
|
||||
allIds = [...new Set(allIds)];
|
||||
|
||||
// Need to make sure we don't clobber existing shorthand $eq constraints on objectId.
|
||||
if (!('objectId' in query)) {
|
||||
@@ -696,8 +691,8 @@ DatabaseController.prototype.addNotInObjectIdsIds = function(ids = null, query)
|
||||
$eq: query.objectId
|
||||
};
|
||||
}
|
||||
query.objectId['$nin'] = idsIntersection;
|
||||
|
||||
query.objectId['$nin'] = allIds;
|
||||
return query;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user