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

Commit bb959f45 by Nick Acker

Add failing test for N:M with renamed attributes

1 parent fcceefdf
......@@ -246,7 +246,7 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
});
var User_has_Group = this.sequelize.define('User_has_Group', {
}, {
tableName: 'tbl_user_has_group'
});
......@@ -269,6 +269,57 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
});
});
});
it('supports primary key attributes with different field names', function () {
var User = this.sequelize.define('User', {
id: {
type: DataTypes.UUID,
allowNull: false,
primaryKey: true,
defaultValue: DataTypes.UUIDV4,
field: 'user_id'
}
}, {
tableName: 'tbl_user'
});
var Group = this.sequelize.define('Group', {
id: {
type: DataTypes.UUID,
allowNull: false,
primaryKey: true,
defaultValue: DataTypes.UUIDV4,
field: 'group_id'
}
}, {
tableName: 'tbl_group'
});
var User_has_Group = this.sequelize.define('User_has_Group', {
}, {
tableName: 'tbl_user_has_group'
});
User.belongsToMany(Group, {through: User_has_Group});
Group.belongsToMany(User, {through: User_has_Group});
return this.sequelize.sync({force: true}).then(function () {
return Promise.join(
User.create(),
Group.create()
).spread(function (user, group) {
return user.addGroup(group);
}).then(function () {
return User.findOne({
where: {},
include: Group
}).then(function (user) {
return user;
});
});
});
});
});
describe('setAssociations', function() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!