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

Commit 6d6dae50 by Sascha Depold

added support for stored procedure calls

1 parent 8bfc6af3
......@@ -69,6 +69,8 @@ module.exports = (function() {
result = handleShowTableQuery.call(this, data)
} else if (isShowOrDescribeQuery.call(this)) {
result = data
} else if (isCallQuery.call(this)) {
result = data[0]
}
return result
......@@ -269,6 +271,14 @@ module.exports = (function() {
return result
}
var isCallQuery = function() {
var result = false
result = result || (this.sql.toLowerCase().indexOf('call') === 0)
return result
}
/**
The function takes the result of the query execution and groups
......
......@@ -25,7 +25,7 @@ module.exports = (function() {
this.client.query(this.sql, function(err, results, fields) {
this.emit('sql', this.sql)
if (err) {
this.emit('error', err, this.callee)
} else {
......
......@@ -81,5 +81,20 @@ describe("[" + dialect.toUpperCase() + "] Sequelize", function() {
})
}.bind(this))
})
it('executes stored procedures', function(done) {
this.sequelize.query(this.insertQuery).success(function() {
this.sequelize.query('DROP PROCEDURE IF EXISTS foo').success(function() {
this.sequelize.query(
"CREATE PROCEDURE foo()\nSELECT * FROM " + this.User.tableName + ";"
).success(function() {
this.sequelize.query('CALL foo()').success(function(users) {
expect(users.map(function(u){ return u.username })).toEqual(['john'])
done()
})
}.bind(this))
}.bind(this))
}.bind(this))
})
})
})
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!