From d318a3afa3f543e4dd4006621709f8eb54656ae5 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Mon, 27 Feb 2017 10:19:30 -0500 Subject: [PATCH] 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 --- .../XXXX.data.update-broken-naco-links.sql | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) 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 -- 2.43.2