PostgreSQL error code
PostgreSQL error 22039
22039 is the SQLSTATE PostgreSQL reports for sql json array not found, in class 22, Data Exception.
| SQLSTATE | 22039 |
|---|---|
| Condition name | sql_json_array_not_found |
| Class | 22 — Data Exception |
Reproduce it, then fix it
tags holds a string, not an array, and strict mode won’t index into it. Lax mode treats a lone value as a one-element array, which suits data that has both shapes. Run the broken query to see the error, then switch to the fixed one. Edit either freely; every run is rolled back.
SELECT jsonb_path_query('{"tags": "sale"}', 'strict $.tags[0]');SELECT jsonb_path_query('{"tags": "sale"}', 'lax $.tags[0]');