[open-ils-commits] r15915 - in trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage: . Driver/Pg (miker)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Mar 18 15:58:53 EDT 2010
Author: miker
Date: 2010-03-18 15:58:48 -0400 (Thu, 18 Mar 2010)
New Revision: 15915
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm
trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/QueryParser.pm
Log:
support * as a truncation operator in FTS. NOTE: this will require Postgres 8.4 or newer!
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm 2010-03-18 18:34:29 UTC (rev 15914)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm 2010-03-18 19:58:48 UTC (rev 15915)
@@ -532,8 +532,15 @@
$sql = $n->{function}."($sql)";
}
- $sql = "to_tsquery('$classname'," . ($self->prefix ? "\$_$$\$" . $self->prefix . "\$_$$\$||" : '') . "'('||regexp_replace($sql,E'(?:\\\\s+|:)','&','g')||')')";
+ my $prefix = $self->prefix || '';
+ my $suffix = $self->suffix || '';
+ $prefix = "'$prefix' ||" if $prefix;
+ my $suffix_op = ":$suffix" if $suffix;
+ my $suffix_after = "|| '$suffix_op'" if $suffix;
+
+ $sql = "to_tsquery('$classname', $prefix '(' || regexp_replace($sql,E'(?:\\\\s+|:)','$suffix_op&','g') $suffix_after || ')')";
+
return $self->sql($sql);
}
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/QueryParser.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/QueryParser.pm 2010-03-18 18:34:29 UTC (rev 15914)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/QueryParser.pm 2010-03-18 19:58:48 UTC (rev 15915)
@@ -525,8 +525,9 @@
my $class_node = $struct->classed_node($current_class);
my $negator = ($atom =~ s/^-//o) ? '!' : '';
+ my $truncate = ($atom =~ s/\*$//o) ? '*' : '';
- $class_node->add_fts_atom( $atom, prefix => $negator, node => $class_node );
+ $class_node->add_fts_atom( $atom, suffix => $truncate, prefix => $negator, node => $class_node );
$struct->joiner( '&' );
$_ = $after;
@@ -865,6 +866,12 @@
return $self->{prefix};
}
+sub suffix {
+ my $self = shift;
+ return undef unless (ref $self);
+ return $self->{suffix};
+}
+
#-------------------------------
package QueryParser::query_plan::filter;
More information about the open-ils-commits
mailing list