diff --git a/lib/waterline/utils/query/forge-stage-two-query.js b/lib/waterline/utils/query/forge-stage-two-query.js index 6fd6ea1f6..ea8653649 100644 --- a/lib/waterline/utils/query/forge-stage-two-query.js +++ b/lib/waterline/utils/query/forge-stage-two-query.js @@ -876,7 +876,7 @@ module.exports = function forgeStageTwoQuery(query, orm) { // Otherwise, this simply must be `true`. Otherwise it's invalid. else { - if (query.populates[populateAttrName] !== true) { + if (query.populates[populateAttrName] !== true && (_.isUndefined(query.populates[populateAttrName].select) && _.isUndefined(query.populates[populateAttrName].omit))) { throw buildUsageError( 'E_INVALID_POPULATES', 'Could not populate `'+populateAttrName+'`. '+ @@ -886,14 +886,19 @@ module.exports = function forgeStageTwoQuery(query, orm) { 'since it generally wouldn\'t make any sense. But that\'s the trouble-- it '+ 'looks like some sort of a subcriteria (or something) _was_ provided!\n'+ '(Note that subcriterias consisting ONLY of `omit` or `select` are a special '+ - 'case that _does_ make sense. This usage will be supported in a future version '+ - 'of Waterline.)\n'+ + 'case that _does_ make sense.\n'+ '\n'+ 'Here\'s what was passed in:\n'+ util.inspect(query.populates[populateAttrName], {depth: 5}), query.using ); }//-• + else { + query.populates[populateAttrName] = { + select: query.populates[populateAttrName].select? query.populates[populateAttrName].select : undefined, + omit: query.populates[populateAttrName].omit? query.populates[populateAttrName].omit : undefined + }; + } }//>-•