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

Commit 68b5fb5b by Jan Aagaard Meier

Move changelog to next and re-add plain

1 parent 202fde0d
# Next # Next
- [BUG] Fixed `field` support for `increment` and `decrement`. - [BUG] Fixed `field` support for `increment` and `decrement`.
- [FEATURE/BUG] Raw queries always return all results (including affected rows etc). This means you should change all promise listeners on `sequelize.query` to use `.spread` instead of `.then`, unless you are passing a query type.
#### Backwards compatability changes
- The default query type for `sequelize.query` is now `RAW` - this means that two arguments (results and metadata) will be returned by default and you should use `.spread`
- The 4th argument to `sequelize.query` has been deprecated in favor of `options.replacements`
# 2.0.0-rc8 # 2.0.0-rc8
- [FEATURE] CLS Support. CLS is also used to automatically pass the transaction to any calls within the callback chain when using `sequelize.transaction(function() ...`. - [FEATURE] CLS Support. CLS is also used to automatically pass the transaction to any calls within the callback chain when using `sequelize.transaction(function() ...`.
...@@ -8,11 +13,6 @@ ...@@ -8,11 +13,6 @@
- [FEATURE] Validations are now enabled by default for upsert. - [FEATURE] Validations are now enabled by default for upsert.
- [FEATURE] Preliminary support for `include.through.where` - [FEATURE] Preliminary support for `include.through.where`
- [SECURITY/BUG] Fixed injection issue in direction param for order - [SECURITY/BUG] Fixed injection issue in direction param for order
- [FEATURE/BUG] Raw queries always return all results (including affected rows etc). This means you should change all promise listeners on `sequelize.query` to use `.spread` instead of `.then`, unless you are passing a query type.
#### Backwards compatability changes
- The default query type for `sequelize.query` is now `RAW` - this means that two arguments (results and metadata) will be returned by default and you should use `.spread`
- The 4th argument to `sequelize.query` has been deprecated in favor of `options.replacements`
# 2.0.0-rc7 # 2.0.0-rc7
- [FEATURE] Throw an error if no where clause is given to `Model.destroy()`. - [FEATURE] Throw an error if no where clause is given to `Model.destroy()`.
......
...@@ -650,6 +650,7 @@ module.exports = (function() { ...@@ -650,6 +650,7 @@ module.exports = (function() {
* @param {Transaction} [options.transaction=null] The transaction that the query should be executed under * @param {Transaction} [options.transaction=null] The transaction that the query should be executed under
* @param {String} [options.type='RAW'] The type of query you are executing. The query type affects how results are formatted before they are passed back. The type is a string, but `Sequelize.QueryTypes` is provided as convenience shortcuts. * @param {String} [options.type='RAW'] The type of query you are executing. The query type affects how results are formatted before they are passed back. The type is a string, but `Sequelize.QueryTypes` is provided as convenience shortcuts.
* @param {Boolean} [options.nest=false] If true, transforms objects with `.` separated property names into nested objects using [dottie.js](https://github.com/mickhansen/dottie.js). For example { 'user.username': 'john' } becomes { user: { username: 'john' }}. When `nest` is true, the query type is assumed to be `'SELECT'`, unless otherwise specified * @param {Boolean} [options.nest=false] If true, transforms objects with `.` separated property names into nested objects using [dottie.js](https://github.com/mickhansen/dottie.js). For example { 'user.username': 'john' } becomes { user: { username: 'john' }}. When `nest` is true, the query type is assumed to be `'SELECT'`, unless otherwise specified
* @param {Boolean} [options.plain=false] Sets the query type to `SELECT` and return a single row
* @param {Object|Array} [options.replacements] Either an object of named parameter replacements in the format `:param` or an array of unnamed replacements to replace `?` in your SQL. * @param {Object|Array} [options.replacements] Either an object of named parameter replacements in the format `:param` or an array of unnamed replacements to replace `?` in your SQL.
* *
* @return {Promise} * @return {Promise}
...@@ -699,7 +700,7 @@ module.exports = (function() { ...@@ -699,7 +700,7 @@ module.exports = (function() {
} }
if (!options.type) { if (!options.type) {
if (options.nest) { if (options.nest || options.plain) {
options.type = QueryTypes.SELECT; options.type = QueryTypes.SELECT;
} else { } else {
options.type = QueryTypes.RAW; options.type = QueryTypes.RAW;
......
...@@ -1393,14 +1393,14 @@ describe(Support.getTestDialectTeaser('Model'), function() { ...@@ -1393,14 +1393,14 @@ describe(Support.getTestDialectTeaser('Model'), function() {
}).then(function(tobi) { }).then(function(tobi) {
return tobi.destroy(); return tobi.destroy();
}).then(function() { }).then(function() {
return self.sequelize.query('SELECT * FROM paranoidusers WHERE username=\'Tobi\''); return self.sequelize.query('SELECT * FROM paranoidusers WHERE username=\'Tobi\'', { plain: true});
}).spread(function(result) { }).then(function(result) {
expect(result[0].username).to.equal('Tobi'); expect(result.username).to.equal('Tobi');
return User.destroy({where: {username: 'Tony'}}); return User.destroy({where: {username: 'Tony'}});
}).then(function() { }).then(function() {
return self.sequelize.query('SELECT * FROM paranoidusers WHERE username=\'Tony\''); return self.sequelize.query('SELECT * FROM paranoidusers WHERE username=\'Tony\'', { plain: true});
}).spread(function(result) { }).then(function(result) {
expect(result[0].username).to.equal('Tony'); expect(result.username).to.equal('Tony');
return User.destroy({where: {username: ['Tony', 'Max']}, force: true}); return User.destroy({where: {username: ['Tony', 'Max']}, force: true});
}).then(function() { }).then(function() {
return self.sequelize.query('SELECT * FROM paranoidusers', null, {raw: true}); return self.sequelize.query('SELECT * FROM paranoidusers', null, {raw: true});
......
...@@ -428,15 +428,15 @@ describe(Support.getTestDialectTeaser('Sequelize'), function() { ...@@ -428,15 +428,15 @@ describe(Support.getTestDialectTeaser('Sequelize'), function() {
}.bind(this)).to.throw(TypeError, 'options.transaction is required'); }.bind(this)).to.throw(TypeError, 'options.transaction is required');
}); });
it('one value', function() { it.only('one value', function() {
return this.sequelize.transaction().bind(this).then(function(t) { return this.sequelize.transaction().bind(this).then(function(t) {
this.t = t; this.t = t;
return this.sequelize.set({ foo: 'bar' }, { transaction: t }); return this.sequelize.set({ foo: 'bar' }, { transaction: t });
}).then(function() { }).then(function() {
return this.sequelize.query('SELECT @foo as `foo`', { transaction: this.t, type: this.sequelize.QueryTypes.SELECT }); return this.sequelize.query('SELECT @foo as `foo`', { plain: true, transaction: this.t });
}).then(function(data) { }).then(function(data) {
expect(data[0]).to.be.ok; expect(data).to.be.ok;
expect(data[0].foo).to.be.equal('bar'); expect(data.foo).to.be.equal('bar');
return this.t.commit(); return this.t.commit();
}); });
}); });
...@@ -449,11 +449,11 @@ describe(Support.getTestDialectTeaser('Sequelize'), function() { ...@@ -449,11 +449,11 @@ describe(Support.getTestDialectTeaser('Sequelize'), function() {
foos: 'bars' foos: 'bars'
}, { transaction: t }); }, { transaction: t });
}).then(function() { }).then(function() {
return this.sequelize.query('SELECT @foo as `foo`, @foos as `foos`', { transaction: this.t, type: this.sequelize.QueryTypes.SELECT }); return this.sequelize.query('SELECT @foo as `foo`, @foos as `foos`', { plain: true, transaction: this.t });
}).then(function(data) { }).then(function(data) {
expect(data[0]).to.be.ok; expect(data).to.be.ok;
expect(data[0].foo).to.be.equal('bar'); expect(data.foo).to.be.equal('bar');
expect(data[0].foos).to.be.equal('bars'); expect(data.foos).to.be.equal('bars');
return this.t.commit(); return this.t.commit();
}); });
}); });
...@@ -917,8 +917,8 @@ describe(Support.getTestDialectTeaser('Sequelize'), function() { ...@@ -917,8 +917,8 @@ describe(Support.getTestDialectTeaser('Sequelize'), function() {
self self
.sequelizeWithTransaction .sequelizeWithTransaction
.query(sql, { transaction: transaction, type: self.sequelize.QueryTypes.SELECT }) .query(sql, { plain: true, transaction: transaction })
.success(function(result) { callback(parseInt(result[0].cnt, 10)); }); .success(function(result) { callback(parseInt(result.cnt, 10)); });
}; };
TransactionTest.sync({ force: true }).success(function() { TransactionTest.sync({ force: true }).success(function() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!