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

Commit 343e3918 by Mick Hansen

Attempt to fix self-dependency foreign key references with sync

1 parent 179f5e3a
...@@ -56,6 +56,9 @@ module.exports = (function() { ...@@ -56,6 +56,9 @@ module.exports = (function() {
} }
} }
deps = deps.filter(function (dep) {
return dao.tableName !== dep
})
sorter.add(dao.tableName, deps) sorter.add(dao.tableName, deps)
}) })
......
...@@ -488,6 +488,34 @@ describe(Support.getTestDialectTeaser("Sequelize"), function () { ...@@ -488,6 +488,34 @@ describe(Support.getTestDialectTeaser("Sequelize"), function () {
done() done()
}) })
}) })
it('handles self dependant foreign key constraints', function (done) {
var block = this.sequelize.define("block", {
id: { type: DataTypes.INTEGER, primaryKey: true },
name: DataTypes.STRING
}, {
tableName: "block",
timestamps: false,
paranoid: false
});
block.hasMany(block, {
as: 'childBlocks',
foreignKey: 'parent',
joinTableName: 'link_block_block',
useJunctionTable: true,
foreignKeyConstraint: true
});
block.belongsTo(block, {
as: 'parentBlocks',
foreignKey: 'child',
joinTableName: 'link_block_block',
useJunctionTable: true,
foreignKeyConstraint: true
});
this.sequelize.sync().done(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!