Issue with storing multiline text with newlines in PostgreSQL
Hello Neon Support Team,
I am experiencing an issue when trying to store multiline text containing newline characters (\n) in a TEXT column in my PostgreSQL database hosted on Neon.tech.
I perform an UPDATE query like this:
UPDATE product
SET description = E'Streamline your \nsalad preparation'
WHERE id = 100375;
Or, from a Python client using psycopg2, I pass a string with embedded newline characters in the description field during INSERT or UPDATE.
However, after the operation, the newline characters are not preserved in the database — the text appears as a single line without any line breaks.
I verified this by querying the field using:
SELECT ENCODE(description::bytea, 'escape') FROM product WHERE id = 100375;
But the result shows the text without \n escape sequences, confirming the newlines are lost.
I also tried alternative approaches like concatenating chr(10) in the query, but the newline characters still do not get stored.
Could you please advise if there are any Neon-specific settings, configurations, or restrictions that might affect storing multiline text with newline characters? Is there any recommended way to ensure that such text is stored and retrieved correctly?
Thank you for your assistance.
0 Replies