From a447fea0417758ec2249ae508f45ec742b6d53a1 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Wed, 29 Apr 2009 09:03:47 +0000 Subject: [PATCH] allow where which are specified in SQL files, so we add just our conditions with and --- lib/LDAP/Koha.pm | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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? -- 2.20.1