filter out empty artist/album names
authorIan Beckwith <ianb@erislabs.net>
Mon, 11 Oct 2010 02:03:16 +0000 (03:03 +0100)
committerIan Beckwith <ianb@erislabs.net>
Mon, 11 Oct 2010 02:03:16 +0000 (03:03 +0100)
lib/ID3FS/DB.pm
lib/ID3FS/Path.pm

index d598fe7..aa9eaf1 100644 (file)
@@ -492,6 +492,13 @@ sub last_insert_id
     }
 }
 
+sub lookup_id
+{
+    my($self, $table, $name)=@_;
+    my($id)=$self->cmd_onerow("SELECT id FROM $table where name=?", $name);
+    return $id;
+}
+
 __DATA__
 
 CREATE TABLE id3fs (
index cee1a45..68c0ab8 100644 (file)
@@ -561,7 +561,7 @@ sub artists
     my($self)=@_;
     if(!@{$self->{elements}}) # /ALL
     {
-       my $sql="SELECT DISTINCT name FROM artists;";
+       my $sql="SELECT DISTINCT name FROM artists WHERE name!='';";
        return($self->{db}->cmd_firstcol($sql));
     }
     my @ids=();
@@ -570,6 +570,7 @@ sub artists
             ") AS subselect\n" .
             "INNER JOIN files ON subselect.files_id=files.id\n" .
             "INNER JOIN artists ON files.artists_id=artists.id\n" .
+            "WHERE artists.name != ''\n" .
             "GROUP BY artists.name;");
     print "SQL: $sql\n";
     my @tagnames=$self->{db}->cmd_firstcol($sql);
@@ -593,6 +594,7 @@ sub albums
             "\t) AS subselect\n" .
             "INNER JOIN files ON subselect.files_id=files.id\n" .
             "INNER JOIN albums ON files.albums_id=albums.id\n" .
+            "WHERE albums.name != ''\n" .
             "GROUP BY albums.name;");
     print "SQL(ALBUMS): \n$sql\n";
     my @names=$self->{db}->cmd_firstcol($sql);
@@ -914,11 +916,4 @@ sub tags_with_values
     return $tags;
 }
 
-sub lookup_id
-{
-    my($self, $table, $name)=@_;
-    my($id)=$self->{db}->cmd_onerow("SELECT id FROM $table where name=?", $name);
-    return $id;
-}
-
 1;