Does Bulk Insert Records accepts JSONb arrays?

Hello!

I have two queries, one inserts a single row to a table which has a JSONb column where we submit arrays to it such as [12, 23] or [2], and we don't have any issues with it.

after that another query gets triggered where it does a Bulk insert records, however I get the following error message:

insert into "table"."product_sessions" ("date", "group_id", "name", "participants", "product_id", "verification_id") values ($1, $2, $3, $4, $5, $6) - invalid input syntax for type json

What jumps to my eye is that it says invalid input syntax for type json instead of jsonb I don't know if that could be the issue. Here's an example of an object:

[
  {
    "name": "BookClub 
    "date": "2024-05-01T06:00:00.000Z",
    "verification_id": "123123",
    "product_id": 132,
    "group_id": 20,
    "participants": [
      198,
      194
    ]
  }
]

There could be many, that's the reasion is a bulk insert.

This is the format before getting the result

{{ sessionsTracker.value.map(e => ({...e, verification_id: currentGroup.value.verification, product_id: currentGroup.value.product, group_id: currentGroup.value.id,
participants: currentGroup.value.participants })) }}

If I remove participants, the query goes without a problem. I have triple check the spelling, both in the database and in the app as well as checked the format of the column of participants and it is correct. currentGroup.value.participants is used on the previous queries so the integrity of the array is correct.


So I'm just wondering if there's an issue with JSONb arrays in bulk inserts arrays since the error just says json? Just to take that out as a possibility or to address the issue accordingly (I hope it really isn't the case).

I had the same issue a while ago and the solution from Kabirdas here helped me

1 Like

Thank you so much to both of you!!!