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

Commit e0ab06d1 by Sushant Committed by Mick Hansen

Fixed #5675, beforeFind issue with options modification (#6167)

* fixed beforeFind issue with options modification

* missing ;
1 parent 11960f26
......@@ -15,6 +15,7 @@
- [ADDED] before/after Save hook [#2702](https://github.com/sequelize/sequelize/issues/2702)
- [ADDED] Remove hooks by reference [#6155](https://github.com/sequelize/sequelize/issues/6155)
- [ADDED] before/after Upsert hook [#3965](https://github.com/sequelize/sequelize/issues/3965)
- [FIXED] Modifying `options` in `beforeFind` throws error [#5675](https://github.com/sequelize/sequelize/issues/5675)
## BC breaks:
- Range type bounds now default to [postgres default](https://www.postgresql.org/docs/9.5/static/rangetypes.html#RANGETYPES-CONSTRUCT) `[)` (inclusive, exclusive), previously was `()` (exclusive, exclusive)
......
......@@ -1297,13 +1297,13 @@ class Model {
}
return Promise.try(() => {
this._conformOptions(options, this);
this.$injectScope(options);
if (options.hooks) {
return this.runHooks('beforeFind', options);
}
}).then(() => {
this._conformOptions(options, this);
this._expandIncludeAll(options);
if (options.hooks) {
......
......@@ -30,6 +30,15 @@ describe(Support.getTestDialectTeaser('Hooks'), function() {
]);
});
it('allow changing attributes via beforeFind #5675', function() {
this.User.beforeFind((options) => {
options.attributes = {
include: ['id']
};
});
return this.User.findAll({});
});
describe('on success', function() {
it('all hooks run', function() {
var beforeHook = false
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!