postgresql の新機能であり、jsonb の新機能です。オブジェクトの配列をフィルタリングしようとしています:
[{"event_slug":"test_1","start_time":"2014-10-08","end_time":"2014-10-12"},
{"event_slug":"test_2","start_time":"2013-06-24","end_time":"2013-07-02"},
{"event_slug":"test_3","start_time":"2014-03-26","end_time":"2014-03-30"}]
私のクエリ:
SELECT l.*
FROM locations l
, jsonb_array_elements(l.events) e
WHERE l.events @> '{"event_slug":"test_1"}'
AND e->>'end_time'::timestamp >= '2014-10-30 14:04:06 -0400'::timestamptz;
エラーが発生します:
ERROR: invalid input syntax for type timestamp: "end_time"
LINE 5: AND e->>'end_time'::timestamp >= '2014-10-30 14:04:06 -04...
^