filter constraint ids, drop undefs
authorIan Beckwith <ianb@erislabs.net>
Sun, 26 Sep 2010 22:34:08 +0000 (23:34 +0100)
committerIan Beckwith <ianb@erislabs.net>
Sun, 26 Sep 2010 22:34:08 +0000 (23:34 +0100)
lib/ID3FS/DB.pm

index a523033..8794ca1 100644 (file)
@@ -160,7 +160,7 @@ sub tags
        my $cid=$constraint->{id};
        push(@ids, $cid);
     }
-    @ids = map( { "\"$_\""; } @ids) unless($self->{postgres});
+    @ids = map( { "\"$_\""; } grep { defined; } @ids) unless($self->{postgres});
     my $tagstr=join(", ", @ids);
     my $sql = ($main_sql_start . $tagstr .
               $main_sql_mid   . $tagstr .
@@ -207,7 +207,7 @@ sub artists
        my $cid=$constraint->{id};
        push(@ids, $cid);
     }
-    @ids = map( { "\"$_\""; } @ids) unless($self->{postgres});
+    @ids = map( { "\"$_\""; } grep { defined; } @ids) unless($self->{postgres});
     my $tagstr=join(", ", @ids);
     my $sql = ($main_sql_start . $tagstr .
               $main_sql_end);
@@ -240,7 +240,7 @@ sub albums
        my $cid=$constraint->{id};
        push(@ids, $cid);
     }
-    @ids = map( { "\"$_\""; } @ids) unless($self->{postgres});
+    @ids = map( { "\"$_\""; } grep { defined; } @ids) unless($self->{postgres});
     my $str=join(", ", @ids);
     my $sql = ($main_sql_start . $str .
               $main_sql_end);
@@ -330,7 +330,7 @@ sub tracks
        my $cid=$constraint->{id};
        push(@ids, $cid);
     }
-    @ids = map( { "\"$_\""; } @ids) unless($self->{postgres});
+    @ids = map( { "\"$_\""; } grep { defined; } @ids) unless($self->{postgres});
     my $str=join(", ", @ids);
     my $sql = ($main_sql_start . $str .
               $main_sql_end);