yandex-qatools / postgresql-embedded

Embedded PostgreSQL Server
Other
493 stars 90 forks source link

JSON functions support #156

Closed xisvaldo closed 5 years ago

xisvaldo commented 5 years ago

I'm using the version 2.10 and trying to run a query that uses jsonb functions (and casting some fields as required by PostgreSQL 10.6) and it is returning the following error:

Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at or near ":"
  Position: 250

The table contains a jsonb field, which is trying to be parsed as

SELECT 
  SUM(jsonb_array_length(t1.result::jsonb -> rootNode)) 
  FROM table1 AS t1
  INNER JOIN table2 AS t2 ON t2.id = t1.id,
  jsonb_object_keys(t1.result::jsonb) AS rootNode 
  WHERE t2.reference_date >= ?1 AND t2.reference_date <= ?2
  AND   (t2.field ->> 'id')::int = ?3 
  AND   t2.field2_id = ?4

Does anyone knows if it supports json functions/cast?