diff --git a/CHANGELOG.md b/CHANGELOG.md index 08f3a3c..3d5877a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog ## [Unreleased](https://github.com/gilzoide/unity-sqlite-net/compare/1.2.0...HEAD) +### Added +- Add support for updating a struct passed to `Insert` with overload accepting `ref T` + ### Fixed - Support for struct return types in queries diff --git a/Runtime/SQLiteExtensions.cs b/Runtime/SQLiteExtensions.cs index 2140832..e682b16 100644 --- a/Runtime/SQLiteExtensions.cs +++ b/Runtime/SQLiteExtensions.cs @@ -81,4 +81,39 @@ static SQLite3() #endif } } + + public static class ISQLiteConnectionExtensions + { + public static int Insert(this ISQLiteConnection connection, ref T obj) + { + object boxed = obj; + int result = connection.Insert(boxed); + obj = (T) boxed; + return result; + } + + public static int Insert(this ISQLiteConnection connection, ref T obj, Type objType) + { + object boxed = obj; + int result = connection.Insert(boxed, objType); + obj = (T) boxed; + return result; + } + + public static int Insert(this ISQLiteConnection connection, ref T obj, string extra) + { + object boxed = obj; + int result = connection.Insert(boxed, extra); + obj = (T) boxed; + return result; + } + + public static int Insert(this ISQLiteConnection connection, ref T obj, string extra, Type objType) + { + object boxed = obj; + int result = connection.Insert(boxed, extra, objType); + obj = (T) boxed; + return result; + } + } }