-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
model.refresh is not working properly | bug #42
Comments
It seems the value is already parsed when the plugin It can also happens that the value comes already parsed from the fetch, which is unlikely, but I wonder if the model data you are refreshing was inserted with the plugin or with a raw query for example. |
I am not extending initialize or save method |
I can't reproduce this error, the only thing that occurs to me is that the fetched value is not a valid stringified JSON object. Can debug what value is being parsed when the error occurs? Also, a snippet of your model and the code you're executing would help, along with the bookshelf and sqlite3 versions you're using. |
This issue is happing when I use increment. Here is simple example const model = await Model.where({id}).fetch();
await model.query().increment('likes', 1);
await model.refresh(); Your package is using parsed data. |
I am using temp fix for this but it is not ideal because it can fail for pure string values this.attributes[column] = typeof this.attributes[column] === 'string'
? JSON.parse(this.attributes[column])
: this.attributes[column]; |
Ok I got the bug, it happens when querying updates or inserts through knex, which does not trigger the I'll try to fix until the end of the week, thanks for the info! |
Released as 2.0.1. |
When I call model.refresh() I will get next exception:
Instead of this everything else working fine.
bookshelf-json-columns@2.0.0 with sqllite
The text was updated successfully, but these errors were encountered: