LP#1607487: make schema update script use same whitespace
authorGalen Charlton <gmc@equinoxinitiative.org>
Mon, 27 Feb 2017 15:19:30 +0000 (10:19 -0500)
committerGalen Charlton <gmc@equinoxinitiative.org>
Mon, 27 Feb 2017 15:19:30 +0000 (10:19 -0500)
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 <gmc@equinoxinitiative.org>
Open-ILS/src/sql/Pg/upgrade/XXXX.data.update-broken-naco-links.sql

index ecf6dff..9b0820f 100644 (file)
@@ -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