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

What is this plugin for #15

Closed
catamphetamine opened this issue Apr 29, 2016 · 2 comments
Closed

What is this plugin for #15

catamphetamine opened this issue Apr 29, 2016 · 2 comments

Comments

@catamphetamine
Copy link

Today I tested bookshelf with Postgres JSON column without this plugin and it works.
What for is this plugin then?

@ricardogama
Copy link
Collaborator

ricardogama commented May 2, 2016

I ran the test suite with the last knex and bookshelf versions and it seems no support for parsing JSON columns has been added yet. Did you try to do something like this?

Model.forge().save({ foo: ['bar'] });

@catamphetamine
Copy link
Author

catamphetamine commented May 2, 2016

Hmm, you're using JSON arrays and knex explicitly says:

Note that when setting an array (or a value that could be an array) as the value of a json or jsonb column, you should use JSON.stringify() to convert your value to a string prior to passing it to the query builder, e.g.

knex.table('users')
  .where({id: 1})
  .update({json_data: JSON.stringify(mightBeAnArray)});

This is because postgresql has a native array type which uses a syntax incompatible with json; knex has no way of knowing which syntax to use, and calling JSON.stringify() forces json-style syntax.

Ok then, your plugin differs in that it supports JSON arrays.

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

No branches or pull requests

2 participants