summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2009-05-24 09:07:52 +0200
committerYorhel <git@yorhel.nl>2009-05-24 09:07:52 +0200
commitdcec270729b0a4a9bfc35b73744a0383a2036728 (patch)
tree11b3564b8dd844e2e8694921d43c190ef00317eb /lib
parent8844486e8eb350185d76cde64105e85251c08040 (diff)
Don't perform search subquery when there are no keywords to search on
Diffstat (limited to 'lib')
-rw-r--r--lib/VNDB/DB/Releases.pm2
-rw-r--r--lib/VNDB/DB/VN.pm7
2 files changed, 4 insertions, 5 deletions
diff --git a/lib/VNDB/DB/Releases.pm b/lib/VNDB/DB/Releases.pm
index bc64b880..9491d213 100644
--- a/lib/VNDB/DB/Releases.pm
+++ b/lib/VNDB/DB/Releases.pm
@@ -51,7 +51,7 @@ sub dbReleaseGet {
s/%//g;
if(/^\d+$/ && gtintype($_)) {
push @where, 'rr.gtin = ?', $_;
- } else {
+ } elsif(length($_) > 0) {
$_ = "%$_%";
push @where, '(rr.title ILIKE ? OR rr.original ILIKE ? OR rr.catalog = ?)',
[ $_, $_, $_ ];
diff --git a/lib/VNDB/DB/VN.pm b/lib/VNDB/DB/VN.pm
index 54e2f510..4798e16f 100644
--- a/lib/VNDB/DB/VN.pm
+++ b/lib/VNDB/DB/VN.pm
@@ -50,19 +50,18 @@ sub dbVNGet {
);
if($o{search}) {
- my @w = (
- '(irr.id IS NULL OR ir.latest = irr.id)' => 1
- );
+ my @w;
for (split /[ -,._]/, $o{search}) {
s/%//g;
if(/^\d+$/ && gtintype($_)) {
push @w, 'irr.gtin = ?', $_;
- } else {
+ } elsif(length($_) > 0) {
$_ = "%$_%";
push @w, '(ivr.title ILIKE ? OR ivr.original ILIKE ? OR ivr.alias ILIKE ? OR irr.title ILIKE ? OR irr.original ILIKE ?)',
[ $_, $_, $_, $_, $_ ];
}
}
+ push @w, '(irr.id IS NULL OR ir.latest = irr.id)' => 1 if @w;
$where{ q|
v.id IN(SELECT iv.id
FROM vn iv