# PostgreSQL Node - Issue with JSONB\[\] Data Type Handling

**URL:** <https://community.n8n.io/t/postgresql-node-issue-with-jsonb-data-type-handling/67216>\
**Category:** Questions\
**Tags:** postgres, data-mapping\
**Created:** [December 23, 2024, 10:01pm UTC](https://community.n8n.io/t/postgresql-node-issue-with-jsonb-data-type-handling/67216 "2024-12-23T22:01:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Burak\_Bayraktaroglu](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/burak_bayraktaroglu/32/25019_2.png) [@Burak\_Bayraktaroglu](https://community.n8n.io/u/Burak_Bayraktaroglu)\
**Post date:** [December 23, 2024, 10:01pm UTC](https://community.n8n.io/t/postgresql-node-issue-with-jsonb-data-type-handling/67216/1 "2024-12-23T22:01:01Z")

</div>

Hey n8n community,

I’m encountering an issue with the PostgreSQL node when trying to insert or update data into a `jsonb[]` column. Here’s the situation:

**What I’m Trying to Achieve:**

- I have a column named `assets` in my PostgreSQL table, which is of type `jsonb[]`.
- I want to insert or update this column with an array of JSON objects directly from my workflow without manually writing SQL commands.

**Current Behavior:**

- When I attempt to set the `assets` column value directly as an array of objects (using expressions like `{{ $json.assets }}`), I get the following error:

```auto
Error;
  Invalid input for 'assets' [item 0]
  'assets' expects a array but we got '::jsonb[]'

```

- I’ve tried to explicitly cast the value to `jsonb[]` within the node’s interface by using `{{ $json.assets }}::jsonb[]`, but this approach results in the node interpreting `::jsonb[]` as part of the data rather than a SQL cast.

**Expected Behavior:**

- The node should recognize the incoming data as an array of JSON objects and automatically handle the conversion to PostgreSQL’s `jsonb[]` type without needing manual SQL casting in the node interface.

**Steps to Reproduce:**

1. Set up a workflow where `assets` is an array of objects.
2. Use a PostgreSQL node for Insert or Update operation.
3. Map the `assets` field from your data to the `assets` column in the table, using expressions if necessary.
4. Attempt to execute the workflow.

**Additional Information:**

- **n8n version:** 1.72.1
- **Database:** postgresdb
- **n8n EXECUTIONS\_PROCESS setting:** own, main
- **Running n8n via:** Docker
- **Operating system:** Linux
- **PostgreSQL version:** 16.1

**Example of data structure for `assets`:**

```json
[
  {
    "assetKey": "exampleKey",
    "campaignId": "exampleId",
    "punchCount": 0,
    "assignDate": "2024-12-17T19:29:45.976Z",
    "redeemed": false
  }
]

```

Has anyone else encountered this issue? Any suggestions for handling this without resorting to custom SQL queries directly in the node? Or is there a known workaround?

Thanks for any help or insights!

## Example workflow

---

<div class="post-metadata">

**Author:** ![n8n](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/n8n/32/26906_2.png) [@n8n](https://community.n8n.io/u/n8n)\
**Post date:** [December 23, 2024, 10:01pm UTC](https://community.n8n.io/t/postgresql-node-issue-with-jsonb-data-type-handling/67216/2 "2024-12-23T22:01:03Z")

</div>

It looks like your topic is missing some important information. Could you provide the following if applicable.

- **n8n version:**
- **Database (default: SQLite):**
- **n8n EXECUTIONS\_PROCESS setting (default: own, main):**
- **Running n8n via (Docker, npm, n8n cloud, desktop app):**
- **Operating system:**

---

<div class="post-metadata">

**Author:** ![Burak\_Bayraktaroglu](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/burak_bayraktaroglu/32/25019_2.png) [@Burak\_Bayraktaroglu](https://community.n8n.io/u/Burak_Bayraktaroglu)\
**Post date:** [December 23, 2024, 10:13pm UTC](https://community.n8n.io/t/postgresql-node-issue-with-jsonb-data-type-handling/67216/3 "2024-12-23T22:13:51Z")

</div>

I already had some info but turned them into required format, as `** *`. (I hope)

---

<div class="post-metadata">

**Author:** ![ihortom](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/ihortom/32/11473_2.png) [@ihortom](https://community.n8n.io/u/ihortom)\
**Post date:** [December 24, 2024, 10:10pm UTC](https://community.n8n.io/t/postgresql-node-issue-with-jsonb-data-type-handling/67216/4 "2024-12-24T22:10:26Z")

</div>

Hey @Burak_Bayraktaroglu , I created the test table as

```auto
CREATE TABLE assets2(
  id int
  , assets JSONB []
  , PRIMARY KEY (id)
);

```

Then inserted the `assets[]` without any issue.

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/3/3/330ed8db17c64b1468fe66c1a23fe5ee15d0fbe6.png)

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/system/32/195824_2.png) [@system](https://community.n8n.io/u/system)\
**Post date:** [March 24, 2025, 10:10pm UTC](https://community.n8n.io/t/postgresql-node-issue-with-jsonb-data-type-handling/67216/5 "2025-03-24T22:10:30Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
