From ae194e3bf9c27954efb8280731e49c3c9ff525fc Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 13 Mar 2026 07:22:03 +0000 Subject: [PATCH 1/2] fix: correct SqlMetaData constructor selection for datetime2/datetimeoffset/time TVP columns The previous fix for #393 used `match name, dbType with` where `name` is the column name (e.g. "CreatedAt"), not the SQL type name. This meant the pattern | "datetime2", SqlDbType.DateTime2 -> ... would never fire unless the column happened to be literally named "datetime2". The correct fix is to match on `dbType` alone, which always contains the actual SQL type. This ensures that all DateTime2, DateTimeOffset and Time TVP columns use SqlMetaData(name, dbType, 0uy, scale) rather than SqlMetaData(name, dbType, precision, scale), avoiding the ArgumentException "Metadata for field 'X' did not match the original record's metadata" when the precision byte doesn't equal what SQL Server expects. Closes #393 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/SqlClient.DesignTime/DesignTime.fs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/SqlClient.DesignTime/DesignTime.fs b/src/SqlClient.DesignTime/DesignTime.fs index ac5c6a07..735d6edc 100644 --- a/src/SqlClient.DesignTime/DesignTime.fs +++ b/src/SqlClient.DesignTime/DesignTime.fs @@ -542,11 +542,15 @@ type DesignTime private() = let precision = byte p.Precision let scale = byte p.Scale if typeInfo.IsFixedLength then - match name, dbType with - | "datetime2" , SqlDbType.DateTime2 - | "datetimeoffset", SqlDbType.DateTimeOffset - | "time" , SqlDbType.Time -> + match dbType with + | SqlDbType.DateTime2 + | SqlDbType.DateTimeOffset + | SqlDbType.Time -> // https://github.com/fsprojects/FSharp.Data.SqlClient/issues/393 + // These types use (name, dbType, precision, scale) but precision must be 0, + // not the value from sys.columns (which is 10 for datetimeoffset etc.). + // The previous match on `name` was incorrect — it compared the column name + // (e.g. "CreatedAt") to the type name, so the fix never fired. <@@ SqlMetaData(name, dbType, 0uy, scale) @@> | _ -> // https://github.com/fsprojects/FSharp.Data.SqlClient/issues/345 From c69b139a35dba865cb22e7ca04672688cc94e943 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 13 Mar 2026 07:30:29 +0000 Subject: [PATCH 2/2] ci: trigger checks