From 3f7bbbcb0f7b0a3df27062f699ff1f9bfd1badda Mon Sep 17 00:00:00 2001 From: gilzoide Date: Sat, 1 Feb 2025 14:20:48 -0300 Subject: [PATCH] Fix support for struct return types in queries --- Plugins/tools~/fix-library-path.sed | 4 +++- README.md | 3 ++- Runtime/sqlite-net/SQLite.cs | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Plugins/tools~/fix-library-path.sed b/Plugins/tools~/fix-library-path.sed index 9406e7e..d0700da 100644 --- a/Plugins/tools~/fix-library-path.sed +++ b/Plugins/tools~/fix-library-path.sed @@ -23,7 +23,6 @@ a\ #endif } - # Make Quote function public, for libraries making raw queries s/static string Quote/public static string Quote/ @@ -37,3 +36,6 @@ s/Column ("name")/Column ("name"), UnityEngine.Scripting.RequiredMember/ # Use main thread TaskScheduler in WebGL s/TaskScheduler\.Default/SQLiteAsyncExtensions.TaskScheduler/ + +# Disable fast setters when ObjectType is struct +s/cols\[i] != null/!typeof(T).IsValueType \&\& cols[i] != null/ diff --git a/README.md b/README.md index d358076..f261019 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,8 @@ Third-party code: - `LibraryPath` is made public. This is useful for libraries that want to bind additional native SQLite functions via P/Invoke. - `SQLiteConnection.Quote` is made public. - This is be useful for libraries making raw queries. + This is useful for libraries making raw queries. - `SQLite3.SetDirectory` is only defined in Windows platforms. - Adds a `[RequiredMember]` attribute to `ColumnInfo.Name` property, fixing errors on columns when managed code stripping is enabled. - Changes the `TaskScheduler` used by the async API on WebGL to one that executes tasks on Unity's main thread. +- Fix support for struct return types in queries diff --git a/Runtime/sqlite-net/SQLite.cs b/Runtime/sqlite-net/SQLite.cs index e4e950f..f9fc593 100644 --- a/Runtime/sqlite-net/SQLite.cs +++ b/Runtime/sqlite-net/SQLite.cs @@ -3146,7 +3146,7 @@ public IEnumerable ExecuteDeferredQuery (TableMapping map) for (int i = 0; i < cols.Length; i++) { var name = SQLite3.ColumnName16 (stmt, i); cols[i] = map.FindColumn (name); - if (cols[i] != null) + if (!typeof(T).IsValueType && cols[i] != null) if (getSetter != null) { fastColumnSetters[i] = (Action)getSetter.Invoke(null, new object[]{ _conn, cols[i]}); }