Fix "access" hook for unoptimized "near" queries

Before this change, when an "access" hook modified the "query" object,
the "near" condition from the original "query" object were still
applied. As a result, the query can end up being more restrictive and
return only a subset of models that should have matched the conditions.

With this change in place, after "access" hook observers are invoked,
we update the "near" condition using the "query" object provided by
hook observers.

Signed-off-by: Miroslav Bajtoš <mbajtoss@gmail.com>
This commit is contained in:
Miroslav Bajtoš 2019-05-13 09:36:46 +02:00
parent 344441d48d
commit aa20180c4f
No known key found for this signature in database
GPG Key ID: 6F2304BA9361C7E3
1 changed files with 2 additions and 1 deletions

View File

@ -1535,7 +1535,7 @@ DataAccessObject.find = function find(query, options, cb) {
this.applyScope(query);
const near = query && geo.nearFilter(query.where);
let near = query && geo.nearFilter(query.where);
const supportsGeo = !!connector.buildNearFilter;
let geoQueryObject;
@ -1597,6 +1597,7 @@ DataAccessObject.find = function find(query, options, cb) {
function queryGeo(query) {
geoQueryObject = query;
near = query && geo.nearFilter(query.where);
invokeConnectorMethod(connector, 'all', self, [{}], options, geoCallback);
}