Loading lib/readable.js +5 −1 Changes for lib/readable.js: 5 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -560,8 +560,12 @@ Readable.prototype.join = function (definition) { return new Proxy(target[prop], { apply: (fn, thisArg, args) => { const optionsIdx = prop === 'where' ? 2 : 1; const optionsObj = args[optionsIdx] || {}; const override = optionsObj.decompose; args[optionsIdx] = _.assign(args[optionsIdx] || {}, {decompose: decompositionSchema}); args[optionsIdx] = _.assign(optionsObj, { decompose: override || decompositionSchema }); return fn.apply(thisArg, args); } Loading test/readable/join.js +30 −0 Changes for test/readable/join.js: 30 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -330,6 +330,36 @@ describe('join', function () { assert.lengthOf(Object.keys(db.entityCache), 2); }); it('allows overriding the decomposition schema', function () { return db.alpha.join({ beta: { type: 'INNER', on: {alpha_id: 'id'} } }).find({ 'alpha.id': 3 }, { // strip the 'val' fields decompose: { pk: 'alpha__id', columns: {alpha__id: 'id'}, beta: { pk: 'beta__id', columns: {beta__id: 'id', beta__alpha_id: 'alpha_id'} } } }).then(result => { assert.deepEqual(result, [{ id: 3, beta: [{ id: 3, alpha_id: 3 }, { id: 4, alpha_id: 3 }] }]); }); }); it('errors when the origin name reappears', function () { assert.throws(() => db.alpha.join({ alpha: { Loading Loading
lib/readable.js +5 −1 Changes for lib/readable.js: 5 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -560,8 +560,12 @@ Readable.prototype.join = function (definition) { return new Proxy(target[prop], { apply: (fn, thisArg, args) => { const optionsIdx = prop === 'where' ? 2 : 1; const optionsObj = args[optionsIdx] || {}; const override = optionsObj.decompose; args[optionsIdx] = _.assign(args[optionsIdx] || {}, {decompose: decompositionSchema}); args[optionsIdx] = _.assign(optionsObj, { decompose: override || decompositionSchema }); return fn.apply(thisArg, args); } Loading
test/readable/join.js +30 −0 Changes for test/readable/join.js: 30 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -330,6 +330,36 @@ describe('join', function () { assert.lengthOf(Object.keys(db.entityCache), 2); }); it('allows overriding the decomposition schema', function () { return db.alpha.join({ beta: { type: 'INNER', on: {alpha_id: 'id'} } }).find({ 'alpha.id': 3 }, { // strip the 'val' fields decompose: { pk: 'alpha__id', columns: {alpha__id: 'id'}, beta: { pk: 'beta__id', columns: {beta__id: 'id', beta__alpha_id: 'alpha_id'} } } }).then(result => { assert.deepEqual(result, [{ id: 3, beta: [{ id: 3, alpha_id: 3 }, { id: 4, alpha_id: 3 }] }]); }); }); it('errors when the origin name reappears', function () { assert.throws(() => db.alpha.join({ alpha: { Loading