diff --git a/lib/aggregator/index.js b/lib/aggregator/index.js index 1dcf048..300e3ce 100644 --- a/lib/aggregator/index.js +++ b/lib/aggregator/index.js @@ -178,7 +178,11 @@ queryMethods.mixin(Aggregator.prototype, function (method, methodName) { // As always, we clone to maintain immutability return function () { const aggregator = this.clone(); - aggregator.queries = aggregator.queries.map(q => q[methodName].apply(q, [].slice.call(arguments))) + aggregator.sharedFunctions.push({ + func: methodName, + params: [].slice.call(arguments) + }) + return aggregator; } }); diff --git a/test/regression.test.js b/test/regression.test.js index 5fc7534..d0a546e 100644 --- a/test/regression.test.js +++ b/test/regression.test.js @@ -91,4 +91,15 @@ describe('regression tests', () => { .then(fetchMock.restore); }); + it('Can override previously called shared method for aggregators', () => { + const kq = KeenQuery.build('@ratio(potato->count(),potato->count())->interval(d)'); + const kq2 = kq.interval('h'); + return kq2.print('url').then(urls => { + expect(urls[0]).to.contain('hourly') + expect(urls[1]).to.contain('hourly') + }) + + + }) + });