From acd957750941c769f509b7b796cf65a706ca09d4 Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Fri, 9 Oct 2026 10:23:47 +0200 Subject: [PATCH] SqliteVec: drop net462 and netstandard2.0 support sqlite3_load_extension is stubbed out in SQLitePCLRaw's .NET Framework (net471) and .NET Standard (netstandard2.0) provider assets, so vec0 can never load when consumed as net462 or netstandard2.0 -- confirmed via MEVD/test/SqliteVec.ConformanceTests and an independent standalone net472 repro (CommunityToolkit/AI#62). Only the net8.0 SQLitePCLRaw asset (resolved by our net8.0/net10.0 targets) works correctly. - Drop net462/netstandard2.0 from TargetFrameworks; keep net10.0;net8.0. - Remove the now-always-true "#if NET" conditionals (and their "#else" .NET Framework/.NET Standard fallbacks) from the provider source, since NET is defined for all remaining TFMs. - Drop net472 from SqliteVec.ConformanceTests (was net10.0 plus the shared NetFrameworkTfm property). - Bump package version to 1.0.3-preview. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: dc4fb29c-b28c-4a98-85a7-d15fbb0629d1 --- MEVD/src/SqliteVec/SqliteFilterTranslator.cs | 2 -- MEVD/src/SqliteVec/SqliteMapper.cs | 9 +-------- MEVD/src/SqliteVec/SqliteModelBuilder.cs | 8 +------- MEVD/src/SqliteVec/SqlitePropertyMapping.cs | 2 -- MEVD/src/SqliteVec/SqliteVec.csproj | 4 ++-- MEVD/src/SqliteVec/SqliteVectorStore.cs | 8 -------- .../SqliteVec.ConformanceTests.csproj | 2 +- 7 files changed, 5 insertions(+), 30 deletions(-) diff --git a/MEVD/src/SqliteVec/SqliteFilterTranslator.cs b/MEVD/src/SqliteVec/SqliteFilterTranslator.cs index 6c7c4b1..69edf6c 100644 --- a/MEVD/src/SqliteVec/SqliteFilterTranslator.cs +++ b/MEVD/src/SqliteVec/SqliteFilterTranslator.cs @@ -173,14 +173,12 @@ private void TranslateConstant(object? value) case DateTimeOffset dateTimeOffset: _sql.Append('\'').Append(dateTimeOffset.ToString("yyyy-MM-dd HH:mm:ss.FFFFFFFzzz", System.Globalization.CultureInfo.InvariantCulture)).Append('\''); return; -#if NET case DateOnly dateOnly: _sql.Append('\'').Append(dateOnly.ToString("yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture)).Append('\''); return; case TimeOnly timeOnly: _sql.Append('\'').Append(timeOnly.ToString("HH:mm:ss.FFFFFFF", System.Globalization.CultureInfo.InvariantCulture)).Append('\''); return; -#endif case null: _sql.Append("NULL"); diff --git a/MEVD/src/SqliteVec/SqliteMapper.cs b/MEVD/src/SqliteVec/SqliteMapper.cs index 4160e50..6e8b07a 100644 --- a/MEVD/src/SqliteVec/SqliteMapper.cs +++ b/MEVD/src/SqliteVec/SqliteMapper.cs @@ -43,10 +43,8 @@ public TRecord MapFromStorageToDataModel(DbDataReader reader, bool includeVector } // SqliteVec provides the vector data as a byte[], which we need to convert to a float[]. - // In modern .NET, we allocate a float[] of the right size, reinterpret-cast it into byte[], + // We allocate a float[] of the right size, reinterpret-cast it into byte[], // and then read the data into that via Stream. - // In .NET Framework, which doesn't have Span APIs on Stream, we just create a copy (inefficient). -#if NET using var stream = reader.GetStream(ordinal); var length = stream.Length; @@ -58,9 +56,6 @@ public TRecord MapFromStorageToDataModel(DbDataReader reader, bool includeVector var floats = new float[length / 4]; var bytes = MemoryMarshal.Cast(floats.AsSpan()); stream.ReadExactly(bytes); -#else - var floats = MemoryMarshal.Cast((byte[])reader[ordinal]).ToArray(); -#endif property.SetValueAsObject( record, @@ -99,10 +94,8 @@ public TRecord MapFromStorageToDataModel(DbDataReader reader, bool includeVector Type t when t == typeof(Guid) => reader.GetGuid(ordinal), Type t when t == typeof(DateTime) => reader.GetDateTime(ordinal), Type t when t == typeof(DateTimeOffset) => reader.GetFieldValue(ordinal), -#if NET Type t when t == typeof(DateOnly) => reader.GetFieldValue(ordinal), Type t when t == typeof(TimeOnly) => reader.GetFieldValue(ordinal), -#endif Type t when t == typeof(byte[]) => (byte[])reader[ordinal], Type t when t == typeof(ReadOnlyMemory) => (byte[])reader[ordinal], Type t when t == typeof(Embedding) => (byte[])reader[ordinal], diff --git a/MEVD/src/SqliteVec/SqliteModelBuilder.cs b/MEVD/src/SqliteVec/SqliteModelBuilder.cs index 2bb0732..cc68ee6 100644 --- a/MEVD/src/SqliteVec/SqliteModelBuilder.cs +++ b/MEVD/src/SqliteVec/SqliteModelBuilder.cs @@ -34,11 +34,7 @@ protected override void ValidateKeyProperty(KeyPropertyModel keyProperty) protected override bool IsDataPropertyTypeValid(Type type, [NotNullWhen(false)] out string? supportedTypes) { - supportedTypes = "int, long, short, string, bool, float, double, byte[], Guid, DateTime, DateTimeOffset" -#if NET - + ", DateOnly, TimeOnly" -#endif - ; + supportedTypes = "int, long, short, string, bool, float, double, byte[], Guid, DateTime, DateTimeOffset, DateOnly, TimeOnly"; if (Nullable.GetUnderlyingType(type) is Type underlyingType) { @@ -56,10 +52,8 @@ protected override bool IsDataPropertyTypeValid(Type type, [NotNullWhen(false)] || type == typeof(Guid) || type == typeof(DateTime) || type == typeof(DateTimeOffset) -#if NET || type == typeof(DateOnly) || type == typeof(TimeOnly) -#endif ; } diff --git a/MEVD/src/SqliteVec/SqlitePropertyMapping.cs b/MEVD/src/SqliteVec/SqlitePropertyMapping.cs index 41782d0..778eb40 100644 --- a/MEVD/src/SqliteVec/SqlitePropertyMapping.cs +++ b/MEVD/src/SqliteVec/SqlitePropertyMapping.cs @@ -116,10 +116,8 @@ private static string GetStorageDataPropertyType(PropertyModel property) // Date/time types - represent as TEXT (ISO 8601) Type t when t == typeof(DateTime) || t == typeof(DateTime?) => "TEXT", Type t when t == typeof(DateTimeOffset) || t == typeof(DateTimeOffset?) => "TEXT", -#if NET Type t when t == typeof(DateOnly) || t == typeof(DateOnly?) => "TEXT", Type t when t == typeof(TimeOnly) || t == typeof(TimeOnly?) => "TEXT", -#endif // Byte array (BLOB) Type t when t == typeof(byte[]) => "BLOB", diff --git a/MEVD/src/SqliteVec/SqliteVec.csproj b/MEVD/src/SqliteVec/SqliteVec.csproj index 40a10b1..fa7643b 100644 --- a/MEVD/src/SqliteVec/SqliteVec.csproj +++ b/MEVD/src/SqliteVec/SqliteVec.csproj @@ -1,10 +1,10 @@  - 1.0.2-preview + 1.0.3-preview CommunityToolkit.VectorData.SqliteVec $(AssemblyName) - net10.0;net8.0;netstandard2.0;net462 + net10.0;net8.0 true SQLite provider for Microsoft.Extensions.VectorData diff --git a/MEVD/src/SqliteVec/SqliteVectorStore.cs b/MEVD/src/SqliteVec/SqliteVectorStore.cs index 5e149f7..0c42ed5 100644 --- a/MEVD/src/SqliteVec/SqliteVectorStore.cs +++ b/MEVD/src/SqliteVec/SqliteVectorStore.cs @@ -61,11 +61,7 @@ public SqliteVectorStore(string connectionString, SqliteVectorStoreOptions? opti /// [RequiresDynamicCode("This overload of GetCollection() is incompatible with NativeAOT. For dynamic mapping via Dictionary, call GetDynamicCollection() instead.")] [RequiresUnreferencedCode("This overload of GetCollecttion() is incompatible with trimming. For dynamic mapping via Dictionary, call GetDynamicCollection() instead.")] -#if NET public override SqliteCollection GetCollection(string name, VectorStoreCollectionDefinition? definition = null) -#else - public override VectorStoreCollection GetCollection(string name, VectorStoreCollectionDefinition? definition = null) -#endif => typeof(TRecord) == typeof(Dictionary) ? throw new ArgumentException(VectorDataStrings.GetCollectionWithDictionaryNotSupported) : new SqliteCollection( @@ -79,11 +75,7 @@ public override VectorStoreCollection GetCollection -#if NET public override SqliteDynamicCollection GetDynamicCollection(string name, VectorStoreCollectionDefinition definition) -#else - public override VectorStoreCollection> GetDynamicCollection(string name, VectorStoreCollectionDefinition definition) -#endif => new SqliteDynamicCollection( _connectionString, name, diff --git a/MEVD/test/SqliteVec.ConformanceTests/SqliteVec.ConformanceTests.csproj b/MEVD/test/SqliteVec.ConformanceTests/SqliteVec.ConformanceTests.csproj index 81a4b8b..8741798 100644 --- a/MEVD/test/SqliteVec.ConformanceTests/SqliteVec.ConformanceTests.csproj +++ b/MEVD/test/SqliteVec.ConformanceTests/SqliteVec.ConformanceTests.csproj @@ -1,7 +1,7 @@  - net10.0;$(NetFrameworkTfm) + net10.0 enable enable true