Bug 375569 - Wrong tags in tooltips
Summary: Wrong tags in tooltips
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Database-Mysql (show other bugs)
Version: 5.4.0
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-01-26 00:31 UTC by Kusi
Modified: 2017-11-21 16:08 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.8.0


Attachments
tooltip (29.93 KB, image/png)
2017-01-26 00:31 UTC, Kusi
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kusi 2017-01-26 00:31:52 UTC
Created attachment 103649 [details]
tooltip

when I hover over an image with many tags (including stacked tags), strange & incomplete tag names are indicated on the tooltip. Please see attached screenshot

On the screenshot, I see
- Leute/Flavia
- Leute/Kusi
- Flavia
- Kusi
- Maman
- Leute/Timea

The corresponding sql query

select Tags.name, Tags.id as TagId, pid as TagParentId from Images
join ImageTags on Images.id = ImageTags.imageid
join Tags on ImageTags.tagid = Tags.id
where 
Images.name = "20161224T184451-D610-DSC_9616.JPG" AND
Images.album is not NULL;

returns
name	name	TagId	TagParentId
20161224T184451-D610-DSC_9616.JPG	Kusi	12	32
20161224T184451-D610-DSC_9616.JPG	Celine Brun	101	401
20161224T184451-D610-DSC_9616.JPG	Maman	103	102
20161224T184451-D610-DSC_9616.JPG	Alessia	159	401
20161224T184451-D610-DSC_9616.JPG	Color Label None	435	428
20161224T184451-D610-DSC_9616.JPG	Pick Label None	445	428
20161224T184451-D610-DSC_9616.JPG	Flavia	1'064	32
20161224T184451-D610-DSC_9616.JPG	Timea	1'210	32

and select * from Tags where id in (32,401,102, 100) returns

id	pid	name	icon	iconkde	lft	rgt
32	0	Leute	[NULL]	[NULL]	1'030	1'631
100	32	Nathalie Famille	[NULL]	[NULL]	1'469	1'576
102	100	Papa	[NULL]	[NULL]	1'570	1'571
401	100	Stephane 	[NULL]	[NULL]	1'528	1'531

It looks like the tooltip query doesn't handle multilevel (stacked) tags correctly. The behavior in digikam is not consistent, this bug does not happen with all stacked tags. For the example above, my db looks correct, though.

PS: for this query, are the lgt rgt columns needed?
Comment 1 Maik Qualmann 2017-11-20 21:49:40 UTC
Yes, the wrong tags display comes from wrong values of the lft/rgt columns. They wrong values were created by deleting or moving tags. This bug will be fixed in digiKam-5.8.0. However, you have to start with a clean DB. I close this bug.

Maik
Comment 2 caulier.gilles 2017-11-21 01:45:56 UTC
Maik,

The DB maintenance tool is perhaps able to fix lf/rg tags properties ?
Comment 3 Maik Qualmann 2017-11-21 06:06:53 UTC
Gilles,

unfortunately, the maintenance tool does not help here. A special function would have to be written to repair the lft/rgt columns. Here a user has published a script, see bug 386606. I have not tested it. But we have more problems due to errors, incorrect parent tags, deleted internal tags or deleted internal root tag. The best way is to start with a clean new DB. I think, the constant recalculation of the lft/rgt columns is not a good idea, I can not reproduce at the moment here wrong values in the lft/rgt columns after wild move and delete tags, but we should solve this differently in the future.

Maik
Comment 4 Maik Qualmann 2017-11-21 07:04:33 UTC
I think we are writing a new maintenance tool for digiKam-5.9.0. We could drop the Tags table, write new hidden tags, and then write back the tags tree just loaded into the model. That's actually the easiest way.

Maik
Comment 5 Kusi 2017-11-21 16:08:00 UTC
Maik, thanks for fixing this issue!

I've written a tool to recreate the lft/rgt columns. https://github.com/githubkusi/digikam_rebuild_mptt

Updating the lft/rgt columns is not too difficult, you can use my python reference implementation as a template. Your idea to copy the tags table to a temp table and back one by one to the tags table works I guess, but I don't think it's easier compared to update only lft/rgt in the main tags table.

best, Kusi