X-Git-Url: http://erislabs.net/gitweb/?p=id3fs.git;a=blobdiff_plain;f=lib%2FID3FS%2FPath.pm;h=dcc2a859481c9c1b5efca61b311fc52dd4dd3022;hp=7909a97b34f18a537e5ca09319dad4675e74102f;hb=93f961269b57f705256c29a2a29d15212388f427;hpb=db517cc1ff37f50a636a89f6adaba51552bbccb1 diff --git a/lib/ID3FS/Path.pm b/lib/ID3FS/Path.pm index 7909a97..dcc2a85 100644 --- a/lib/ID3FS/Path.pm +++ b/lib/ID3FS/Path.pm @@ -505,40 +505,10 @@ sub tags ") AS subselect\n" . "INNER JOIN files_x_tags ON subselect.files_id=files_x_tags.files_id\n" . "INNER JOIN tags ON files_x_tags.tags_id=tags.id\n"); - my @allused=$self->used_tags(); - my @used=grep { ref($_) ne "ARRAY"; } @allused; - my @used_with_vals=grep { ref($_) eq "ARRAY"; } @allused; -# print "tags(): USED: ", join(", ", @used), "\n"; -# print "tags(): USED_WITH_VALS: ", join(", ", map { "[".$_->[0]. ", ".$_->[1]."]";} @used_with_vals), "\n"; - my @orclauses=(); my @andclauses=(); my $id=$self->trailing_tag_id(); - if($hasvals) - { -# print "HAS_VALUES\n"; - my @values=map { "'".$_->[1]."'"; } grep { $_->[0] == $id; } @used_with_vals; - my $clause="(tags.parents_id='$id'"; - if(@values) - { - $clause .= " AND tags.id NOT IN (" . join(', ', @values) . ")"; - } - $clause .= ")"; - push(@andclauses, $clause); - } - else - { -# print "HASNT VALUES\n";; - if(@used) - { - push(@andclauses, "(NOT (tags.parents_id='' AND tags.id IN (" . join(', ', @used) . ")))"); - } - for my $pair (@used_with_vals) - { - push(@andclauses, "(NOT (tags.parents_id='" . $pair->[0] . "' AND tags.id='" . $pair->[1] . "'))"); - } - } - my $parentclause= "(tags.parents_id='"; + my $parentclause= "tags.parents_id='"; if($hasvals) { $parentclause .= $id; @@ -547,17 +517,19 @@ sub tags { $parentclause .= $parent; } - $parentclause .= "')"; + $parentclause .= "'"; push(@andclauses, $parentclause); - if(@orclauses) + my @used=$self->used_tags(); + if(@used) { - push(@andclauses, '( ' . join(' OR ', @orclauses) . ' )'); + push(@andclauses, "tags.id NOT IN (" . join(', ', @used) . ")"); } if(@andclauses) { $sql .= "WHERE " . join(' AND ', @andclauses) . "\n"; } + $sql .= "GROUP BY tags.name;"; print "SQL(TAGS): $sql\n" if($self->{verbose}); my @tagnames=$self->{db}->cmd_firstcol($sql);