From ee8cd3160941dd808b75b8f06e7138eaca90c9af Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Mon, 21 May 2007 11:37:24 +0000 Subject: [PATCH] =?utf8?q?Der=20SQL-Code=20f=C3=BCr=20die=20Suche=20nach?= =?utf8?q?=20Hersteller=20und=20Modell=20in=20den=20Stammdaten=20benutze?= =?utf8?q?=20einen=20Alias=20"m",=20der=20nicht=20definiert=20wurde.=20Fix?= =?utf8?q?=20f=C3=BCr=20Bug=20653.=20Zus=C3=A4tzlich=20das=20Query=20etwas?= =?utf8?q?=20verbessert.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/IC.pm | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/SL/IC.pm b/SL/IC.pm index a27cc52e4..092a24d0f 100644 --- a/SL/IC.pm +++ b/SL/IC.pm @@ -861,10 +861,15 @@ sub all_parts { $where .= qq| AND (p.onhand < p.rop)|; } + my @subcolumns; foreach my $column (qw(make model)) { - next unless ($form->{$column}); - $where .= qq| AND p.id IN (SELECT DISTINCT m.parts_id FROM makemodel WHERE $column ILIKE ?)|; - push(@values, '%' . $form->{$column} . '%'); + push @subcolumns, $column if $form->{$column}; + } + if (@subcolumns) { + $where .= qq| AND p.id IN (SELECT DISTINCT parts_id FROM makemodel WHERE |; + $where .= join " AND ", map { "($_ ILIKE ?)"; } @subcolumns; + $where .= qq|)|; + push @values, map { '%' . $form->{$_} . '%' } @subcolumns; } if ($form->{l_soldtotal}) { -- 2.20.1