[smuxi] Engine: implemented SqliteMessageBuffer.RemoveAt()
- From: Mirco M. M. Bauer <mmmbauer src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [smuxi] Engine: implemented SqliteMessageBuffer.RemoveAt()
- Date: Fri, 28 Feb 2014 20:25:51 +0000 (UTC)
commit a12bab068228cf01c39311e95373b8d5d6541f65
Author: Mirco Bauer <meebey meebey net>
Date: Wed Feb 26 22:45:47 2014 +0100
Engine: implemented SqliteMessageBuffer.RemoveAt()
src/Engine/MessageBuffers/SqliteMessageBuffer.cs | 27 ++++++++++++++++++++-
1 files changed, 25 insertions(+), 2 deletions(-)
---
diff --git a/src/Engine/MessageBuffers/SqliteMessageBuffer.cs
b/src/Engine/MessageBuffers/SqliteMessageBuffer.cs
index c377f04..44210ad 100644
--- a/src/Engine/MessageBuffers/SqliteMessageBuffer.cs
+++ b/src/Engine/MessageBuffers/SqliteMessageBuffer.cs
@@ -163,9 +163,32 @@ namespace Smuxi.Engine
throw new NotImplementedException ();
}
- public override void RemoveAt(int index)
+ public override void RemoveAt(int offset)
{
- throw new NotImplementedException ();
+ int id = -1;
+ using (var cmd = Connection.CreateCommand()) {
+ cmd.CommandText = "SELECT ID FROM Messages " +
+ " ORDER BY ID " +
+ " LIMIT 1 OFFSET @offset";
+
+ var param = cmd.CreateParameter();
+ param.ParameterName = "offset";
+ param.Value = offset;
+ cmd.Parameters.Add(param);
+
+ id = (int) Convert.ChangeType(cmd.ExecuteScalar(), typeof(int));
+ }
+
+ using (var cmd = Connection.CreateCommand()) {
+ cmd.CommandText = "DELETE FROM Messages WHERE ID = @id";
+
+ var param = cmd.CreateParameter();
+ param.ParameterName = "id";
+ param.Value = id;
+ cmd.Parameters.Add(param);
+
+ cmd.ExecuteNonQuery();
+ }
}
public override void Flush()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]