Dear list,
I ran into an error when running the following snippet of code (I simplified as much as I could):
CREATE DOMAIN domaintest AS VARCHAR(10) NOT NULL;
CREATE TABLE tabletest (
fieldtest domaintest GENERATED ALWAYS AS ('valuetest') STORED
);
INSERT INTO tabletest DEFAULT VALUES;
In PostgreSQL 12 and 13, I get the following error:
domain domaintest does not allow null values.
If I move the NOT NULL constraint from the domain to the table, the error disappears.
Is this the expected behaviour? Is there any way to circumvent this and use a domain with a NOT NULL constraint on a generated column? (I know the documentation recommends to avoid NOT NULL on domains, but I'd still like to do so).
Thank you,
--
Fabian Pijcke