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

Commit d44300d2 by sdepold

renamed isManyMany to useJunctionTable

1 parent 6e37a9f6
......@@ -9,7 +9,7 @@ module.exports = (function() {
this.source = srcDAO
this.target = targetDAO
this.options = options
this.isManyMany = this.options.isManyMany === undefined ? true : this.options.isManyMany
this.useJunctionTable = this.options.useJunctionTable === undefined ? true : this.options.useJunctionTable
this.isSelfAssociation = (this.source.tableName == this.target.tableName)
this.associationAccessor = this.combinedName = this.options.joinTableName || Utils.combineTableNames(
......@@ -35,7 +35,7 @@ module.exports = (function() {
// is there already a single sided association between the source and the target?
// or is the association on the model itself?
if ((this.isSelfAssociation && this.isManyMany) || multiAssociation) {
if ((this.isSelfAssociation && this.useJunctionTable) || multiAssociation) {
// remove the obsolete association identifier from the source
if(this.isSelfAssociation) {
this.foreignIdentifier = Utils._.underscoredIf((this.options.as || this.target.tableName) + 'Id', this.options.underscored)
......
......@@ -95,13 +95,13 @@ describe('HasMany', function() {
it("should allow selfAssociation to be single linked (only one DAO is created)", function() {
var oldLength = sequelize.daoFactoryManager.daos.length;
var Comment = sequelize.define('Comment', { content: Sequelize.STRING })
Comment.belongsTo(Comment, {as: "Parent"});
Comment.hasMany(Comment, {as: 'Children', foreignKey: "ParentId", isManyMany: false})
Comment.hasMany(Comment, {as: 'Children', foreignKey: "ParentId", useJunctionTable: false})
expect(sequelize.daoFactoryManager.daos.length).toEqual(oldLength + 1)
Helpers.async(function(done) {
Comment.sync({force: true}).success(function() {
done()
......@@ -115,7 +115,7 @@ describe('HasMany', function() {
done()
})
})
Helpers.async(function(done) {
Comment.create({ content: 'child1' }).success(function(child1) {
child1.setParent(parent).success(function() {
......@@ -123,7 +123,7 @@ describe('HasMany', function() {
})
})
})
Helpers.async(function(done) {
Comment.create({ content: 'child2' }).success(function(child2) {
child2.setParent(parent).success(function() {
......@@ -140,15 +140,15 @@ describe('HasMany', function() {
})
})
})
it("should still use many to many for selfAssociation by default (two DAOs are created)", function() {
it("should still use many to many for selfAssociation by default (two DAOs are created)", function() {
Helpers.async(function(done) {
var oldLength = sequelize.daoFactoryManager.daos.length;
var Comment = sequelize.define('Comment', { content: Sequelize.STRING })
Comment.belongsTo(Comment, {as: "Parent"})
Comment.hasMany(Comment, {as: 'Children'})
expect(sequelize.daoFactoryManager.daos.length).toEqual(oldLength + 2)
done();
})
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!