Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down