SDB.Database.ActiveFilterQuery function is inconsistent

This forum is for reporting bugs in MediaMonkey for Windows 4. Note that version 4 is no longer actively maintained as it has been replaced by version 5.

Moderator: Gurus

bob61
Posts: 157
Joined: Sun Dec 09, 2007 4:52 pm

SDB.Database.ActiveFilterQuery function is inconsistent

Post by bob61 »

I encountered a problem when using Magic Nodes. I'm using the latest release of MM3 (3.0.2.1134) on Windows XP. As part of the discussion with the script author (ZvezdanD) it appears to be a bug within MM3. ZvezdanD was very helpful and modified his script to provide some additional debug information that I've included below.

First, I set the Filters to Album View and then select this Magic Node

Code: Select all

Songs with lyrics|SQL filter:Length(Songs.Lyrics) > 0\<Artist>)

This is the resulting messages (first is from ZvezdanD's debug from his modified script):
Image
Image

For comparison, I then set the Filter to Available Tracks and everything then works. This is the message displayed:
Image


To further test I set Filters back to Album View and selected this MN

Code: Select all

Rating, Genre\<rating|statistic:count(all)>\<genre|statistic:count(all)>
This is the resulting messages (again first is debug info from ZvezdanD modified script):
Image
Image


Based on this information it appears the SDB.Database.ActiveFilterQuery function is inconsistent. For "Album View" filter it returns full SQL query:

Code: Select all

SELECT Songs.Id FROM Songs
For Available Tracks, Music and Audiobooks filters, it returns WHERE part of query. For example, for Available tracks, it is:

Code: Select all

(Songs.IdMedia in (31,28,29) OR Songs.CacheStatus=1)
PetrCBR
Posts: 1778
Joined: Tue Mar 07, 2006 5:31 pm
Location: Czech
Contact:

Re: SDB.Database.ActiveFilterQuery function is inconsistent

Post by PetrCBR »

Hi.

And what is "Album View" filter ? How looks rule you're used for this filter ?
bob61
Posts: 157
Joined: Sun Dec 09, 2007 4:52 pm

Post by bob61 »

I don't even recall creating this Filter, I thought it was just part of the standard filter. However in taking a look at it it really doesn't have any filtering in it that I see:

Image
Bex
Posts: 6316
Joined: Fri May 21, 2004 5:44 am
Location: Sweden

Post by Bex »

It seems that if you create a filter with no search criteria then MM returns:

Code: Select all

SELECT Songs.Id FROM Songs
Which obviously make some problem when using SDB.Database:ActiveFilterQuery in scripts.
Advanced Duplicate Find & Fix Find More From Same - Custom Search. | Transfer PlayStat & Copy-Paste Tags/AlbumArt between any tracks.
Tagging Inconsistencies Do you think you have your tags in order? Think again...
Play History & Stats Node Like having your Last-FM account stored locally, but more advanced.
Case & Leading Zero Fixer Works on filenames too!

All My Scripts
PetrCBR
Posts: 1778
Joined: Tue Mar 07, 2006 5:31 pm
Location: Czech
Contact:

Post by PetrCBR »

This issue will be fixed in next release. For "empty" filters will return "(1)" string.
Bex
Posts: 6316
Joined: Fri May 21, 2004 5:44 am
Location: Sweden

Post by Bex »

Do you mean an empty string when you say "(1)" string?
Advanced Duplicate Find & Fix Find More From Same - Custom Search. | Transfer PlayStat & Copy-Paste Tags/AlbumArt between any tracks.
Tagging Inconsistencies Do you think you have your tags in order? Think again...
Play History & Stats Node Like having your Last-FM account stored locally, but more advanced.
Case & Leading Zero Fixer Works on filenames too!

All My Scripts
ZvezdanD
Posts: 3265
Joined: Thu Jun 08, 2006 7:40 pm

Post by ZvezdanD »

PetrCBR wrote:This issue will be fixed in next release. For "empty" filters will return "(1)" string.
Please, could I get an answer for: http://www.mediamonkey.com/forum/viewtopic.php?t=25697?

I need to know a name of the active filter to display it after Magic Nodes caption between parenthesis in same way as Library display it. I tried to get a caption of Library node and parse such information, but this caption is always "Library" even when it displays "Library (Available Tracks)". If you already have INI key for this, why don't you use it?
ZvezdanD
Posts: 3265
Joined: Thu Jun 08, 2006 7:40 pm

Post by ZvezdanD »

Bex wrote:Do you mean an empty string when you say "(1)" string?
Hmm, maybe it should return something, because there is not another way to detect if some filter is active. For instance, if I have a line:

Code: Select all

If Len(SDB.Database.ActiveFilterQuery) > 0 Then
Maybe "True" is more logical.
PetrCBR
Posts: 1778
Joined: Tue Mar 07, 2006 5:31 pm
Location: Czech
Contact:

Post by PetrCBR »

It will return "(1)" string. As you said, there's no other way how to detect filter is active so even if filter rule will be empty, ActiveFilterQuery will return something ( and "(1)" can be used without problems in query).
Bex
Posts: 6316
Joined: Fri May 21, 2004 5:44 am
Location: Sweden

Post by Bex »

:-?
I get errors when I use "(1)" i a query...

I still think the function should return an empty string if no sql is supposed to be returned regardless if any filter is active or not. That's make more sense.

But I would lbe nice with some additional functions/methods here which would tell you if any filter is active and possibility to sql's of non active filter etc, That would really be helpful.
Advanced Duplicate Find & Fix Find More From Same - Custom Search. | Transfer PlayStat & Copy-Paste Tags/AlbumArt between any tracks.
Tagging Inconsistencies Do you think you have your tags in order? Think again...
Play History & Stats Node Like having your Last-FM account stored locally, but more advanced.
Case & Leading Zero Fixer Works on filenames too!

All My Scripts
PetrCBR
Posts: 1778
Joined: Tue Mar 07, 2006 5:31 pm
Location: Czech
Contact:

Post by PetrCBR »

OK Bex.

For next release i'll add following :

- ActiveFilterQuery returns empty string if filter's rule is empty
- new ActiveFilterID property will return ID of active filter (-1 when not filtered)
- new GetFilterQuery(ID) function will return query for filter specified by ID
Bex
Posts: 6316
Joined: Fri May 21, 2004 5:44 am
Location: Sweden

Post by Bex »

Great, thanks a lot! :D

I'm sure it will be used a lot in various script.
I will implement it in all my scripts, where applicable, as soon as it gets released.

What about a:
GetFilterList as StringList (returns a list of all configured Filters)

Not really needed since one could query the database but...
Advanced Duplicate Find & Fix Find More From Same - Custom Search. | Transfer PlayStat & Copy-Paste Tags/AlbumArt between any tracks.
Tagging Inconsistencies Do you think you have your tags in order? Think again...
Play History & Stats Node Like having your Last-FM account stored locally, but more advanced.
Case & Leading Zero Fixer Works on filenames too!

All My Scripts
PetrCBR
Posts: 1778
Joined: Tue Mar 07, 2006 5:31 pm
Location: Czech
Contact:

Post by PetrCBR »

List of filters can be very easily queried from database so i think it's not necessary.
Bex
Posts: 6316
Joined: Fri May 21, 2004 5:44 am
Location: Sweden

Post by Bex »

Yes, Ok. Thanks again!
Advanced Duplicate Find & Fix Find More From Same - Custom Search. | Transfer PlayStat & Copy-Paste Tags/AlbumArt between any tracks.
Tagging Inconsistencies Do you think you have your tags in order? Think again...
Play History & Stats Node Like having your Last-FM account stored locally, but more advanced.
Case & Leading Zero Fixer Works on filenames too!

All My Scripts
Post Reply