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 7f35e0ff2c
commit c4ff74a723
No known key found for this signature in database
GPG Key ID: 6F2304BA9361C7E3
1 changed files with 3 additions and 1 deletions

View File

@ -1536,7 +1536,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;
if (near) {
@ -1567,6 +1567,8 @@ DataAccessObject.find = function find(query, options, cb) {
}
function queryGeo(query) {
near = query && geo.nearFilter(query.where);
function geoCallbackWithoutNotify(err, data) {
const memory = new Memory();
const modelName = self.modelName;