Skip to content
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

Not compatible with Bookshelf new version #55

Closed
lacivert opened this issue Dec 24, 2019 · 2 comments · Fixed by #56
Closed

Not compatible with Bookshelf new version #55

lacivert opened this issue Dec 24, 2019 · 2 comments · Fixed by #56

Comments

@lacivert
Copy link

I can use this plugin with 0.x Bookshelf but when I grab 1.x, it gives me the error:

SyntaxError: Unexpected token o in JSON at position 1
    at JSON.parse (<anonymous>)
    at constructor.jsonColumns.forEach.column (/path/to/project/node_modules/bookshelf-json-columns/dist/index.js:49:38)
    at Array.forEach (<anonymous>)
    at Child.parse (/path/to/project/node_modules/bookshelf-json-columns/dist/index.js:47:32)
    at Promise.mapSeries (/path/to/project/node_modules/bookshelf/lib/base/events.js:101:64)
    at tryCatcher (/path/to/project/node_modules/bluebird/js/release/util.js:16:23)
    at Object.gotValue (/path/to/project/node_modules/bluebird/js/release/reduce.js:166:18)
    at Object.gotAccum (/path/to/project/node_modules/bluebird/js/release/reduce.js:155:25)
    at Object.tryCatcher (/path/to/project/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/path/to/project/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/path/to/project/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromiseCtx (/path/to/project/node_modules/bluebird/js/release/promise.js:641:10)
    at _drainQueueStep (/path/to/project/node_modules/bluebird/js/release/async.js:97:12)
    at _drainQueue (/path/to/project/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/path/to/project/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/path/to/project/node_modules/bluebird/js/release/async.js:15:14)
@lacivert
Copy link
Author

lacivert commented Dec 24, 2019

I have commented the foreach code block on the parse function; it seems working for insert on jsonb columns. I haven't tested for other methods;

// this.constructor.jsonColumns.forEach(column => {
 //   if (this.attributes[column]) {
 //     console.log(column, "asdads", this.attributes[column])
 //     this.attributes[column] = JSON.parse(this.attributes[column]);
 //   }
 // });

@ricardogama
Copy link
Collaborator

Released as 3.0.0

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants