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

Commit 6b9a110e by Sascha Depold

first execution of api sugar works

1 parent 3ed27be1
Showing with 28 additions and 1 deletions
......@@ -71,6 +71,7 @@ module.exports = (function() {
var dataset = this.dataset()
, result = dataset[methodName].apply(dataset, arguments)
, dialect = this.daoFactoryManager.sequelize.options.dialect
, self = this
result.toSql = function() {
var query = result.toQuery()
......@@ -78,7 +79,7 @@ module.exports = (function() {
}
result.exec = function() {
console.log("would exec", result.toSql())
return self.QueryInterface.queryAndEmit([result.toSql(), self, { type: 'SELECT' }], 'snafu')
}
return result
......
......@@ -2701,5 +2701,31 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
expect(sql).to.equal(sqlMap[dialect])
})
})
describe("exec", function() {
beforeEach(function(done) {
var self = this
this
.User
.create({ username: "foo" })
.then(function() {
return self.User.create({ username: "bar" })
})
.then(function() { done() })
})
it("selects all users with name 'foo'", function(done) {
this
.User
.where({ username: "foo" })
.exec()
.success(function(users) {
expect(users).to.have.length(1)
expect(users[0].username).to.equal("foo")
done()
})
})
})
})
})
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!