Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

PG for Postgres may give problems for top level arrays in JSONB columns #1576

Closed
AshotN opened this issue Nov 8, 2022 · 0 comments
Closed

Comments

@AshotN
Copy link

AshotN commented Nov 8, 2022

Comment/Problem

Whenever a schema contains a property of Type.Array(Type.Object()) with PostgreSQL the user may encounter an issue during insert/update. This is related to this issue with pg.

The issue is basically that the parser can't handle a top level array normally. I found the simplest solution is to make sure that the column is of type jsonb[] in the database.

In Knex this is acheived with table.specificType('my_json_array', 'jsonb ARRAY')

The error the user may see if the column is jsonb is something like this

{
  "name": "NotFound",
  "message": "insert into \"my_json_array\") values ($1) returning \"id\" - invalid input syntax for type json",
  "code": 404,
  "className": "not-found"
}

System configuration

"@feathersjs/knex": "^5.0.0-pre.32",
"@feathersjs/schema": "^5.0.0-pre.32",
"@feathersjs/typebox": "^5.0.0-pre.32",
"pg": "^8.8.0"
@daffl daffl closed this as completed Sep 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants