N
Neon2y ago
rising-crimson

Postgres JSON field

Hi, is there a specific way to use JSON data in neon? I have a JSON field in one of my tables I can insert it to my local postgres database on my machine but when I send it to Neon I get a syntax error.
11 Replies
rare-sapphire
rare-sapphire2y ago
Neon
Postgres JSON data types - Neon Docs
Postgres supports JSON (JavaScript Object Notation) data types, providing a flexible way to store and manipulate semi structured data. The two types are JSON and JSONB. The functions work similarly, b...
rising-crimson
rising-crimsonOP2y ago
Thanks. Very strange when you run the query in Neon SQL editor it works but when I send the query from my code it hangs.
absent-sapphire
absent-sapphire2y ago
If you could share both the query and the error, that would help greatly What postgres client are you using in your project? JSON in sql is quite sensitive to quotation marks, which can also be quite annoying to work with in code
rising-crimson
rising-crimsonOP2y ago
I am using https://github.com/denodrivers/postgres which is not well established yet I think.
GitHub
GitHub - denodrivers/postgres: PostgreSQL driver for Deno
PostgreSQL driver for Deno. Contribute to denodrivers/postgres development by creating an account on GitHub.
rising-crimson
rising-crimsonOP2y ago
This is my query. my JSON fields are JSONB. do you think I should change to JSON . I am not getting any error connection just seems to be haning
absent-sapphire
absent-sapphire2y ago
Are you using backticks (`) for the query string in your code? or are you using a query parameter with the json object as an argument?
rising-crimson
rising-crimsonOP2y ago
I am using query parameter. I am removing parts of JSON to test maybe my JSON is too big to go over the network
rising-crimson
rising-crimsonOP2y ago
so I tested and connection hangs if the JSON string is more than 2455 characters
rising-crimson
rising-crimsonOP2y ago
if I add another character to above JSON it doesnt work
absent-sapphire
absent-sapphire2y ago
That is very odd. I'll take a look, I do think it's likely a bug in deno-postgres, never heard anything like this before, besides https://neon.tech/blog/when-limit-9-works-but-limit-10-hangs which was another bug in a client side driver
Neon
When LIMIT 9 works but LIMIT 10 hangs - Neon
I got a Slack message from colleagues at a major partner. They’d updated their dev environment to support WebSockets, so that Neon’s serverless driver could be used there, but then they’d run into a weird issue.  The nub of it was this: This hangs: This works Reproducibly, the query without an ORDER BY ran fine […]
rising-crimson
rising-crimsonOP2y ago
thanks @Conrad Ludgate yes probably deno-postgres issue. but strange that it works against local postgres instance on my machine

Did you find this page helpful?