0

I have a table in Postgres with a jsonb column. I'm using Entity Framework to upsert data on this table, but I'm always getting the error

Input string was not in a correct format

because of the jsonb column.

This is an example of a query I generate:

INSERT INTO example_table (id, name, details) 
VALUES (1, 'john','{\r\n  \"age\": \"17\"\r\n}') 
ON CONFLICT (name) DO NOTHING

This is the command I'm trying to execute:

_context.ExecuteSqlRaw("INSERT INTO example_table (id, name, details) VALUES (1, 'john','{\r\n  \"age\": \"17\"\r\n}') ON CONFLICT (name) DO NOTHING");

If I remove the json the query is executed perfectly.

What am I doing wrong?

1 Answer 1

0

Json and Jsonb doesn't support \n, \r symbols. Use this:

INSERT INTO example_table (id, name, details) 
VALUES 
(1, 'john','{"age":"17"}') 
ON CONFLICT (name) DO NOTHING 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.