-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Returning Invalid syntax for type jsonb on arrays #857
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
Comments
Same issue here, trying to insert an array of objects in a jsonb column. My JS array : const coordinates = [{latitude:43.654327, longitude:7.2010627}, {latitude:43.65835, longitude:7.2018366}] |
What is your query? |
@joskuijpers Here is a simple one : client.query('CREATE TABLE IF NOT EXISTS test_jsonb (test jsonb)', [], (err, _) => {
if (err) return l(err)
const coordinates = [
{ latitude: 1, longitude: 1 }
]
client.query('INSERT INTO test_jsonb (test) VALUES ($1)', [coordinates], (err, _) => {
if (err) return l(err)
return r()
})
}) The error :
If I wrap We can see according to the error that the array is turned into an object, so the syntax |
Could you try using $1::json and $1::jsonb? |
Same error in both cases. |
See #1143. |
I think this is related to #442, but this time with jsonb. Can't insert/update a jsonb column directly with the javascript object. If I use JSON.stringify first, it works. Error is:
The text was updated successfully, but these errors were encountered: