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

Commit 0990ab65 by José Moreira

sequelize.set: make options.transaction required

1 parent 45f8a7c3
Showing with 19 additions and 4 deletions
......@@ -560,9 +560,9 @@ module.exports = (function() {
* If you want to set variables for a specific query, you should create a transaction and pass it on options.
*
* @method set
* @param {Object} Object with multiple variables.
* @param {Object} [options={}] Query options.
* @param {Transaction} [options.transaction=null] The transaction that the query should be executed under
* @param {Object} variables Object with multiple variables.
* @param {Object} options={} Query options.
* @param {Transaction} options.transaction=null The transaction that the query should be executed under
* @return {Promise}
*
*/
......@@ -572,6 +572,10 @@ module.exports = (function() {
// Prepare options
options = Utils._.extend( {}, this.options.set, typeof options === 'object' && options || {} );
if( ! options.transaction || ! ( options.transaction instanceof Transaction ) ) {
return Promise.rejected( new TypeError("options.transaction is required") );
}
// Override some options, since this isn't a SELECT
options.raw = true;
options.plain = true;
......
......@@ -449,7 +449,18 @@ describe(Support.getTestDialectTeaser("Sequelize"), function () {
}
})
describe('set', function() {
describe.only('set', function() {
it("should return an promised error if transaction isn't defined", function ( done ) {
var S = this.sequelize;
S.set({ foo: 'bar' })
.done( function ( err ) {
expect( err ).to.be.an.instanceof( TypeError )
done();
});
})
it("one value", function ( done ) {
var S = this.sequelize;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!