f-spot r3561 - in trunk: . src



Author: sdelcroix
Date: Thu Jan 17 09:52:33 2008
New Revision: 3561
URL: http://svn.gnome.org/viewvc/f-spot?rev=3561&view=rev

Log:
2008-01-17  Stephane Delcroix  <sdelcroix novell com>

	* src/Updater.cs: v12, clean dead tag-photos associations caused by
	bgo #488545. Fixes bgo #507950.


Modified:
   trunk/ChangeLog
   trunk/src/Updater.cs

Modified: trunk/src/Updater.cs
==============================================================================
--- trunk/src/Updater.cs	(original)
+++ trunk/src/Updater.cs	Thu Jan 17 09:52:33 2008
@@ -213,7 +213,7 @@
 			// Update to version 11.0, rating
 			AddUpdate (new Version (11,0),delegate () {
  				string tmp_photos = MoveTableToTemp ("photos");
- 				ExecuteNonQuery (
+ 				Execute (
  					"CREATE TABLE photos (                                     " +
  					"	id                 INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, " +
  					"	time               INTEGER NOT NULL,	   	   " +
@@ -224,13 +224,18 @@
 					"       rating             INTEGER NULL			   " +
  					")");
  
- 				ExecuteNonQuery (String.Format (
+ 				Execute (String.Format (
  					"INSERT INTO photos (id, time, uri, description, roll_id, default_version_id, rating) " +
  					"SELECT id, time, uri, description, roll_id, default_version_id, null  " + 
  					"FROM  {0} ", tmp_photos));
 			});
+
+			//Update to version 12.0, remove dead associations, bgo #507950, #488545
+			AddUpdate (new Version (12, 0), delegate () {
+				Execute ("DELETE FROM photo_tags WHERE tag_id NOT IN (SELECT id FROM tags)");
+			});
 			
-			// Update to version 12.0
+			// Update to version 13.0
 			//AddUpdate (new Version (0,0),delegate () {
 			//	do update here
 			//});
@@ -323,6 +328,16 @@
 			}
 		}
 
+		private static int Execute (string statement)
+		{
+			return db.Database.Execute (statement);
+		}
+
+		private static int Execute (DbCommand command)
+		{
+			return db.Database.Execute (command);
+		}
+
 		private static void ExecuteNonQuery (string statement)
 		{
 			db.Database.ExecuteNonQuery(statement);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]