diff --git a/lib/utils.js b/lib/utils.js index ed2fabfd8..53611ad4a 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -73,7 +73,9 @@ function setScopeValuesFromWhere(data, where, targetModel) { * @param {String|Array|Object} source The runtime value of `include` option * @returns {Object} */ -function mergeIncludes(destination, source) { +// function mergeIncludes(destination, source) { +// NOTE see: https://github.com/strongloop/loopback-datasource-juggler/pull/787 +function mergeIncludes(source, destination) { var destArray = convertToArray(destination); var sourceArray = convertToArray(source); if (destArray.length === 0) { @@ -193,12 +195,20 @@ function mergeQuery(base, update, spec) { } // Overwrite fields - if (spec.fields !== false && update.fields !== undefined) { + // NOTE see: https://github.com/strongloop/loopback-datasource-juggler/pull/787 + if (spec.fields !== false && base.fields === undefined && update.fields !== undefined) { base.fields = update.fields; - } else if (update.fields !== undefined) { + } else if (spec.fields !== false && update.fields !== undefined) { base.fields = [].concat(base.fields).concat(update.fields); } + // // Overwrite fields + // if (spec.fields !== false && update.fields !== undefined) { + // base.fields = update.fields; + // } else if (update.fields !== undefined) { + // base.fields = [].concat(base.fields).concat(update.fields); + // } + // set order if ((!base.order || spec.order === false) && update.order) { base.order = update.order;