Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
35 changes: 35 additions & 0 deletions Runtime/SQLiteExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,39 @@ static SQLite3()
#endif
}
}

public static class ISQLiteConnectionExtensions
{
public static int Insert<T>(this ISQLiteConnection connection, ref T obj)
{
object boxed = obj;
int result = connection.Insert(boxed);
obj = (T) boxed;
return result;
}

public static int Insert<T>(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<T>(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<T>(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;
}
}
}