不要怂,就是干,撸起袖子干!

Commit 0aedb015 by Jan Aagaard Meier

🐛 Fix include all for self-reference. Closes #3804

1 parent d2167832
# Next
- [BUG] Fix a case where `type` in `sequelize.query` was not being set to raw. [#3800](https://github.com/sequelize/sequelize/pull/3800)
- [BUG] Fix an issue where include all was not being properly expanded for self-references [#3804](https://github.com/sequelize/sequelize/issues/3804)
# 3.1.1
- [FIXED] Always quote aliases, even when quoteIdentifiers is false [#1589](https://github.com/sequelize/sequelize/issues/1589)
......
......@@ -2126,7 +2126,7 @@ module.exports = (function() {
}
};
var expandIncludeAll = function(options) {
var expandIncludeAll = Model.$expandIncludeAll = function(options) {
var includes = options.include;
if (!includes) {
return;
......@@ -2207,7 +2207,6 @@ module.exports = (function() {
var used = [];
(function addAllIncludes(parent, includes) {
used.push(parent);
Utils._.forEach(parent.associations, function(association) {
if (all !== true && all.indexOf(association.associationType) === -1) {
return;
......@@ -2231,6 +2230,7 @@ module.exports = (function() {
if (nested && used.indexOf(model) !== -1) {
return;
}
used.push(parent);
// include this model
var thisInclude = optClone(include);
......
'use strict';
/* jshint -W030 */
var chai = require('chai')
, expect = chai.expect
, Support = require(__dirname + '/../support')
, current = Support.sequelize;
describe(Support.getTestDialectTeaser('Include'), function() {
describe('all', function (){
var Referral = current.define('referal');
Referral.belongsTo(Referral);
it('can expand nested self-reference', function () {
var options = { include: [{ all: true, nested: true }] };
current.Model.$expandIncludeAll.call(Referral, options);
expect(options.include).to.deep.equal([
{ model: Referral }
]);
});
});
});
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!