PostgreSQL error code
PostgreSQL error 2203F
2203F is the SQLSTATE PostgreSQL reports for sql json scalar required, in class 22, Data Exception.
| SQLSTATE | 2203F |
|---|---|
| Condition name | sql_json_scalar_required |
| Class | 22 — Data Exception |
Reproduce it, then fix it
JSON_VALUE only returns scalars, and $.tags is an array. Point the path at one element, or use JSON_QUERY to get the array itself. Run the broken query to see the error, then switch to the fixed one. Edit either freely; every run is rolled back.
SELECT JSON_VALUE(jsonb '{"tags": ["sale"]}', '$.tags' ERROR ON ERROR);SELECT JSON_VALUE(jsonb '{"tags": ["sale"]}', '$.tags[0]' ERROR ON ERROR);