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

Commit 48426b66 by qjroberts

Fix increment and decrement usage with schemata

1 parent 0655153e
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
- [BUG] Fixed a bug where plain objects like `{ in: [...] }` were not properly converted to SQL when combined with a sequelize method (`fn`, `where` etc.). Closes [#2077](https://github.com/sequelize/sequelize/issues/2077) - [BUG] Fixed a bug where plain objects like `{ in: [...] }` were not properly converted to SQL when combined with a sequelize method (`fn`, `where` etc.). Closes [#2077](https://github.com/sequelize/sequelize/issues/2077)
- [BUG] Made the default for array search in postgres exact comparison instead of overlap - [BUG] Made the default for array search in postgres exact comparison instead of overlap
- [BUG] Allow logging from individual functions even though the global logging setting is false. Closes [#2571](https://github.com/sequelize/sequelize/issues/2571) - [BUG] Allow logging from individual functions even though the global logging setting is false. Closes [#2571](https://github.com/sequelize/sequelize/issues/2571)
- [BUG] Allow increment/decrement operations when using schemata
- [INTERNALS] Update `inflection` dependency to v1.5.2 - [INTERNALS] Update `inflection` dependency to v1.5.2
#### Backwards compatability changes #### Backwards compatability changes
......
...@@ -377,7 +377,7 @@ module.exports = (function() { ...@@ -377,7 +377,7 @@ module.exports = (function() {
} }
var replacements = { var replacements = {
table: this.quoteIdentifiers(tableName), table: this.quoteTable(tableName),
values: values.join(','), values: values.join(','),
where: this.getWhereConditions(where) where: this.getWhereConditions(where)
}; };
......
...@@ -842,7 +842,7 @@ module.exports = (function() { ...@@ -842,7 +842,7 @@ module.exports = (function() {
countOrOptions.attributes[updatedAtAttr] = this.Model.__getTimestamp(updatedAtAttr); countOrOptions.attributes[updatedAtAttr] = this.Model.__getTimestamp(updatedAtAttr);
} }
return this.QueryInterface.increment(this, this.QueryInterface.QueryGenerator.addSchema(this.Model.tableName, this.Model.options.schema), values, where, countOrOptions); return this.QueryInterface.increment(this, this.QueryInterface.QueryGenerator.addSchema(this.Model), values, where, countOrOptions);
}; };
/** /**
......
'use strict';
var chai = require('chai')
, expect = chai.expect
, Support = require(__dirname + '/support')
, DataTypes = require(__dirname + '/../lib/data-types');
chai.config.includeStack = true;
describe(Support.getTestDialectTeaser('Schema'), function () {
before(function() {
return this.sequelize.createSchema('testschema');
});
after(function() {
return this.sequelize.dropSchema('testschema');
});
beforeEach(function() {
this.User = this.sequelize.define('User', {
aNumber: { type: DataTypes.INTEGER }
}, {
schema: 'testschema'
});
return this.User.sync({ force: true });
});
it('supports increment', function () {
return this.User.create({ aNumber: 1 }).then(function(user) {
return user.increment('aNumber', { by: 3 });
}).then(function(result) {
return result.reload();
}).then(function(user) {
expect(user).to.be.ok;
expect(user.aNumber).to.be.equal(4);
});
});
it('supports decrement', function () {
return this.User.create({ aNumber: 10 }).then(function(user) {
return user.decrement('aNumber', { by: 3 });
}).then(function(result) {
return result.reload();
}).then(function(user) {
expect(user).to.be.ok;
expect(user.aNumber).to.be.equal(7);
});
});
});
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!