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

Commit 179f5e3a by Mick Hansen

Don't fail on foreign key references to inexistant DAOs, let it run and the DB s…

…hould complain about referencing inexistant tables
1 parent b123a72b
...@@ -60,7 +60,7 @@ module.exports = (function() { ...@@ -60,7 +60,7 @@ module.exports = (function() {
}) })
sorter.sort().reverse().forEach(function(name) { sorter.sort().reverse().forEach(function(name) {
iterator(daos[name]) iterator(daos[name], name)
}) })
} }
......
...@@ -366,8 +366,12 @@ module.exports = (function() { ...@@ -366,8 +366,12 @@ module.exports = (function() {
// Topologically sort by foreign key constraints to give us an appropriate // Topologically sort by foreign key constraints to give us an appropriate
// creation order // creation order
this.daoFactoryManager.forEachDAO(function(dao) { this.daoFactoryManager.forEachDAO(function(dao, daoName) {
if (dao) {
chainer.add(dao, 'sync', [options]) chainer.add(dao, 'sync', [options])
} else {
// DB should throw an SQL error if referencing inexistant table
}
}) })
return chainer.runSerially() return chainer.runSerially()
......
...@@ -477,6 +477,17 @@ describe(Support.getTestDialectTeaser("Sequelize"), function () { ...@@ -477,6 +477,17 @@ describe(Support.getTestDialectTeaser("Sequelize"), function () {
done() done()
}) })
}) })
it('returns an error correctly if unable to sync a foreign key referenced model', function (done) {
var Application = this.sequelize.define('Application', {
authorID: { type: Sequelize.BIGINT, allowNull: false, references: 'User', referencesKey: 'id' },
})
this.sequelize.sync().error(function (error) {
assert.ok(error);
done()
})
})
} }
describe("doesn't emit logging when explicitly saying not to", function() { describe("doesn't emit logging when explicitly saying not to", function() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!