fsprojects / fsprojects/FSharp.Data.SqlClient

SqlProgrammability provider fails to update/bulk copy into tables with computed persistent columns

Open
#272 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
F#
Stars
206
Forks
66
PR merge metrics
No merged PRs in 30d

Description

Description

SqlProgrammability provider fails to update/bulk copy into tables with computed persistent columns - you get exception when you call update method:
System.Data.NoNullAllowedException: Column '{persistentColumn}' does not allow nulls.

Repro steps

Please provide the steps required to reproduce the problem

  1. Create table:
CREATE TABLE [dbo].[T1](
	[A] [int] NOT NULL,
	B  AS ((0)) PERSISTED NOT NULL
)
  1. Step B

type Database = SqlProgrammabilityProvider<"name=someConnectionString">
let t = new Database.dbo.Tables.T1()
t.AddRow(3)
t.Update() 
Expected behavior

New row is inserted into the table.

Actual behavior

System.Data.NoNullAllowedException: Column 'B' does not allow nulls.

Known workarounds

Following code can be used - works for update only:

    let t = new Database.dbo.Tables.T1()
    let r = t.NewRow(3)
    r.["B"] <- 0
    t.Rows.Add(r)
    t.Update()
Related information

.Net Standard 4.6.2
SqlServer 2016
SqlClient 1.8.1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the SqlProgrammability provider's generated table and row update paths, using the supplied T1 schema and AddRow/Update reproduction. Compare the update and bulk-copy flows, then verify that inserts into tables with computed persistent columns complete without a NoNullAllowedException.

Written by the indexing model from the issue text.

Assessment

Tech stack
fsharp, sql
Domain
database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.