commit
b039b51610
|
@ -1562,6 +1562,9 @@ RelationDefinition.hasAndBelongsToMany = function hasAndBelongsToMany(modelFrom,
|
||||||
options.properties = params.properties;
|
options.properties = params.properties;
|
||||||
options.scope = params.scope;
|
options.scope = params.scope;
|
||||||
|
|
||||||
|
// Forward relation options like "disableInclude"
|
||||||
|
options.options = params.options;
|
||||||
|
|
||||||
if (params.polymorphic) {
|
if (params.polymorphic) {
|
||||||
var polymorphic = polymorphicParams(params.polymorphic);
|
var polymorphic = polymorphicParams(params.polymorphic);
|
||||||
options.polymorphic = polymorphic; // pass through
|
options.polymorphic = polymorphic; // pass through
|
||||||
|
|
|
@ -919,6 +919,29 @@ describe('include', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should support disableInclude for hasAndBelongsToMany', function() {
|
||||||
|
var Patient = db.define('Patient', { name: String });
|
||||||
|
var Doctor = db.define('Doctor', { name: String });
|
||||||
|
var DoctorPatient = db.define('DoctorPatient');
|
||||||
|
Doctor.hasAndBelongsToMany('patients', {
|
||||||
|
model: 'Patient',
|
||||||
|
options: { disableInclude: true },
|
||||||
|
});
|
||||||
|
|
||||||
|
var doctor;
|
||||||
|
return db.automigrate(['Patient', 'Doctor', 'DoctorPatient']).then(function() {
|
||||||
|
return Doctor.create({ name: 'Who' });
|
||||||
|
}).then(function(inst) {
|
||||||
|
doctor = inst;
|
||||||
|
return doctor.patients.create({ name: 'Lazarus' });
|
||||||
|
}).then(function() {
|
||||||
|
return Doctor.find({ include: ['patients'] });
|
||||||
|
}).then(function(list) {
|
||||||
|
list.should.have.length(1);
|
||||||
|
list[0].toJSON().should.not.have.property('patients');
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function setup(done) {
|
function setup(done) {
|
||||||
|
|
Loading…
Reference in New Issue