Bug 371578 - untagged images no longer shown in "no tags" overview when removing existing tag
Summary: untagged images no longer shown in "no tags" overview when removing existing tag
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Database-Mysql (show other bugs)
Version: 5.1.0
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-10-24 15:05 UTC by beaaeecffmiqwryxcmbw2ta2cukc4
Modified: 2017-11-20 22:16 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.8.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description beaaeecffmiqwryxcmbw2ta2cukc4 2016-10-24 15:05:00 UTC
When removing all tags from an image file using the "Captions/Tags" sidebar the image is not listed in the "No Tags" overview.

Reproducible: Always

Steps to Reproduce:
1. add a fresh image (verify that it shows up in the "No Tags" overview)
2. tag the image (the image file now vanished from the "No Tags" overview)
3. remove the tag _using "Captions/Tags" sidebar

Actual Results:  
image file is not listed in "No Tags"

Expected Results:  
image file should be listed in "No Tags"

When tagging an image, e.g. with "mytag", it seems that also the tags "Color Label None" and "Pick Label None" are applied to that image. When removing the "mytag" tag, the other two tags stay in place so the image file still has "tags", although they're not visible.

Example:
# image 84265 is freshly added
MariaDB [digikam]> select * from ImageTags where imageid = 84265;
Empty set (0.00 sec)

# tag the image with "mytag"
MariaDB [digikam]> select * from Tags where id in (select tagid from ImageTags where imageid = 84265);
+-----+------+------------------+------+---------+-----+-----+
| id  | pid  | name             | icon | iconkde | lft | rgt |
+-----+------+------------------+------+---------+-----+-----+
|  87 |   11 | mytag            | NULL | NULL    | 775 | 834 |
|  97 |   92 | Color Label None | NULL | NULL    | 698 | 699 |
| 107 |   92 | Pick Label None  | NULL | NULL    | 678 | 679 |
+-----+------+------------------+------+---------+-----+-----+
3 rows in set (0.00 sec)

# remove the tag "mytag"
MariaDB [digikam]> select * from Tags where id in (select tagid from ImageTags where imageid = 84265);
+-----+------+------------------+------+---------+-----+-----+
| id  | pid  | name             | icon | iconkde | lft | rgt |
+-----+------+------------------+------+---------+-----+-----+
|  97 |   92 | Color Label None | NULL | NULL    | 698 | 699 |
| 107 |   92 | Pick Label None  | NULL | NULL    | 678 | 679 |
+-----+------+------------------+------+---------+-----+-----+
2 rows in set (0.00 sec)
Comment 1 beaaeecffmiqwryxcmbw2ta2cukc4 2016-10-24 15:48:08 UTC
For those who want to "clean up" their database, that's how I did it.
Please be REALLY careful and VERIFY the results BEFORE the delete statement.

CREATE TABLE ImageDeleteMe (imageid INT(11) NOT NULL);

INSERT INTO ImageDeleteMe
    SELECT DISTINCT imageid FROM ImageTags WHERE
        tagid IN (
            SELECT id FROM Tags WHERE pid = ( 
                SELECT id FROM Tags WHERE name = '_Digikam_Internal_Tags_'
            ) AND name LIKE ('% None')
        ) AND 
        imageid NOT IN (
            SELECT imageid FROM ImageTags WHERE tagid NOT IN (
                SELECT id FROM Tags WHERE pid = ( 
                    SELECT id FROM Tags WHERE name = '_Digikam_Internal_Tags_'
                ) AND name LIKE ('% None')
            )
        );  

DELETE FROM ImageTags WHERE imageid IN (
    SELECT imageid FROM ImageDeleteMe
);

DROP TABLE ImageDeleteMe;
Comment 2 swatilodha27 2016-11-02 18:42:26 UTC
This issue is reproducible for me. (Using digiKam 5.2.0)

What I did :
1) Create a new album and add a new image. (Shown in "no tags" overview)
2) Assign a new tag (Removed from "no tags" overview)
3) Removed tag using Caption/Tags sidebar.

Observations
1) I think on removing the tags from Caption/Tags sidebar, the tags are just removed from the picture. "Actually" the tags are still present in the database. On running :
 SELECT * FROM TAGS; before and after assigning tags, tags remains in the table.
 But, SELECT * FROM IMAGETAGS; the tag is present before removal in the table. This implies the "Apply" after unchecking the specific tag works fine. 

2) After removal of tag, the image doesn't appear in "No tags" overview. Also, I note that:
-->Select Tags view from left
-->Click on the tag you assigned from the tags tree.
-->No image is visible for that tag.

Also, image isn't visible if digiKam is restarted at neither of the two places.
Comment 3 Maik Qualmann 2017-11-20 22:16:50 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