Mercurial > gemma
changeset 4896:dd888bbb7e43 fairway-marks-import
Merge branch default into fairway-marks-import
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Fri, 24 Jan 2020 17:37:41 +0100 |
parents | 9f799077a3e6 (current diff) 8a4c98b80fbd (diff) |
children | 638a61fb881b |
files | schema/gemma.sql |
diffstat | 2 files changed, 14 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/pkg/pgxutils/errors.go Tue Jan 14 18:24:51 2020 +0100 +++ b/pkg/pgxutils/errors.go Fri Jan 24 17:37:41 2020 +0100 @@ -22,14 +22,16 @@ ) const ( - notNullViolation = "23502" - foreignKeyViolation = "23503" - uniqueViolation = "23505" - checkViolation = "23514" - exclusionViolation = "23P01" - violatesRowLevelSecurity = "42501" - duplicateObject = "42710" - noDataFound = "P0002" + // camel cased condition name = error code + // from appendix A of PostgreSQL documentation + notNullViolation = "23502" + foreignKeyViolation = "23503" + uniqueViolation = "23505" + checkViolation = "23514" + exclusionViolation = "23P01" + insufficientPrivilege = "42501" + duplicateObject = "42710" + noDataFound = "P0002" ) // ReadableError wraps a given error Err and @@ -165,7 +167,7 @@ m = "No area around axis between given ISRS Location Codes" return } - case violatesRowLevelSecurity: + case insufficientPrivilege: m = "Could not save: Data outside the area of responsibility." return }
--- a/schema/gemma.sql Tue Jan 14 18:24:51 2020 +0100 +++ b/schema/gemma.sql Fri Jan 24 17:37:41 2020 +0100 @@ -27,6 +27,7 @@ -- -- Check if a given string can be used as a FROM item in an SQL statement +-- All objects in stmt should be schema qualified if not in the public schema CREATE OR REPLACE FUNCTION is_valid_from_item(stmt text) RETURNS boolean AS $$ BEGIN @@ -38,6 +39,7 @@ RETURN false; END $$ + SET search_path TO 'public' LANGUAGE plpgsql STRICT; @@ -229,7 +231,7 @@ LANGUAGE plpgsql AS $$ BEGIN - IF NOT st_intersects((SELECT area + IF NOT public.ST_Intersects((SELECT area FROM waterway.bottlenecks WHERE bottleneck_id = NEW.bottleneck_id AND validity @> NEW.date_info::timestamptz),