-
-
Save chy-causer/a55b514c03ca6f7a8ac07b0d46782a5c to your computer and use it in GitHub Desktop.
Check a jsonb column is an array of arrays
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)) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment