Bug 189080 - comments not saved with digikam 0.10.0 on KDE 4.2.2
Summary: comments not saved with digikam 0.10.0 on KDE 4.2.2
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Database-Schema (show other bugs)
Version: 0.10.0
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-04-07 23:50 UTC by Egbert König
Modified: 2017-07-26 05:21 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In: 1.0.0


Attachments
gzipped compressed xml export of table imagecomments with duplicate imageid's (149.43 KB, application/octet-stream)
2009-04-11 18:23 UTC, Egbert König
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Egbert König 2009-04-07 23:50:30 UTC
Version:           0.10.0 (using KDE 4.2.2)
OS:                Linux
Installed from:    SuSE RPMs

Since I have installed KDE 4.2.2 my picture comments are neither stored to the digikam database nor to the EXIF comment fields (I have enabled the latter for a test). Rating and tags are stored to the database. Existing comments are read from the database.
Comment 1 Egbert König 2009-04-07 23:52:18 UTC
digikam is running under openSuSE 11.1 with KDE 4.2.2 from the openSuSE Build Service repository KDE:/KDE4:/Factory:/Desktop/openSUSE_11.1/, architecture is x86_64.
Comment 2 caulier.gilles 2009-04-07 23:53:29 UTC
Hum, not reproducible here. Mandriva 2009, x86-32

Gilles Caulier
Comment 3 Egbert König 2009-04-08 23:11:09 UTC
I have checked again. I have found,that I could save comments to some pictures and not to some other pictures. The reason was, that there have been duplicate entries for the same imageid in database table "imagecomments". The newer entries had lower ID values (column ID is different from column IMAGEID). Obviously the comment shown is that with the highest ID value. After I have removed the wrong comments (they had all the same text from my camera), I could see the comments, I have entered before. I was now also able to change the comments.

Might this be a consequence of converting the database from digikam3.db? The affected pictures have been in the database before the conversion.
Comment 4 caulier.gilles 2009-04-08 23:13:22 UTC
Yes, certainly a bug.

Marcel ?

Gilles
Comment 5 Marcel Wiesweg 2009-04-11 17:35:44 UTC
May it be that the invalid comment texts can be found in the exif/iptc metadata?
Do you still have an example of the multiple entries in your ImageComments table (with all fields in that table)?
Comment 6 Egbert König 2009-04-11 18:23:08 UTC
Created attachment 32761 [details]
gzipped compressed xml export of table imagecomments with duplicate imageid's

You're totally right. The duplicate comments were coming from the pictures' EXIF comment fields. Please get the attached table export. Examples for this failure are e.g. starting at imageid 11370. These were the pictures which I wanted to comment when my comments were not accepted.
Comment 7 Marcel Wiesweg 2009-04-12 21:20:40 UTC
Ok the cause of this problem is a SQL subtlety that I was not aware of:
"The UNIQUE constraint causes an unique index to be created on the specified columns. All NULL values are considered different from each other and from all other values for the purpose of determining uniqueness, hence a UNIQUE column may contain multiple entries with the value of NULL."
There is a UNIQUE constraint in ImageComments for (imageid, type, language, author). Now you have identical values for imageid, type and language and NULL for author. Would author be '' (the empty string) there would not be duplicate entries.
Now I have to find out how to solve that.
Comment 8 Marcel Wiesweg 2009-04-13 14:46:49 UTC
This may be SQL to fix an affected database:

DELETE FROM ImageComments WHERE id IN (SELECT C2.id FROM ImageComments AS C1, ImageComments AS C2 WHERE C1.imageid=C2.imageid AND C1.type=C2.type AND C1.language=C2.language AND C1.author IS NULL AND C2.author IS NULL AND C1.id < C2.id);

(removes all second entries where the UNIQUE enforcement fails because author is null)
Comment 9 Egbert König 2009-04-13 15:43:43 UTC
Thanks for the query. I have used it to identify the duplicate entries. As sometimes the first entry had the right comment and sometimes the second, I have delete the duplicate entries interactively with knoda/KDE3.
Comment 10 Gerhard Kulzer 2009-04-23 23:07:57 UTC
*** Bug 190411 has been marked as a duplicate of this bug. ***
Comment 11 Marcel Wiesweg 2009-07-05 18:10:39 UTC
SVN commit 991767 by mwiesweg:

Take into account that a NULL value will prevent a UNIQUE restriction taking effect.
1) In ImageComments, treat an empty author like a null author
2) When upgrading - there will still be users upgrading from 0.9, work around it
   by deleting all affected entries before upgrading the image comments from the old db

Users already affected by this bug need to solve it manually as outlined in the bug report.

BUG: 189080

 M  +3 -1      NEWS  
 M  +9 -4      libs/database/imagecomments.cpp  
 M  +8 -0      libs/database/schemaupdater.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=991767
Comment 12 Marcel Wiesweg 2009-07-11 15:35:28 UTC
*** Bug 199482 has been marked as a duplicate of this bug. ***
Comment 13 Marcel Wiesweg 2010-01-01 17:46:32 UTC
*** Bug 220903 has been marked as a duplicate of this bug. ***