-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Error: invalid input syntax for type json #1143
Comments
What is the error?
|
The error is below (also in the gist): |
probably related to #1143 |
@abimelex What do you mean by "parsing it to jsonString". Is there a specific postgres command that you are using as a workaround? |
I found the problem. When parsing the value to something postgres understands, the input is checked on its type. To solve this, there would need to be a check on the true input type (when using ::type). If this typecast is not used there is no way to know whether to parse the data as array or as object. Sadly, the content of the query string is not used anywhere in node-postgres currently. I am open to solutions. |
I don't necessarily have any solutions, but I did encounter other errors when trying to send the JSON in various formats, for example without the single quotes, or not stringified. I got errors such as : References: |
Reopened #442. |
I have the following situation. I am using the pg driver version 4.5.3 (yes I know its old, but can't yet refactor or switch to new version), along with Node 4.x, Express 4, and a postgres 9.5 database. I have a table that looks like this:
code to recreate(https://gist.github.com/PythonDevOp/aced5918de770365258690cecbceee92)
I am calling a function, taking an array of data, and passing that array as a parameter using commands in the following gist:
https://gist.github.com/PythonDevOp/f7a7f95fd7fa11a06420c54c5be4501a
However, I am getting an error when trying to insert the data via the node postgres driver. When I call the function in pgadmin or via the console, it works as expected. When calling this via the application, something breaks and I can't tell where. I am guessing this is a bug with the postgres driver in how it parses JSONB.
Any ideas?
The text was updated successfully, but these errors were encountered: