From: Galen Charlton Date: Mon, 27 Feb 2017 15:19:30 +0000 (-0500) Subject: LP#1607487: make schema update script use same whitespace X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=d318a3afa3f543e4dd4006621709f8eb54656ae5;p=working%2FEvergreen.git LP#1607487: make schema update script use same whitespace This patch ensures that the naco_normalize() and search_normalize() functions preserve the exact whitespace used in the baseline function definitions; this makes no functional difference, but may help folks using diffs to compare schema versions. Signed-off-by: Galen Charlton --- diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.update-broken-naco-links.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.update-broken-naco-links.sql index ecf6dff8c1..9b0820f5f7 100644 --- a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.update-broken-naco-links.sql +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.update-broken-naco-links.sql @@ -40,14 +40,14 @@ CREATE OR REPLACE FUNCTION public.naco_normalize( TEXT, TEXT ) RETURNS TEXT AS $ # transformations based on Unicode category codes $str =~ s/[\p{Cc}\p{Cf}\p{Co}\p{Cs}\p{Lm}\p{Mc}\p{Me}\p{Mn}]//g; - if ($sf && $sf =~ /^a/o) { - my $commapos = index($str, ','); - if ($commapos > -1) { - if ($commapos != length($str) - 1) { + if ($sf && $sf =~ /^a/o) { + my $commapos = index($str, ','); + if ($commapos > -1) { + if ($commapos != length($str) - 1) { $str =~ s/,/\x07/; # preserve first comma - } - } - } + } + } + } # since we've stripped out the control characters, we can now # use a few as placeholders temporarily @@ -69,7 +69,8 @@ CREATE OR REPLACE FUNCTION public.naco_normalize( TEXT, TEXT ) RETURNS TEXT AS $ return lc $str; $func$ LANGUAGE 'plperlu' STRICT IMMUTABLE; - +-- Currently, the only difference from naco_normalize is that search_normalize +-- turns apostrophes into spaces, while naco_normalize collapses them. CREATE OR REPLACE FUNCTION public.search_normalize( TEXT, TEXT ) RETURNS TEXT AS $func$ use strict; @@ -105,14 +106,14 @@ CREATE OR REPLACE FUNCTION public.search_normalize( TEXT, TEXT ) RETURNS TEXT AS # transformations based on Unicode category codes $str =~ s/[\p{Cc}\p{Cf}\p{Co}\p{Cs}\p{Lm}\p{Mc}\p{Me}\p{Mn}]//g; - if ($sf && $sf =~ /^a/o) { - my $commapos = index($str, ','); - if ($commapos > -1) { - if ($commapos != length($str) - 1) { + if ($sf && $sf =~ /^a/o) { + my $commapos = index($str, ','); + if ($commapos > -1) { + if ($commapos != length($str) - 1) { $str =~ s/,/\x07/; # preserve first comma - } - } - } + } + } + } # since we've stripped out the control characters, we can now # use a few as placeholders temporarily