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"
}
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 withpg
.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 thisSystem configuration