From d095e83d30c2ddcf2d87c96fd139df792d1b8c8c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 12 Mar 2026 19:21:34 +0000 Subject: [PATCH 1/4] fix: only exclude nullable columns from DataTable PK when they have a default Fixes a bug where non-nullable columns with DEFAULT constraints were incorrectly removed from the DataTable PrimaryKey. This caused ConstraintException when inserting rows that differ only in the column that was wrongly excluded from the PK. Root cause: the original condition checked only for the presence of a DEFAULT constraint, but the comment described the intent as preventing null PK values. For non-nullable columns, callers must always supply the value, so including them in the PK is correct. Fix: add the c.Nullable guard so that only nullable+default columns are removed from the PK. Non-nullable columns with defaults retain PartOfUniqueKey = true, so the generated DataTable constraint correctly enforces uniqueness across all PK columns. Closes #376 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/SqlClient.DesignTime/SqlClientProvider.fs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/SqlClient.DesignTime/SqlClientProvider.fs b/src/SqlClient.DesignTime/SqlClientProvider.fs index 50044859..fdd1a8f8 100644 --- a/src/SqlClient.DesignTime/SqlClientProvider.fs +++ b/src/SqlClient.DesignTime/SqlClientProvider.fs @@ -295,11 +295,13 @@ type SqlProgrammabilityProvider(config : TypeProviderConfig) as this = ?defaultValue = x.TryGetValue("default_constraint"), ?description = x.TryGetValue("description") ) - if c.DefaultConstraint <> "" && c.PartOfUniqueKey + if c.DefaultConstraint <> "" && c.Nullable && c.PartOfUniqueKey then { c with PartOfUniqueKey = false } - //ADO.NET doesn't allow nullable columns as part of primary key - //remove from PK if default value provided by DB on insert. + //ADO.NET doesn't allow null values in primary key columns. + //Only remove nullable columns from PK when they have a default value, + //since nullable+default columns may be omitted in NewRow() and remain null. + //Non-nullable columns with defaults should stay in PK - callers must supply them. else c ) |> Seq.toList From d1711d9e22266a43a01287140c627c0a3358690f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 12 Mar 2026 19:27:48 +0000 Subject: [PATCH 2/4] ci: trigger checks From ed2876b2b893d61730fb79dc4f76d04df67d68ea Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 13 Mar 2026 07:17:39 +0000 Subject: [PATCH 3/4] ci: update build script target framework from net6.0 to net8.0 The GitHub Actions Windows runner no longer ships .NET 6 (only 8, 9, 10). This change mirrors PR #461 to allow CI to at least reach the build stage. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- build/build.fsproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/build.fsproj b/build/build.fsproj index 3686fb1a..5b2f053e 100644 --- a/build/build.fsproj +++ b/build/build.fsproj @@ -2,7 +2,7 @@ Exe - net6.0 + net8.0 From a526a97125e2aeb0528034a426869b5a3040b1a5 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 13 Mar 2026 07:30:26 +0000 Subject: [PATCH 4/4] ci: trigger checks