Skip to content

Commit

Permalink
Revert "Add Update event."
Browse files Browse the repository at this point in the history
This reverts commits af506c4 & a94aaf2.
  • Loading branch information
bricelam committed Jan 30, 2018
1 parent 1da84d8 commit 2e3c403
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 218 deletions.
7 changes: 0 additions & 7 deletions Microsoft.Data.Sqlite.sln
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BulkInsertSample", "samples
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CollationSample", "samples\CollationSample\CollationSample.csproj", "{A5E96F24-953A-4E71-9081-736E11D8229F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataChangedSample", "samples\DataChangedSample\DataChangedSample.csproj", "{61F83459-79DD-4640-AF11-574ABAB529F1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DateAndTimeSample", "samples\DateAndTimeSample\DateAndTimeSample.csproj", "{EBC5675D-1FD0-4F77-93D0-F970EB7A29EC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DirtyReadSample", "samples\DirtyReadSample\DirtyReadSample.csproj", "{CB405B7D-81E5-48B6-9E24-AC901D0423EE}"
Expand Down Expand Up @@ -100,10 +98,6 @@ Global
{A5E96F24-953A-4E71-9081-736E11D8229F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A5E96F24-953A-4E71-9081-736E11D8229F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A5E96F24-953A-4E71-9081-736E11D8229F}.Release|Any CPU.Build.0 = Release|Any CPU
{61F83459-79DD-4640-AF11-574ABAB529F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{61F83459-79DD-4640-AF11-574ABAB529F1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{61F83459-79DD-4640-AF11-574ABAB529F1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{61F83459-79DD-4640-AF11-574ABAB529F1}.Release|Any CPU.Build.0 = Release|Any CPU
{EBC5675D-1FD0-4F77-93D0-F970EB7A29EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EBC5675D-1FD0-4F77-93D0-F970EB7A29EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EBC5675D-1FD0-4F77-93D0-F970EB7A29EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -149,7 +143,6 @@ Global
{7EFA4FBC-33F1-44FF-9E8F-57EC0FE32201} = {D30CC1C7-D46C-4640-8CE6-EC9ED34DEDA5}
{7BC06AAD-FAD0-4FDE-BB3E-4A3D56D1FEBC} = {D30CC1C7-D46C-4640-8CE6-EC9ED34DEDA5}
{A5E96F24-953A-4E71-9081-736E11D8229F} = {D30CC1C7-D46C-4640-8CE6-EC9ED34DEDA5}
{61F83459-79DD-4640-AF11-574ABAB529F1} = {D30CC1C7-D46C-4640-8CE6-EC9ED34DEDA5}
{EBC5675D-1FD0-4F77-93D0-F970EB7A29EC} = {D30CC1C7-D46C-4640-8CE6-EC9ED34DEDA5}
{CB405B7D-81E5-48B6-9E24-AC901D0423EE} = {D30CC1C7-D46C-4640-8CE6-EC9ED34DEDA5}
{67F8FB83-302C-4FBE-A2DC-F4FF5CEC8776} = {D30CC1C7-D46C-4640-8CE6-EC9ED34DEDA5}
Expand Down
16 changes: 0 additions & 16 deletions samples/DataChangedSample/DataChangedSample.csproj

This file was deleted.

46 changes: 0 additions & 46 deletions samples/DataChangedSample/Program.cs

This file was deleted.

19 changes: 0 additions & 19 deletions src/Microsoft.Data.Sqlite.Core/SqliteConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ public partial class SqliteConnection : DbConnection
static SqliteConnection()
=> BundleInitializer.Initialize();

/// <summary>
/// Occurs whenever a row is updated, inserted or deleted in a rowid table.
/// </summary>
public event EventHandler<UpdateEventArgs> Update;

/// <summary>
/// Initializes a new instance of the <see cref="SqliteConnection" /> class.
/// </summary>
Expand Down Expand Up @@ -230,13 +225,8 @@ public override void Open()
SqliteException.ThrowExceptionForRC(rc, _db);

SetState(ConnectionState.Open);

raw.sqlite3_update_hook(_db, UpdateHook, null);
}

private void UpdateHook(object user_data, int type, string database, string table, long rowid)
=> OnUpdate(new UpdateEventArgs((UpdateEventType)type, database, table, rowid));

/// <summary>
/// Closes the connection to the database. Open transactions are rolled back.
/// </summary>
Expand All @@ -248,8 +238,6 @@ public override void Close()
return;
}

raw.sqlite3_update_hook(_db, null, null);

Transaction?.Dispose();

foreach (var reference in _commands)
Expand Down Expand Up @@ -462,13 +450,6 @@ public virtual void BackupDatabase(SqliteConnection destination, string destinat
}
}

/// <summary>
/// Raises the Microsoft.Data.Sqlite.SqliteConnection.Update event.
/// </summary>
/// <param name="e">A Microsoft.Data.Sqlite.UpdateEventArgs that contains the event data.</param>
protected virtual void OnUpdate(UpdateEventArgs e)
=> Update?.Invoke(this, e);

private void CreateFunctionCore<TState, TResult>(
string name,
int arity,
Expand Down
60 changes: 0 additions & 60 deletions src/Microsoft.Data.Sqlite.Core/UpdateEventArgs.cs

This file was deleted.

28 changes: 0 additions & 28 deletions src/Microsoft.Data.Sqlite.Core/UpdateEventType.cs

This file was deleted.

42 changes: 0 additions & 42 deletions test/Microsoft.Data.Sqlite.Tests/SqliteConnectionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -951,48 +951,6 @@ public void EnableExtensions_throws_when_closed()
}
}

[Fact]
public void DataChange_event_works()
{
using (var connection = new SqliteConnection("Data Source=:memory:"))
{
var list = new List<UpdateEventArgs>();
connection.Update += (sender, e) =>
{
Assert.Equal(connection, sender);
list.Add(e);
};

connection.Open();
connection.ExecuteNonQuery(
"CREATE TABLE Person (ID INTEGER PRIMARY KEY, FirstName TEXT, LastName TEXT NOT NULL, Code INT UNIQUE);");
Assert.Empty(list);

connection.ExecuteNonQuery("INSERT INTO Person VALUES(101, 'John', 'Dee', 123);");
Assert.Single(list);
Assert.Equal(UpdateEventType.Insert, list[0].Event);
Assert.Equal("main", list[0].Database);
Assert.Equal("Person", list[0].Table);
Assert.Equal(101, list[0].RowId);
list.Clear();

connection.ExecuteNonQuery("UPDATE Person SET Code=234 WHERE ID=101;");
Assert.Single(list);
Assert.Equal(UpdateEventType.Update, list[0].Event);
Assert.Equal("main", list[0].Database);
Assert.Equal("Person", list[0].Table);
Assert.Equal(101, list[0].RowId);
list.Clear();

connection.ExecuteNonQuery("DELETE FROM Person WHERE ID=101;");
Assert.Single(list);
Assert.Equal(UpdateEventType.Delete, list[0].Event);
Assert.Equal("main", list[0].Database);
Assert.Equal("Person", list[0].Table);
Assert.Equal(101, list[0].RowId);
}
}

#if !NETCOREAPP2_0
[Fact]
public void DbProviderFactory_works()
Expand Down

0 comments on commit 2e3c403

Please sign in to comment.