Smart playlist bug

Felix Rotthowe felix.rotthowe at cs.uni-dortmund.de
Sat Jan 20 01:38:39 UTC 2007


Hello there,

today I tried to create a smart playlist (using current svn version)  
with all non rated songs and noticed that this doesn't work because  
it contained ALL songs of my collection. After a little research, I  
found out that the generated SQL query contains the substring  
"COALESCE(statistics.rating,0) <> '0' ", which seems to be wrong  
because statistics.rating is supposed to be an integer value rather  
than a string.

I first searched the problem inside  
CriteriaEditor::getSearchCriteria, but soon found out this method is  
never used (in fact, I deleted it and amarok compiled without  
complaints).
After that, I noticed amarok is using xml based playlists, from which  
the sql query is build. Inside QueryBuilder::excludeFilter I found  
the following code:

if (exact)
   s = " <> '" + CollectionDB::instance()->escapeString( filter ) +  
"' ";

Because the filter string comes from the xml playlist description, at  
this point there is no information wheter it was a numeric or string  
value. Nevertheless, the following code should be ok with all queries  
because sqlite converts numbers to strings if the are matched against  
another string value (so for example an artist called 666 would be  
excluded although the isNumber check succeeds).

if (exact) {
     bool isNumber;
     filter.toInt( &isNumber );
     if (isNumber) {
         s = " <> " + CollectionDB::instance()->escapeString 
( filter ) + " ";
     } else {
         s = " <> '" + CollectionDB::instance()->escapeString 
( filter ) + "' ";
     }
}

This fixed the bug for me. Please let me know if this was the right  
place to change the code, because I've just started exploring the  
amarok sources.

Greetings,
Felix



More information about the Amarok mailing list