@@ -73,7 +73,9 @@ function setScopeValuesFromWhere(data, where, targetModel) {
7373 * @param {String|Array|Object } source The runtime value of `include` option
7474 * @returns {Object }
7575 */
76- function mergeIncludes ( destination , source ) {
76+ // function mergeIncludes(destination, source) {
77+ // NOTE see: https://github.com/strongloop/loopback-datasource-juggler/pull/787
78+ function mergeIncludes ( source , destination ) {
7779 var destArray = convertToArray ( destination ) ;
7880 var sourceArray = convertToArray ( source ) ;
7981 if ( destArray . length === 0 ) {
@@ -193,12 +195,20 @@ function mergeQuery(base, update, spec) {
193195 }
194196
195197 // Overwrite fields
196- if ( spec . fields !== false && update . fields !== undefined ) {
198+ // NOTE see: https://github.com/strongloop/loopback-datasource-juggler/pull/787
199+ if ( spec . fields !== false && base . fields === undefined && update . fields !== undefined ) {
197200 base . fields = update . fields ;
198- } else if ( update . fields !== undefined ) {
201+ } else if ( spec . fields !== false && update . fields !== undefined ) {
199202 base . fields = [ ] . concat ( base . fields ) . concat ( update . fields ) ;
200203 }
201204
205+ // // Overwrite fields
206+ // if (spec.fields !== false && update.fields !== undefined) {
207+ // base.fields = update.fields;
208+ // } else if (update.fields !== undefined) {
209+ // base.fields = [].concat(base.fields).concat(update.fields);
210+ // }
211+
202212 // set order
203213 if ( ( ! base . order || spec . order === false ) && update . order ) {
204214 base . order = update . order ;
0 commit comments