X-Git-Url: http://git.rot13.org/?p=virtual-ldap;a=blobdiff_plain;f=lib%2FLDAP%2FKoha.pm;fp=lib%2FLDAP%2FKoha.pm;h=2187bacfb64706a253f134a27e2d2abff75799c8;hp=05532eae0b6a1cfe0f581e1f7841610c894c1f1a;hb=a447fea0417758ec2249ae508f45ec742b6d53a1;hpb=393f5f337f96d9db5cad0d840aea07048b4f2d00 diff --git a/lib/LDAP/Koha.pm b/lib/LDAP/Koha.pm index 05532ea..2187bac 100644 --- a/lib/LDAP/Koha.pm +++ b/lib/LDAP/Koha.pm @@ -181,15 +181,19 @@ sub search { __ldap_search_to_sql( $filter, $reqData->{'filter'}->{$filter} ); } - $sql_where .= ' ' . join( " $filter ", @limits ); + $sql_where .= ' ' . join( " $filter ", @limits ) if @limits; } + my $sql_select = read_file( lc "sql/$objectclass.sql" ); if ( $sql_where ) { - $sql_where = " where $sql_where"; + if ( $sql_select !~ m{where}i ) { + $sql_where = " where $sql_where"; + } else { + $sql_where = " and $sql_where"; + } } - my $sql_select = read_file( lc "sql/$objectclass.sql" ); warn "# SQL:\n$sql_select\n", $sql_where ? $sql_where : '-- no where', "\n# DATA: ",dump( @values ); my $sth = $dbh->prepare( $sql_select . $sql_where . " LIMIT $max_results" ); # XXX remove limit?