Closed
Description
To repro:
- Using a postgres 9.2 database, create a table with a column of type json.
- Run an insert statement, passing in a javascript array as the parameter value for that column.
- pg generates an incorrect json string, and postgres errors with "invalid input syntax for type json".
For example, if my input array is:
["foo", "bar", "baz"]
The generated json string from pg is:
{"foo", "bar", "baz"}
In other words, the array gets wrapped with curly braces not square brackets.
You can see where this is happening in lib/utils.js. The issue is that we are trying to treat the array as a postgres array input, even though this should be treated as a json input because the database column is of type json.
I'd be happy to do a PR to fix this, but i'm not sure of the right strategy here -- it seems like to fix this problem, we need to know the column datatype, not just the input datatype? do we have that context available?
Thanks,
Seth
Metadata
Metadata
Assignees
Labels
No labels