From aaf037fc5157e42e87bfe40b6ebb98e3f4c89c30 Mon Sep 17 00:00:00 2001 From: Laurent Chenay Date: Mon, 28 Jul 2014 15:17:36 +0200 Subject: [PATCH] Do not overwrite inclusion but scope them. Needed in relation hasManyThrought --- lib/scope.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/scope.js b/lib/scope.js index c1c90eba..f6384856 100644 --- a/lib/scope.js +++ b/lib/scope.js @@ -246,9 +246,15 @@ function mergeQuery(base, update) { } } - // Overwrite inclusion + // Merge inclusion if (update.include) { - base.include = update.include; + if (!base.include) { + base.include = update.include; + } else { + var saved = base.include; + base.include = {}; + base.include[update.include] = [saved]; + } } if (update.collect) { base.collect = update.collect;