summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2018-10-25 10:24:34 +0200
committerYorhel <git@yorhel.nl>2018-10-25 10:29:18 +0200
commit95feae6a676d5d312b2ad9b2994d56842acb4795 (patch)
tree6b5ea687c401931bf95ba2edb453576a61fa774c /lib
parent22b070a421fd15435cd10d4084fea05526660c11 (diff)
DB::Releases: Don't return duplicate releases in dbReleaseGet(vid => [...])
In the special case where the releases of multiple VNs are requested, and those VNs have releases in common, dbReleaseGet() would return those releases multiple times. Using a JOIN in order to filter rows isn't safe if the join condition isn't unique - so use an "id IN(SELECT ..)" filter instead. (I found this while editing c15068 and noticing that some releases were listed twice in the edit form. Editing that entry without manually removing those duplicates would trigger an internal server error due to duplicate relations)
Diffstat (limited to 'lib')
-rw-r--r--lib/VNDB/DB/Releases.pm3
1 files changed, 1 insertions, 2 deletions
diff --git a/lib/VNDB/DB/Releases.pm b/lib/VNDB/DB/Releases.pm
index 1a01f712..a2614ca8 100644
--- a/lib/VNDB/DB/Releases.pm
+++ b/lib/VNDB/DB/Releases.pm
@@ -59,8 +59,8 @@ sub dbReleaseGet {
!$o{id} && !$o{hidden_only} ? ( 'r.hidden = FALSE' => 0 ) : (),
$o{hidden_only} ? ('r.hidden = TRUE' => 1) : (),
$o{id} ? ( 'r.id = ?' => $o{id} ) : (),
- $o{vid} ? ( 'rv.vid IN(!l)' => [ ref $o{vid} ? $o{vid} : [$o{vid}] ] ) : (),
$o{pid} ? ( 'rp.pid = ?' => $o{pid} ) : (),
+ $o{vid} ? ( 'r.id IN(SELECT id FROM releases_vn WHERE vid IN(!l))' => [ ref $o{vid} ? $o{vid} : [$o{vid}] ] ) : (),
$self->dbReleaseFilters(%o),
);
@@ -78,7 +78,6 @@ sub dbReleaseGet {
}
my @join = (
- $o{vid} ? 'JOIN releases_vn rv ON rv.id = r.id' : (),
$o{pid} ? 'JOIN releases_producers rp ON rp.id = r.id' : (),
);