Bug 176654 - Buttons for setting album date in album properties not working
Summary: Buttons for setting album date in album properties not working
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Database-Albums (show other bugs)
Version: 0.10.0
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-12-01 22:35 UTC by David Eriksson
Modified: 2017-07-19 13:59 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 0.10.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Eriksson 2008-12-01 22:35:03 UTC
Version:           0.10.0-svn (using KDE 4.1.3)
Compiler:          gcc 4.3.2 cmake 2.6 
OS:                Linux
Installed from:    Ubuntu Packages

When clicking the Oldest or Newest buttons does nothing and clicking Average gives a error message. I look in the code and it looks like these functions use the old 0.9 database schema.
Here is a possible patch to solve the problem:

Index: digikam/libs/database/albumdb.cpp
===================================================================
--- digikam/libs/database/albumdb.cpp   (revision 891372)
+++ digikam/libs/database/albumdb.cpp   (working copy)
@@ -2700,8 +2700,9 @@
 QDate AlbumDB::getAlbumLowestDate(int albumID)
 {
     QList<QVariant> values;
-    d->db->execSql( QString("SELECT MIN(datetime) FROM Images "
-                            "WHERE album=? GROUP BY album"),
+    d->db->execSql( "SELECT MIN(creationDate) FROM ImageInformation "
+                    " LEFT JOIN Images ON Images.id=ImageInformation.imageid "
+                    " WHERE Images.album=? GROUP BY Images.album;",
                     albumID, &values );
     if (!values.isEmpty())
         return QDate::fromString( values.first().toString(), Qt::ISODate );
@@ -2712,8 +2713,9 @@
 QDate AlbumDB::getAlbumHighestDate(int albumID)
 {
     QList<QVariant> values;
-    d->db->execSql( QString("SELECT MAX(datetime) FROM Images "
-                            "WHERE album=? GROUP BY album"),
+    d->db->execSql( "SELECT MAX(creationDate) FROM ImageInformation "
+                    " LEFT JOIN Images ON Images.id=ImageInformation.imageid "
+                    " WHERE Images.album=? GROUP BY Images.album;",
                     albumID , &values );
     if (!values.isEmpty())
         return QDate::fromString( values.first().toString(), Qt::ISODate );
@@ -2724,7 +2726,9 @@
 QDate AlbumDB::getAlbumAverageDate(int albumID)
 {
     QList<QVariant> values;
-    d->db->execSql( QString("SELECT datetime FROM Images WHERE album=?"),
+    d->db->execSql( "SELECT creationDate FROM ImageInformation "
+                    " LEFT JOIN Images ON Images.id=ImageInformation.imageid "
+                    " WHERE Images.album=?;",
                     albumID , &values);
 
     int differenceInSecs = 0;
Comment 1 caulier.gilles 2008-12-02 06:37:46 UTC
David,

Thanks for the patch...

Marcel, This entry is for you (:=)))

Gilles Caulier
Comment 2 Marcel Wiesweg 2008-12-02 14:42:10 UTC
SVN commit 891625 by mwiesweg:

Patch from David Eriksson:
Fix SQL

CCBUG: 176654

 M  +9 -5      albumdb.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=891625
Comment 3 Marcel Wiesweg 2008-12-02 14:43:45 UTC
David, thank you for your help!