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

Commit 9ef6a23c by Meg Sharkey

more logging fixes

1 parent cb7adce6
......@@ -21,6 +21,7 @@ module.exports = (function() {
self.__factory.target.findAllJoin(self.__factory.connectorModel.tableName, {where: where})
.on('success', function(objects) { customEventEmitter.emit('success', objects) })
.on('failure', function(err){ customEventEmitter.emit('failure', err) })
.on('sql', function(sql) { customEventEmitter.emit('sql', sql)})
})
return customEventEmitter.run()
......@@ -31,6 +32,7 @@ module.exports = (function() {
destroyObsoleteAssociations.call(this, oldAssociations, newAssociations)
.error(function(err) { emitter.emit('failure', err) })
.on('sql', function(sql) { emitter.emit('sql', sql) })
.success(function() {
var chainer = new Utils.QueryChainer
, association = self.__factory.target.associations[self.__factory.associationAccessor]
......@@ -49,6 +51,7 @@ module.exports = (function() {
.run()
.success(function() { emitter.emit('success', newAssociations) })
.error(function(err) { emitter.emit('failure', err) })
.on('sql', function(sql) { emitter.emit('sql', sql) })
})
}
......@@ -82,6 +85,7 @@ module.exports = (function() {
.run()
.success(function() { emitter.emit('success', null) })
.error(function(err) { emitter.emit('failure', err) })
.on('sql', function(sql) { emitter.emit('sql', sql) })
}
})
})
......
......@@ -68,6 +68,7 @@ module.exports = (function() {
.createTable(self.tableName, self.attributes, options)
.success(function() { emitter.emit('success', self) })
.error(function(err) { emitter.emit('failure', err) })
.on('sql', function(sql) { emitter.emit('sql', sql) })
}
if(options.force)
......
......@@ -99,6 +99,7 @@ module.exports = (function() {
self.fails.push(err)
finish.call(self)
})
.on('sql', function(sql){ self.eventEmitter.emit('sql', sql) })
}
var finish = function() {
......
......@@ -240,6 +240,45 @@ describe('HasMany', function() {
})
})
it("allows join table to be specified", function() {
Helpers.async(function(done) {
var Child = sequelize.define('Child', { name: Sequelize.STRING }, {underscore: true, freezeTableName: true})
var Parent = sequelize.define('Parent', { name: Sequelize.STRING }, {underscore: true, freezeTableName: true})
var ParentJoin = sequelize.define('ParentRelationship', { parent_id: Sequelize.INTEGER, child_id: Sequelize.INTEGER }, {underscore: true, freezeTableName: true})
Parent.hasMany(Child, {as: 'Children', foreignKey: 'child_id', joinTableName: 'ParentRelationship'})
Child.hasMany(Parent, {as: 'Parents', foreignKey: 'parent_id', joinTableName: 'ParentRelationship'})
var parents = []
ParentJoin.sync({force: true}).success(function() {
Parent.sync({force: true}).success(function() {
Child.sync({force: true}).success(function() {
Parent.create({name: 'mom'}).success(function(mom) {
parents.push(mom)
Parent.create({name: 'dad'}).success(function(dad) {
parents.push(dad)
Child.create({name: 'baby'}).success(function(baby) {
baby.setParents(parents).success(function(){
parents[0].getChildren().success(function(children){
expect(children).not.toBe(null)
expect(children.length).toBeDefined()
expect(children.length).toEqual(1)
expect(children[0]).toBeDefined()
expect(children[0].name).toEqual('baby')
done()
})
})
})
})
})
})
})
})
})
})
it("gets and sets the connector models", function() {
Helpers.async(function(done) {
var Person = sequelize.define('Person', { name: Sequelize.STRING })
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!