[open-ils-commits] r9144 - trunk/Open-ILS/src/sql/Pg
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Mar 27 00:52:34 EDT 2008
Author: miker
Date: 2008-03-27 00:17:10 -0400 (Thu, 27 Mar 2008)
New Revision: 9144
Modified:
trunk/Open-ILS/src/sql/Pg/300.schema.staged_search.sql
Log:
escape regexp-special characters
Modified: trunk/Open-ILS/src/sql/Pg/300.schema.staged_search.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/300.schema.staged_search.sql 2008-03-27 03:54:35 UTC (rev 9143)
+++ trunk/Open-ILS/src/sql/Pg/300.schema.staged_search.sql 2008-03-27 04:17:10 UTC (rev 9144)
@@ -211,8 +211,17 @@
WHERE term_type = 'phrase'
AND table_alias = query_part.table_alias LOOP
- inner_where_clause := inner_where_clause || ' AND ' || 'value ~* ' || quote_literal( E'(^|\\W+)' || regexp_replace(phrase_query_part.term, E'\\s+',E'\\\\s+','g') || E'(\\W+|\$)' );
+ tmp_text := replace( phrase_query_part.term, '*', E'\\*' );
+ tmp_text := replace( tmp_text, '?', E'\\?' );
+ tmp_text := replace( tmp_text, '+', E'\\+' );
+ tmp_text := replace( tmp_text, '|', E'\\|' );
+ tmp_text := replace( tmp_text, '(', E'\\(' );
+ tmp_text := replace( tmp_text, ')', E'\\)' );
+ tmp_text := replace( tmp_text, '[', E'\\[' );
+ tmp_text := replace( tmp_text, ']', E'\\]' );
+ inner_where_clause := inner_where_clause || ' AND ' || 'value ILIKE ' || quote_literal( E'(^|\\W+)' || regexp_replace(tmp_text, E'\\s+',E'\\\\s+','g') || E'(\\W+|\$)' );
+
END LOOP;
query_table := search.pick_table(query_part.field_class);
More information about the open-ils-commits
mailing list