-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update() breaks when sequelize configured with raw:true #99
Comments
Makes sense. This can probably easily be fixed by changing the line you pointed out to Object.keys(typeof instance.toJSON === 'function' ? instance.toJSON() : instance).forEach(key => { |
Unfortunately my PR might have been too fast In order to update, the DOA instance is used: return instance.update(copy, options); |
The best solution I see would be replacing: return this.Model.findById(id).then(instance => { with return this.Model.findById(id, { raw: false }).then(instance => { |
Ah, I see. Well at least we know it didn't break anything else ;) I think we should do what |
Now it's been fixed via #101 in v1.4.5 |
Affects master, v1.4.3, etc.
A call to
update()
results in aModel.findById
call:/~https://github.com/feathersjs/feathers-sequelize/blob/master/src/index.js#L168
If sequelize is configured with
raw: false
(the default), this returns a DAO, with atoJSON
method, which is then called several lines later:/~https://github.com/feathersjs/feathers-sequelize/blob/master/src/index.js#L174
However, if sequelize is configured with
raw: true
, thefindById
call returns a JSON object without this method.There are two simple fixes:
toJSON
if it exists and is a function{raw: false}
as a second argument to thefindById
call to force the expected behaviourThe text was updated successfully, but these errors were encountered: