Revision 14227
Added by Aaron Marcuse-Kubitza over 10 years ago
trunk/schemas/util.sql | ||
---|---|---|
1071 | 1071 |
CREATE FUNCTION check_constraint_expr_enable(expr text) RETURNS text |
1072 | 1072 |
LANGUAGE sql IMMUTABLE |
1073 | 1073 |
AS $_$ |
1074 |
SELECT util.remove_prefix($$true OR $$, expr, require := false) |
|
1074 |
SELECT util.trim_parens(util.remove_prefix($$true OR $$, util.trim_parens(expr), |
|
1075 |
require:= false)) |
|
1075 | 1076 |
$_$; |
1076 | 1077 |
|
1077 | 1078 |
|
... | ... | |
1853 | 1854 |
CREATE FUNCTION derived_col_expr_from_check_constraint(check_constraint_def check_constraint_def) RETURNS text |
1854 | 1855 |
LANGUAGE sql IMMUTABLE |
1855 | 1856 |
AS $_$ |
1856 |
SELECT util.extract_str($$NOT $$||quote_ident( |
|
1857 |
(check_constraint_def).constraint_.name)||$$ IS DISTINCT FROM $$, |
|
1858 |
'', util.check_constraint_expr_enable(check_constraint_def.expr)) |
|
1857 |
SELECT util.trim_parens(util.extract_str( |
|
1858 |
quote_ident((check_constraint_def).constraint_.name)||$$ IS DISTINCT FROM $$,'', |
|
1859 |
util.trim_parens(util.remove_prefix($$NOT $$, util.trim_parens( |
|
1860 |
util.check_constraint_expr_enable(check_constraint_def.expr) |
|
1861 |
), require := true)) |
|
1862 |
)) |
|
1859 | 1863 |
$_$; |
1860 | 1864 |
|
1861 | 1865 |
|
Also available in: Unified diff
fix: schemas/util.sql: check_constraint_expr_enable(), derived_col_expr_from_check_constraint(): trim parens in order to support non-pretty-print mode, which is needed with canon_sql()