Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

Search.pm questions...

Quote Reply
Search.pm questions...

i was just going through search.pm for my morbid curiosity, and in sub query i was wondering what happens if the filter is requested, but actually contains no data..

the code -

$filter = (" and (( " .
join ( ") and ( ", map { "$_ = '". quotemeta($$filterref{$_}) ."'" } keys %$filterref )
. "))" );

$where = "$id_col in (" .
join ( ",", map ( $$_[0], @query_results) ) .
") $filter";

doesn't seem to make sense to me if $filter is empty... also if no results are returned in @query_results, surely that will result in the SQL command being malformed ?

sorry if this has been addressed already, i'm just playing with the code for my buddy and this popped up.



Quote Reply
Re: Search.pm questions... In reply to
Hi Tom,

The $filterref doesn't get set unless $self->filter is called and all that method does is accept filters. So if there is no filter, $self->{filter} is undef or has a filter and is set to a non-empty hashref.

Though, if @query_results is empty, yes, there is a problem. It is advisable to add the line

@query_results or return;

right before:

# Now let's limit our search, and prepare how we are going to get the data.
if ( $self->{get_fields} ) {

Hope this helps,

Quote Reply
Re: Search.pm questions... In reply to
thanks for that !

If this is still a revelant question, I might try to work on a method which will still search if the filter is set, and return the terms it was unable to use.

thanks once again,