cast label_sortkey to bytea in order to get ascii-betical sorting in any locale,...
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 14 Oct 2010 19:18:11 +0000 (19:18 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 14 Oct 2010 19:18:11 +0000 (19:18 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@18333 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm
Open-ILS/src/sql/Pg/002.schema.config.sql
Open-ILS/src/sql/Pg/040.schema.asset.sql
Open-ILS/src/sql/Pg/1.6.1-2.0-upgrade-db.sql
Open-ILS/src/sql/Pg/upgrade/0437.schema.bytea-index-label_sortkey.sql [new file with mode: 0644]

index e86d459..5384792 100644 (file)
@@ -305,7 +305,7 @@ sub cn_browse {
                        },
                        { flesh         => 1,
                          flesh_fields  => { acn => [qw/record owning_lib/] },
-                         order_by      => { acn => "label_sortkey desc, upper(label) desc, id desc, owning_lib desc" },
+                         order_by      => { acn => "cast(label_sortkey as bytea) desc, upper(label) desc, id desc, owning_lib desc" },
                          limit         => $before_limit,
                          offset        => abs($page) * $page_size - $before_offset,
                        }
@@ -323,7 +323,7 @@ sub cn_browse {
                        },
                        { flesh         => 1,
                          flesh_fields  => { acn => [qw/record owning_lib/] },
-                         order_by      => { acn => "label_sortkey, upper(label), id, owning_lib" },
+                         order_by      => { acn => "cast(label_sortkey as bytea), upper(label), id, owning_lib" },
                          limit         => $after_limit,
                          offset        => abs($page) * $page_size - $after_offset,
                        }
@@ -428,7 +428,7 @@ sub cn_startwith {
                        },
                        { flesh         => 1,
                          flesh_fields  => { acn => [qw/record owning_lib/] },
-                         order_by      => { acn => "label_sortkey, upper(label) desc, id desc, owning_lib desc" },
+                         order_by      => { acn => "cast(label_sortkey as bytea) desc, upper(label) desc, id desc, owning_lib desc" },
                          limit         => $limit,
                          offset        => $offset,
                        }
@@ -446,7 +446,7 @@ sub cn_startwith {
                        },
                        { flesh         => 1,
                          flesh_fields  => { acn => [qw/record owning_lib/] },
-                         order_by      => { acn => "label_sortkey, upper(label), id, owning_lib" },
+                         order_by      => { acn => "cast(label_sortkey as bytea), upper(label), id, owning_lib" },
                          limit         => $limit,
                          offset        => $offset,
                        }
index 0294e8a..447c7f2 100644 (file)
@@ -70,7 +70,7 @@ CREATE TABLE config.upgrade_log (
     install_date    TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
 );
 
-INSERT INTO config.upgrade_log (version) VALUES ('0436'); -- miker
+INSERT INTO config.upgrade_log (version) VALUES ('0437'); -- miker
 
 CREATE TABLE config.bib_source (
        id              SERIAL  PRIMARY KEY,
index 1c52cb0..91878e0 100644 (file)
@@ -294,7 +294,7 @@ CREATE INDEX asset_call_number_creator_idx ON asset.call_number (creator);
 CREATE INDEX asset_call_number_editor_idx ON asset.call_number (editor);
 CREATE INDEX asset_call_number_dewey_idx ON asset.call_number (public.call_number_dewey(label));
 CREATE INDEX asset_call_number_upper_label_id_owning_lib_idx ON asset.call_number (upper(label),id,owning_lib);
-CREATE INDEX asset_call_number_label_sortkey ON asset.call_number(label_sortkey);
+CREATE INDEX asset_call_number_label_sortkey ON asset.call_number(cast(label_sortkey as bytea));
 CREATE UNIQUE INDEX asset_call_number_label_once_per_lib ON asset.call_number (record, owning_lib, label) WHERE deleted = FALSE OR deleted IS FALSE;
 CREATE RULE protect_cn_delete AS ON DELETE TO asset.call_number DO INSTEAD UPDATE asset.call_number SET deleted = TRUE WHERE OLD.id = asset.call_number.id;
 CREATE TRIGGER asset_label_sortkey_trigger
index 77d2dc4..99d3b40 100644 (file)
@@ -17770,7 +17770,7 @@ ALTER TABLE asset.call_number
        ADD COLUMN label_sortkey TEXT;
 
 CREATE INDEX asset_call_number_label_sortkey
-       ON asset.call_number(label_sortkey);
+       ON asset.call_number(cast(label_sortkey as bytea));
 
 ALTER TABLE auditor.asset_call_number_history
        ADD COLUMN label_class BIGINT;
diff --git a/Open-ILS/src/sql/Pg/upgrade/0437.schema.bytea-index-label_sortkey.sql b/Open-ILS/src/sql/Pg/upgrade/0437.schema.bytea-index-label_sortkey.sql
new file mode 100644 (file)
index 0000000..5400166
--- /dev/null
@@ -0,0 +1,9 @@
+
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0437'); -- miker
+
+DROP INDEX asset.asset_call_number_label_sortkey;
+CREATE INDEX asset_call_number_label_sortkey ON asset.call_number(cast(label_sortkey as bytea));
+
+COMMIT;