Skip to content

Commit

Permalink
Fix insert tracing
Browse files Browse the repository at this point in the history
  • Loading branch information
praeclarum committed May 26, 2017
1 parent ed244cd commit 86cefe8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
3 changes: 0 additions & 3 deletions src/SQLite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1358,9 +1358,6 @@ public int Insert (object obj, string extra, Type objType)
// We lock here to protect the prepared statement returned via GetInsertCommand.
// A SQLite prepared statement can be bound for only one operation at a time.
try {
if (Trace) {
Tracer?.Invoke ("Execute Insert: " + insertCmd.CommandText);
}
count = insertCmd.ExecuteNonQuery (vals);
} catch (SQLiteException ex) {
if (SQLite3.ExtendedErrCode (this.Handle) == SQLite3.ExtendedResult.ConstraintNotNull) {
Expand Down
20 changes: 20 additions & 0 deletions tests/InsertTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,26 @@ public void InsertALot()
Assert.AreEqual(numCount, n, "Num counted must = num objects");
}

[Test]
public void InsertTraces ()
{
var oldTracer = _db.Tracer;
var oldTrace = _db.Trace;

var traces = new List<string> ();
_db.Tracer = traces.Add;
_db.Trace = true;

var obj1 = new TestObj () { Text = "GLaDOS loves tracing!" };
var numIn1 = _db.Insert (obj1);

Assert.AreEqual (1, numIn1);
Assert.AreEqual (1, traces.Count);

_db.Tracer = oldTracer;
_db.Trace = oldTrace;
}

[Test]
public void InsertTwoTimes()
{
Expand Down

0 comments on commit 86cefe8

Please sign in to comment.