-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Alleviate SERVER-13732 on all top level filters (#3564)
In a prior commit, improvements were made to the addition of `_rperm` in the case of `$or` queries, to avoid MongoDB bug SERVER-13732. As the vast majority of $or queries previously hit this bug due to the presence of `_rperm` on most Parse queries), the present solution avoids the bug and improves query performance in most cases. However, it's still possible for clients to supply their own queries which hit that bug, such as those with `_created_at` or `_updated_at` filters, or their own properties from their data model. This commit makes the logic currently present for `_rperm` available to all top level filters that exist alongside an $or query, meaning SERVER-13732 should be avoided in all cases where keys at the top and inner levels do not have name clashes. - #3476 - https://jira.mongodb.org/browse/SERVER-13732
- Loading branch information
1 parent
053bbef
commit 7319562
Showing
2 changed files
with
55 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
var DatabaseController = require('../src/Controllers/DatabaseController.js'); | ||
var validateQuery = DatabaseController._validateQuery; | ||
|
||
describe('DatabaseController', function() { | ||
|
||
describe('validateQuery', function() { | ||
|
||
it('should restructure simple cases of SERVER-13732', (done) => { | ||
var query = {$or: [{a: 1}, {a: 2}], _rperm: {$in: ['a', 'b']}, foo: 3}; | ||
validateQuery(query); | ||
expect(query).toEqual({$or: [{a: 1, _rperm: {$in: ['a', 'b']}, foo: 3}, | ||
{a: 2, _rperm: {$in: ['a', 'b']}, foo: 3}]}); | ||
done(); | ||
}); | ||
|
||
it('should reject invalid queries', (done) => { | ||
expect(() => validateQuery({$or: {'a': 1}})).toThrow(); | ||
done(); | ||
}); | ||
|
||
it('should accept valid queries', (done) => { | ||
expect(() => validateQuery({$or: [{'a': 1}, {'b': 2}]})).not.toThrow(); | ||
done(); | ||
}); | ||
|
||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters