[open-ils-commits] r18437 - in branches/rel_1_6/Open-ILS/src: perlmods/OpenILS/Application perlmods/OpenILS/Application/Storage/Publisher sql/Pg (gmc)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Oct 21 10:53:08 EDT 2010
Author: gmc
Date: 2010-10-21 10:53:06 -0400 (Thu, 21 Oct 2010)
New Revision: 18437
Modified:
branches/rel_1_6/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/asset.pm
branches/rel_1_6/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm
branches/rel_1_6/Open-ILS/src/sql/Pg/002.functions.config.sql
branches/rel_1_6/Open-ILS/src/sql/Pg/040.schema.asset.sql
branches/rel_1_6/Open-ILS/src/sql/Pg/1.6.1-1.6.2-upgrade-db.sql
Log:
improve call number sorting
oils_text_as_bytea now does uppercasing in addition
to converting strings to bytea, working around
the limitation that json_query can't stack transforms
Signed-off-by: Galen Charlton <gmc at esilibrary.com>
Modified: branches/rel_1_6/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/asset.pm
===================================================================
--- branches/rel_1_6/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/asset.pm 2010-10-21 14:48:12 UTC (rev 18436)
+++ branches/rel_1_6/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/asset.pm 2010-10-21 14:53:06 UTC (rev 18437)
@@ -230,9 +230,9 @@
$table cn
where
not deleted
- and (oils_text_as_bytea(upper(label)) > ? or ( cn.id > ? and oils_text_as_bytea(upper(label)) = ? ))
+ and (oils_text_as_bytea(label) > ? or ( cn.id > ? and oils_text_as_bytea(label) = ? ))
and owning_lib in ($orgs)
- order by oils_text_as_bytea(upper(label)), 4, 2
+ order by oils_text_as_bytea(label), 4, 2
limit $size;
SQL
@@ -285,9 +285,9 @@
$table cn
where
not deleted
- and (oils_text_as_bytea(upper(label)) < ? or ( cn.id < ? and oils_text_as_bytea(upper(label)) = ? ))
+ and (oils_text_as_bytea(label) < ? or ( cn.id < ? and oils_text_as_bytea(label) = ? ))
and owning_lib in ($orgs)
- order by oils_text_as_bytea(upper(label)) desc, 4 desc, 2 desc
+ order by oils_text_as_bytea(label) desc, 4 desc, 2 desc
limit $size
) as bar
order by 1,4,2;
@@ -343,9 +343,9 @@
$table cn
where
not deleted
- and oils_text_as_bytea(upper(label)) < ?
+ and oils_text_as_bytea(label) < ?
and owning_lib in ($orgs)
- order by oils_text_as_bytea(upper(label)) desc, 4 desc, 2 desc
+ order by oils_text_as_bytea(label) desc, 4 desc, 2 desc
limit $topsize
) as bar
order by 1,4,2;
@@ -361,9 +361,9 @@
$table cn
where
not deleted
- and oils_text_as_bytea(upper(label)) >= ?
+ and oils_text_as_bytea(label) >= ?
and owning_lib in ($orgs)
- order by oils_text_as_bytea(upper(label)),4,2
+ order by oils_text_as_bytea(label),4,2
limit $bottomsize;
SQL
Modified: branches/rel_1_6/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm
===================================================================
--- branches/rel_1_6/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm 2010-10-21 14:48:12 UTC (rev 18436)
+++ branches/rel_1_6/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm 2010-10-21 14:53:06 UTC (rev 18437)
@@ -281,13 +281,13 @@
if ($page <= 0) {
my $before = $_storage->request(
"open-ils.cstore.direct.asset.call_number.search.atomic",
- { label => { "<" => { transform => "upper", value => ["upper", $label] } },
+ { label => { "<" => { transform => "oils_text_as_bytea", value => ["oils_text_as_bytea", $label] } },
owning_lib => \@ou_ids,
deleted => 'f',
},
{ flesh => 1,
flesh_fields => { acn => [qw/record owning_lib/] },
- order_by => { acn => "oils_text_as_bytea(upper(label)) desc, id desc, owning_lib desc" },
+ order_by => { acn => "oils_text_as_bytea(label) desc, id desc, owning_lib desc" },
limit => $before_limit,
offset => abs($page) * $page_size - $before_offset,
}
@@ -298,13 +298,13 @@
if ($page >= 0) {
my $after = $_storage->request(
"open-ils.cstore.direct.asset.call_number.search.atomic",
- { label => { ">=" => { transform => "upper", value => ["upper", $label] } },
+ { label => { ">=" => { transform => "oils_text_as_bytea", value => ["oils_text_as_bytea", $label] } },
owning_lib => \@ou_ids,
deleted => 'f',
},
{ flesh => 1,
flesh_fields => { acn => [qw/record owning_lib/] },
- order_by => { acn => "oils_text_as_bytea(upper(label)), id, owning_lib" },
+ order_by => { acn => "oils_text_as_bytea(label), id, owning_lib" },
limit => $after_limit,
offset => abs($page) * $page_size - $after_offset,
}
Modified: branches/rel_1_6/Open-ILS/src/sql/Pg/002.functions.config.sql
===================================================================
--- branches/rel_1_6/Open-ILS/src/sql/Pg/002.functions.config.sql 2010-10-21 14:48:12 UTC (rev 18436)
+++ branches/rel_1_6/Open-ILS/src/sql/Pg/002.functions.config.sql 2010-10-21 14:53:06 UTC (rev 18437)
@@ -125,7 +125,7 @@
$$ LANGUAGE SQL;
CREATE OR REPLACE FUNCTION oils_text_as_bytea (TEXT) RETURNS BYTEA AS $_$
- SELECT CAST(REGEXP_REPLACE($1, $$\\$$, $$\\\\$$, 'g') AS BYTEA);
+ SELECT CAST(REGEXP_REPLACE(UPPER($1), $$\\$$, $$\\\\$$, 'g') AS BYTEA);
$_$ LANGUAGE SQL IMMUTABLE;
COMMIT;
Modified: branches/rel_1_6/Open-ILS/src/sql/Pg/040.schema.asset.sql
===================================================================
--- branches/rel_1_6/Open-ILS/src/sql/Pg/040.schema.asset.sql 2010-10-21 14:48:12 UTC (rev 18436)
+++ branches/rel_1_6/Open-ILS/src/sql/Pg/040.schema.asset.sql 2010-10-21 14:53:06 UTC (rev 18437)
@@ -158,7 +158,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 (oils_text_as_bytea(upper(label)),id,owning_lib);
+CREATE INDEX asset_call_number_upper_label_id_owning_lib_idx ON asset.call_number (oils_text_as_bytea(label),id,owning_lib);
CREATE UNIQUE INDEX asset_call_number_label_once_per_lib ON asset.call_number (record, owning_lib, label) WHERE 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;
Modified: branches/rel_1_6/Open-ILS/src/sql/Pg/1.6.1-1.6.2-upgrade-db.sql
===================================================================
--- branches/rel_1_6/Open-ILS/src/sql/Pg/1.6.1-1.6.2-upgrade-db.sql 2010-10-21 14:48:12 UTC (rev 18436)
+++ branches/rel_1_6/Open-ILS/src/sql/Pg/1.6.1-1.6.2-upgrade-db.sql 2010-10-21 14:53:06 UTC (rev 18437)
@@ -46,11 +46,11 @@
$func$ LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION oils_text_as_bytea (TEXT) RETURNS BYTEA AS $_$
- SELECT CAST(REGEXP_REPLACE($1, $$\\$$, $$\\\\$$, 'g') AS BYTEA);
+ SELECT CAST(REGEXP_REPLACE(UPPER($1), $$\\$$, $$\\\\$$, 'g') AS BYTEA);
$_$ LANGUAGE SQL IMMUTABLE;
DROP INDEX asset.asset_call_number_upper_label_id_owning_lib_idx;
-CREATE INDEX asset_call_number_upper_label_id_owning_lib_idx ON asset.call_number (oils_text_as_bytea(upper(label)),id,owning_lib);
+CREATE INDEX asset_call_number_upper_label_id_owning_lib_idx ON asset.call_number (oils_text_as_bytea(label),id,owning_lib);
/* this makes us require PG 8.3+ */
CREATE OR REPLACE FUNCTION oils_xpath ( TEXT, TEXT, ANYARRAY ) RETURNS TEXT[] AS 'SELECT XPATH( $1, $2::XML, $3 )::TEXT[];' LANGUAGE SQL IMMUTABLE;
More information about the open-ils-commits
mailing list