Context:
Just found out that subqueries can not be used in the check constraint.
Squawk linter does not complain but Postgresql throws the following error:
ERROR: cannot use subquery in check constraint (SQLSTATE 0A000)
Example:
ALTER TABLE
table_x
ADD
CONSTRAINT bar_should_equal_to_banana CHECK (
(
SELECT
bar
FROM
table_y
WHERE
table_y.pk = table_x.y_pk
) = 'banana'
);
Expected fix:
New rule should throw an error on subqueries used in the check constraint.
Should suggest to use triggers instead?
Context:
Just found out that subqueries can not be used in the check constraint.
Squawk linter does not complain but Postgresql throws the following error:
ERROR: cannot use subquery in check constraint (SQLSTATE 0A000)Example:
Expected fix:
New rule should throw an error on subqueries used in the check constraint.
Should suggest to use triggers instead?