postgresql に json 型フィールドがあります。ただし、特定のフィールドが null である行を選択することはできません。
コード:
SELECT *
FROM json_array_elements(
'[{"name": "Toby", "occupation": "Software Engineer"},
{"name": "Zaphod", "occupation": "Galactic President"} ,
{"name2": "Zaphod", "occupation2": null} ]' ) AS elem
where elem#>'{occupation2}' is null
これは機能するはずですが、次のエラーが発生します。
ERROR: operator does not exist: json #> boolean
LINE 6: where elem#>'{occupation2}' is null