On Sat, 2024-09-14 at 12:05 +0200, Alban Hertroys wrote: > > That’s because the replacement data is an array of objects, not a > single object. > > You need to iterate through the array elements to build your > replacement data, something like what I do here with a select > (because that’s way easier to play around with): > > with dollar6 as ( > select jsonb($$[ > { > "data": { > "foo": 1, "bar": 2 > }, > "end": "2023- > 06-12T19:54:51Z", > "start": > "2023-06-12T19:54:39Z" > } > ]$$::text) replacement > ) > select * > from dollar6 > cross join lateral jsonb_array_elements(replacement) r > where (r->>'start')::timestamptz <= current_timestamp; Thanks