This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create or replace function is_AoA(_input jsonb) returns boolean as $$ | |
select _input = '[]' or 'array' = all(array_agg(jsonb_typeof(foo))) from (select jsonb_array_elements(_input) foo) x; | |
$$ language sql immutable; | |
create table mytest ( | |
id bigserial primary key, | |
myAoA jsonb check (is_AoA(myAoA)) | |
); |