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
17 changes: 16 additions & 1 deletion src/Pingmint.CodeGen.Sql/Analyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,8 @@ private async Task<List<GetTableTypeColumnsRow>> GetTableTypeColumnsAsync(SqlCon
"xml" => SqlDbType.Xml,
"uniqueidentifier" => SqlDbType.UniqueIdentifier,
"image" => SqlDbType.Image,
"vector" => SqlDbType.Vector,
"json" => SqlDbType.Json,

_ => (SqlDbType?)null,
} is not { } value)
Expand Down Expand Up @@ -502,7 +504,8 @@ SqlDbType.NText or
SqlDbType.NVarChar or
SqlDbType.Text or
SqlDbType.VarChar or
SqlDbType.Xml
SqlDbType.Xml or
SqlDbType.Json
=> typeof(String),

SqlDbType.DateTimeOffset => typeof(DateTimeOffset),
Expand Down Expand Up @@ -559,6 +562,18 @@ private async Task<CSharpTypeInfo> GetCSharpTypeInfoAsync(SqlConnection server,
throw new InvalidOperationException("Could not find sys.types row for " + systemTypeId + ", " + userTypeId);
}

if (foundSysType.Name == "vector")
{
_csharpTypeInfosById[(systemTypeId, userTypeId)] = cachedValue = new()
{
TypeRef = "SqlVector<float>",
TypeRefNullable = "SqlVector<float>?",
IsValueType = true,
SqlDbType = SqlDbType.Vector,
};
return cachedValue;
}

if (!foundSysType.IsUserDefined)
{
if (await GetSqlDbTypeAsync(server, systemTypeId, userTypeId) is { } sqlDbType)
Expand Down
1 change: 1 addition & 0 deletions src/Pingmint.CodeGen.Sql/CodeFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public String GenerateCode()
code.UsingNamespace("System.Threading");
code.UsingNamespace("System.Threading.Tasks");
code.UsingNamespace("Microsoft.Data.SqlClient");
code.UsingNamespace("Microsoft.Data.SqlTypes");
code.Line($"using static {Namespace}.FileMethods;");
code.Line();

Expand Down
2 changes: 1 addition & 1 deletion src/Pingmint.CodeGen.Sql/Pingmint.CodeGen.Sql.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>0.48</Version>
<Version>0.49</Version>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<LangVersion>latest</LangVersion>
Expand Down
Loading