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

Commit 0f9e5f30 by Sascha Depold

do not check the autoIncrementField if no callee was passed. fix #291

1 parent 8494f951
...@@ -180,6 +180,7 @@ module.exports = (function() { ...@@ -180,6 +180,7 @@ module.exports = (function() {
} }
var handleInsertQuery = function(results, metaData) { var handleInsertQuery = function(results, metaData) {
if (this.callee) {
// add the inserted row id to the instance // add the inserted row id to the instance
var autoIncrementField = this.callee.__factory.autoIncrementField var autoIncrementField = this.callee.__factory.autoIncrementField
, id = null , id = null
...@@ -189,6 +190,7 @@ module.exports = (function() { ...@@ -189,6 +190,7 @@ module.exports = (function() {
this.callee[autoIncrementField] = id this.callee[autoIncrementField] = id
} }
}
var isShowTableQuery = function() { var isShowTableQuery = function() {
return (this.sql.toLowerCase().indexOf('show tables') === 0) return (this.sql.toLowerCase().indexOf('show tables') === 0)
......
...@@ -7,10 +7,8 @@ buster.spec.expose() ...@@ -7,10 +7,8 @@ buster.spec.expose()
describe('Sequelize', function() { describe('Sequelize', function() {
before(function(done) { before(function(done) {
var self = this
Helpers.initTests({ Helpers.initTests({
beforeComplete: function(sequelize) { self.sequelize = sequelize }, beforeComplete: function(sequelize) { this.sequelize = sequelize }.bind(this),
onComplete: done onComplete: done
}) })
}) })
...@@ -27,4 +25,22 @@ describe('Sequelize', function() { ...@@ -27,4 +25,22 @@ describe('Sequelize', function() {
expect(this.sequelize.isDefined('Project')).toBeTrue() expect(this.sequelize.isDefined('Project')).toBeTrue()
}) })
}) })
describe('query', function() {
before(function(done) {
this.User = this.sequelize.define('User', {
username: Helpers.Sequelize.STRING
})
this.User.sync().success(done)
})
it('=>executes a query the internal way', function(done) {
var sql = "INSERT INTO " + this.User.tableName + " (username) VALUES ('john')"
this.sequelize.query(sql, null, { raw: true }).success(function(result) {
expect(result).toBeNull()
done()
})
})
})
}) })
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!