Commit d095e83
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>1 parent ac79dd6 commit d095e83
1 file changed
Lines changed: 5 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
295 | 295 | | |
296 | 296 | | |
297 | 297 | | |
298 | | - | |
| 298 | + | |
299 | 299 | | |
300 | 300 | | |
301 | | - | |
302 | | - | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
303 | 305 | | |
304 | 306 | | |
305 | 307 | | |
| |||
0 commit comments