Bug
Column check is extracted by stripping a fixed prefix/suffix from pg_get_constraintdef(...), assuming the def is exactly CHECK (...).
When the constraint has a suffix (NOT VALID, NO INHERIT), the length heuristic returns a corrupted expression:
| constraintdef |
returned check |
CHECK (id > 0) NOT VALID |
id > 0) NOT VALI |
CHECK (id > 0) NO INHERIT |
id > 0) NO INHERI |
Studio then shows / may round-trip an invalid check expression.
Repro
create table public.t (id int8);
alter table public.t add constraint t_id_check check (id > 0) not valid;
Then columns.retrieve / list — check is not id > 0.
Expected
check should be the expression only (id > 0), using pg_get_expr(conbin, conrelid) (with one outer paren pair stripped to preserve the existing API shape).
Bug
Column
checkis extracted by stripping a fixed prefix/suffix frompg_get_constraintdef(...), assuming the def is exactlyCHECK (...).When the constraint has a suffix (
NOT VALID,NO INHERIT), the length heuristic returns a corrupted expression:checkCHECK (id > 0) NOT VALIDid > 0) NOT VALICHECK (id > 0) NO INHERITid > 0) NO INHERIStudio then shows / may round-trip an invalid check expression.
Repro
Then
columns.retrieve/ list —checkis notid > 0.Expected
checkshould be the expression only (id > 0), usingpg_get_expr(conbin, conrelid)(with one outer paren pair stripped to preserve the existing API shape).