Open EndsOfTheEarth opened 4 weeks ago
Here is a check clause text example: "((length((text1)::text) >= 1) AND (length((text1)::text) <= 100))".
create table test (
text1 citext not null,
constraint chk_text1_length CHECK(LENGTH(text1) between 1 and 100)
);
select *
from information_schema.check_constraints cc
join information_schema.constraint_column_usage cu
on cc.constraint_catalog = cu.constraint_catalog and
cc.constraint_schema = cu.constraint_schema and
cc.constraint_name = cu.constraint_name
where cu.constraint_name = 'chk_text1_length';
The citext type does not have a maximum length defined like the VARCHAR type. This makes validating the column character length difficult as it needs to be constrained by using a CHECK constraint. Look at ways to extract that length information for the schema validation to use.