[tasque] Fix sqlite backend on latest versions of Mono.Data.Sqlite (bug #609712)



commit 8d7b76a8f70101faf003823dfd551f97dd643871
Author: Mario Carrion <mario carrion mx>
Date:   Mon Feb 15 07:35:35 2010 -0800

    Fix sqlite backend on latest versions of Mono.Data.Sqlite (bug #609712)
    
    This should fix the build on Mono >= 2.6.

 src/Backends/Sqlite/SqliteCategory.cs |    5 ++---
 src/Backends/Sqlite/SqliteTask.cs     |   10 ++++------
 2 files changed, 6 insertions(+), 9 deletions(-)
---
diff --git a/src/Backends/Sqlite/SqliteCategory.cs b/src/Backends/Sqlite/SqliteCategory.cs
index 51a714c..e1579b0 100644
--- a/src/Backends/Sqlite/SqliteCategory.cs
+++ b/src/Backends/Sqlite/SqliteCategory.cs
@@ -46,9 +46,8 @@ namespace Tasque.Backends.Sqlite
 		public SqliteCategory (SqliteBackend backend, string name)
 		{
 			this.backend = backend;
-			string command = String.Format("INSERT INTO Categories (Name, ExternalID) values ('{0}', '{1}')", name, string.Empty);
-			backend.Database.ExecuteScalar(command);
-			this.id = backend.Database.Connection.LastInsertRowId;
+			string command = String.Format("INSERT INTO Categories (Name, ExternalID) values ('{0}', '{1}'); SELECT last_insert_rowid();", name, string.Empty);
+			this.id = Convert.ToInt32 (backend.Database.ExecuteScalar(command));
 			//Logger.Debug("Inserted category named: {0} with id {1}", name, id);
 		}
 		
diff --git a/src/Backends/Sqlite/SqliteTask.cs b/src/Backends/Sqlite/SqliteTask.cs
index 1b7d93a..a9f5d42 100644
--- a/src/Backends/Sqlite/SqliteTask.cs
+++ b/src/Backends/Sqlite/SqliteTask.cs
@@ -18,11 +18,10 @@ namespace Tasque.Backends.Sqlite
 			this.backend = backend;
 			Logger.Debug("Creating New Task Object : {0} (id={1})", name, id);
 			name = backend.SanitizeText (name);
-			string command = String.Format("INSERT INTO Tasks (Name, DueDate, CompletionDate, Priority, State, Category, ExternalID) values ('{0}','{1}', '{2}','{3}', '{4}', '{5}', '{6}')", 
+			string command = String.Format("INSERT INTO Tasks (Name, DueDate, CompletionDate, Priority, State, Category, ExternalID) values ('{0}','{1}', '{2}','{3}', '{4}', '{5}', '{6}'); SELECT last_insert_rowid();", 
 								name, Database.FromDateTime(DateTime.MinValue), Database.FromDateTime(DateTime.MinValue), 
 								((int)(TaskPriority.None)), ((int)TaskState.Active), 0, string.Empty );
-			backend.Database.ExecuteScalar(command);
-			this.id = backend.Database.Connection.LastInsertRowId;
+			this.id = Convert.ToInt32 (backend.Database.ExecuteScalar (command));
 		}
 		
 		public SqliteTask (SqliteBackend backend, int id)
@@ -211,9 +210,8 @@ namespace Tasque.Backends.Sqlite
 		{
 			Logger.Debug("Creating New Note Object : {0} (id={1})", text, id);
 			text = backend.SanitizeText (text);
-			string command = String.Format("INSERT INTO Notes (Task, Text) VALUES ('{0}','{1}')", id, text);
-			backend.Database.ExecuteScalar(command);
-			int taskId = backend.Database.Connection.LastInsertRowId;
+			string command = String.Format("INSERT INTO Notes (Task, Text) VALUES ('{0}','{1}'); SELECT last_insert_rowid();", id, text);
+			int taskId = Convert.ToInt32 (backend.Database.ExecuteScalar(command));
 
 			return new SqliteNote (taskId, text);
 		}



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