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

Commit 727ae363 by daleoooo Committed by Jan Aagaard Meier

Fix getting true when upsert a row to its current value with mysql (#6962)

* Fixed: 6310

* Added: test

* Fixed: 6310

* Added: test
1 parent a71f5975
......@@ -73,6 +73,7 @@ class ConnectionManager extends AbstractConnectionManager {
host: config.host,
port: config.port,
user: config.username,
flags: '-FOUND_ROWS',
password: config.password,
database: config.database,
timezone: this.sequelize.options.timezone,
......
......@@ -331,6 +331,23 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
});
it('does not update when setting current values', function() {
return this.User.create({ id: 42, username: 'john' }).bind(this).then(function() {
return this.User.findById(42);
}).then(function(user) {
return this.User.upsert({ id: user.id, username: user.username });
}).then(function(created) {
if (dialect === 'sqlite') {
expect(created).to.be.undefined;
} else {
// After set node-mysql flags = '-FOUND_ROWS' in connection of mysql,
// result from upsert should be false when upsert a row to its current value
// https://dev.mysql.com/doc/refman/5.7/en/insert-on-duplicate.html
expect(created).to.equal(false);
}
});
});
it('Works when two separate uniqueKeys are passed', function() {
var User = this.sequelize.define('User', {
username: {
......@@ -372,8 +389,6 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
});
});
});
}
});
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!