-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated support for Npgsql 8 and Npgsql.EntityFrameworkCore.PostgreSQL 8
- Loading branch information
Showing
8 changed files
with
51 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"sdk": { | ||
"version": "8.0.100-rc.2.23502.2", | ||
"version": "8.0.100", | ||
"rollForward": "latestMajor", | ||
"allowPrerelease": "true" | ||
"allowPrerelease": "false" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System; | ||
using Npgsql.Internal; | ||
using Npgsql.Internal.Postgres; | ||
|
||
namespace Pgvector.Npgsql; | ||
|
||
public class VectorTypeInfoResolverFactory : PgTypeInfoResolverFactory | ||
{ | ||
public override IPgTypeInfoResolver CreateResolver() => new Resolver(); | ||
public override IPgTypeInfoResolver CreateArrayResolver() => new ArrayResolver(); | ||
|
||
class Resolver : IPgTypeInfoResolver | ||
{ | ||
TypeInfoMappingCollection? _mappings; | ||
protected TypeInfoMappingCollection Mappings => _mappings ??= AddMappings(new()); | ||
|
||
public PgTypeInfo? GetTypeInfo(Type? type, DataTypeName? dataTypeName, PgSerializerOptions options) | ||
=> Mappings.Find(type, dataTypeName, options); | ||
|
||
static TypeInfoMappingCollection AddMappings(TypeInfoMappingCollection mappings) | ||
{ | ||
mappings.AddType<Vector>("vector", | ||
static (options, mapping, _) => mapping.CreateInfo(options, new VectorConverter()), isDefault: true); | ||
return mappings; | ||
} | ||
} | ||
|
||
sealed class ArrayResolver : Resolver, IPgTypeInfoResolver | ||
{ | ||
TypeInfoMappingCollection? _mappings; | ||
new TypeInfoMappingCollection Mappings => _mappings ??= AddMappings(new(base.Mappings)); | ||
|
||
public new PgTypeInfo? GetTypeInfo(Type? type, DataTypeName? dataTypeName, PgSerializerOptions options) | ||
=> Mappings.Find(type, dataTypeName, options); | ||
|
||
static TypeInfoMappingCollection AddMappings(TypeInfoMappingCollection mappings) | ||
{ | ||
mappings.AddArrayType<Vector>("vector"); | ||
return mappings; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters