Documentation say nothing about create a domain from other custom domains.
I need only to create array of (previously created) custom domains, so it is not the problem/solution discussed here.
Example:
CREATE DOMAIN jbag AS JSONb
CHECK( VALUE IS NULL OR jsonb_typeof(VALUE) IN ('object','null') );
But PostgreSQL not accepting declations like CREATE FUNCTION intersection(jbag[]) RETURNS jbag
.
How to do a kind of CREATE DOMAIN jbag[] AS jbag[]
?... Or say to postgresql-parser "hello let's accept arrays of atomic custom types!"?
For details see bag.sql
You can create a domain based on a predefined array type, in this case on
jsonb[].
Define a check constraint using a function which ensures that all array elements are compatible withjbag
:Now your function may look like this:
The function in action:
but: