# Postgresql INSERT Issue (JSONB)

**URL:** <https://community.n8n.io/t/postgresql-insert-issue-jsonb/6890>\
**Category:** Questions\
**Created:** [July 24, 2021, 4:22pm UTC](https://community.n8n.io/t/postgresql-insert-issue-jsonb/6890 "2021-07-24T16:22:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sigmet](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/sigmet/32/5629_2.png) [@sigmet](https://community.n8n.io/u/sigmet)\
**Post date:** [July 24, 2021, 4:22pm UTC](https://community.n8n.io/t/postgresql-insert-issue-jsonb/6890/1 "2021-07-24T16:22:28Z")

</div>

I need some advice where I’m heading wrong.  
So the scenario is that I’m inserting a JSON object into a Postgresql table (to a JSONB column) for warehousing purposes. When I run the query manually on the database everything works as expected but on the n8n Postgres node it fails with a syntax error due to the Postgres node adding a unexpected [object Object] reference.

The issue can be replicated by using the query that’s visible in the first screen shot below (note the [object Object] in values).

```
INSERT INTO payment_data (record_id, doc_id, json_data)
VALUES (3, 319, [object Object]);

```

 ![image](https://europe1.discourse-cdn.com/n8n/original/2X/d/d8deedd67a6b10637e0058343eb1e3ee89949491.png)

 ![image](https://europe1.discourse-cdn.com/n8n/original/2X/e/ebe06bdd809b1258ad2221d5ab7ed54101d55488.png)

The expected result from the Postgres node expression is:

```
INSERT INTO payment_data (record_id, doc_id, json_data)
VALUES (1, 319, '{"key":"value"}');

```

What is the way to omit the [Object] reference to get the query working? I should note that [Object] is placed by JSON \> data \> raw value selection.

 ![image](https://europe1.discourse-cdn.com/n8n/original/2X/d/d78440a392d96f29235fb9fa1c95a64cfdb92d28.png)

---

<div class="post-metadata">

**Author:** ![sigmet](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/sigmet/32/5629_2.png) [@sigmet](https://community.n8n.io/u/sigmet)\
**Post date:** [July 25, 2021, 6:21am UTC](https://community.n8n.io/t/postgresql-insert-issue-jsonb/6890/2 "2021-07-25T06:21:50Z")

</div>

Found a solution: one way to solve this is to use the Function node

```auto
items[0].json.payload = JSON.stringify({"key": "value"});
return items

```

which bypasses the object rendering in the Postgres node since the data is coming in as a string, resulting in a correctly executed SQL statement.

---

<div class="post-metadata">

**Author:** ![RicardoE105](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/ricardoe105/32/550_2.png) [@RicardoE105](https://community.n8n.io/u/RicardoE105)\
**Post date:** [July 25, 2021, 12:07pm UTC](https://community.n8n.io/t/postgresql-insert-issue-jsonb/6890/3 "2021-07-25T12:07:44Z")

</div>

thanks for sharing the solution with the community @sigmet
