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

Commit 6d498582 by Ryan Fink

Fixes issue #2373

1 parent 7bb9c07e
Showing with 14 additions and 1 deletions
......@@ -193,7 +193,7 @@ module.exports = (function() {
}
self.options.uniqueKeys[idxName] = self.options.uniqueKeys[idxName] || {fields: [], msg: null};
self.options.uniqueKeys[idxName].fields.push(attribute);
self.options.uniqueKeys[idxName].fields.push(options.field || attribute);
self.options.uniqueKeys[idxName].msg = self.options.uniqueKeys[idxName].msg || options.unique.msg || null;
self.options.uniqueKeys[idxName].name = idxName || false;
}
......
......@@ -311,6 +311,19 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
})))
})
it('allows unique on column with field aliases', function(done) {
var User = this.sequelize.define('UserWithUniqueFieldAlias', {
userName: { type: Sequelize.STRING, unique: 'user_name_unique', field: 'user_name' }
});
User.sync({ force: true })
.then(function() {
return done();
})
.catch(function(err) {
throw err;
});
});
it('allows us to customize the error message for unique constraint', function(done) {
var self = this
, User = this.sequelize.define('UserWithUniqueUsername', {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!