Fails to insert jsonb values in Postgres
See original GitHub issueWe have a table with a field of type jsonb
, which becomes string
in the generated type, but it doesn’t seem to work when inserting a string with the json format, the exception I get is:
Npgsql.PostgresException (0x80004005): 42804: column "test" is of type jsonb but expression is of type text
Exception data:
Severity: ERROR
SqlState: 42804
MessageText: column "test" is of type jsonb but expression is of type text
Hint: You will need to rewrite or cast the expression.
Position: 97
File: parse_target.c
Line: 588
Routine: transformAssignedExpr
when trying to insert """{"publisher": "test"}"""
.
Would you be able to help with this?
Issue Analytics
- State:
- Created 2 years ago
- Comments:22 (21 by maintainers)
Top Results From Across the Web
pgadmin: can't insert jsonb[] values with strings
I have jsonb[] column and it allows me to insert some nested arrays, but only with number values like {{1,2,3}, {4,5,6}, {7,8,9}} ....
Read more >Getting error when trying to insert JSON field in Postgres
I am getting below error: ERROR: syntax error at or near "{" LINE 1: ...nc_desc,user_id,container_path) ...
Read more >Postgresql INSERT Issue (JSONB) - Questions
So the scenario is that I'm inserting a JSON object into a Postgresql table (to a JSONB column) for warehousing purposes.
Read more >Inserting JSON into PostgreSQL: 3 Comprehensive Aspects
To work with JSON and PostgreSQL, you must first understand the following aspects of Inserting JSON into PostgreSQL:
Read more >Insert Jsonb into Postgresql Database
Hi, i need to insert some data into a Postgresql Database. ... ERROR: column "data" is of type jsonb but expression is of...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Oh, that’s genius 😄 I almost made it work with this new suggestion … will need to clean up the mess and open a PR in the beginning of the week. Yeah, I am enjoying the process, thanks for the help!
The plot thickens!
It seems that we may need to check for the existence of the column metadata attribute in the
InsertExpressionBuilder
andUpdateExpressionBuilder
when record properties are being added.The nice thing is that the
LinqExpressionVisitors.visitPropertySelector
returnsMemberInfo
that should give us the attribute metadata for free. So if any metadata exists, it can be added to theInsertQuerySpec
orUpdateQuerySpec
in the order at which the columns were added.Then the
QueryContext
insert and update methods should have enough info to create a Map of parameter type info to theBuildCommand
methods.