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

Commit 3cc67019 by Mick Hansen

Merge pull request #2422 from nullivex/master

Fixes #2416 - Creation of Many-to-Many associations using indexes
2 parents c63ccaf6 9cd22912
...@@ -133,6 +133,7 @@ module.exports = (function() { ...@@ -133,6 +133,7 @@ module.exports = (function() {
if (typeof this.through.model === 'string') { if (typeof this.through.model === 'string') {
this.through.model = this.sequelize.define(this.through.model, {}, _.extend(this.options, { this.through.model = this.sequelize.define(this.through.model, {}, _.extend(this.options, {
tableName: this.through.model, tableName: this.through.model,
indexes: {}, //we dont want indexes here (as referenced in #2416)
paranoid: false // A paranoid join table does not make sense paranoid: false // A paranoid join table does not make sense
})); }));
......
...@@ -1278,6 +1278,39 @@ describe(Support.getTestDialectTeaser("HasMany"), function() { ...@@ -1278,6 +1278,39 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
expect(tasks[0].title).to.equal('get started'); expect(tasks[0].title).to.equal('get started');
}); });
}); });
it('should not pass indexes to the join table',function(){
var User = this.sequelize.define(
'User',
{ username: DataTypes.STRING },
{
indexes: [
{
name: 'username_unique',
unique: true,
method: 'BTREE',
fields: ['username']
}
]
});
var Task = this.sequelize.define(
'Task',
{ title: DataTypes.STRING },
{
indexes: [
{
name: 'title_index',
method: 'BTREE',
fields: ['title']
}
]
});
//create associations
User.hasMany(Task);
Task.hasMany(User);
return this.sequelize.sync({ force: true });
});
}); });
describe('addMultipleAssociations', function () { describe('addMultipleAssociations', function () {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!