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

Commit 6d6dae50 by Sascha Depold

added support for stored procedure calls

1 parent 8bfc6af3
...@@ -69,6 +69,8 @@ module.exports = (function() { ...@@ -69,6 +69,8 @@ module.exports = (function() {
result = handleShowTableQuery.call(this, data) result = handleShowTableQuery.call(this, data)
} else if (isShowOrDescribeQuery.call(this)) { } else if (isShowOrDescribeQuery.call(this)) {
result = data result = data
} else if (isCallQuery.call(this)) {
result = data[0]
} }
return result return result
...@@ -269,6 +271,14 @@ module.exports = (function() { ...@@ -269,6 +271,14 @@ module.exports = (function() {
return result 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 The function takes the result of the query execution and groups
......
...@@ -81,5 +81,20 @@ describe("[" + dialect.toUpperCase() + "] Sequelize", function() { ...@@ -81,5 +81,20 @@ describe("[" + dialect.toUpperCase() + "] Sequelize", function() {
}) })
}.bind(this)) }.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!