fsprojects / fsprojects/FSharp.Data.SqlClient

SqlProgrammabilityProvider generates wrong `Execute` method if SP has default to null output parameter

Open
#246 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

create procedure sh.SGet
	@STable  dbo.SmallIntTable readonly,
	@ToDate       datetime = null output,
	@no_resultset bit      = 0
as
begin
	set transaction isolation level read uncommitted

	if @no_resultset = 1
		select top 1 @ToDate = s.ToDate
		from dbo.xxx s
			join @STable t
			on t.[value] = s.ID
	else
		select 
  		  s.ID
		, s.ID1
		, s.[Address]
		, s.UpdatePeriod
		, ... 
		from dbo.S s
			join @STable t
			on t.[value] = s.ID
end
use cmd = DB.sh.SGet (connStr, TimeSpan.FromMinutes 1.)
let idTable = ids |> Seq.map WL.dbo.``User-Defined Table Types``.SmallIntTable
let records = cmd.Execute (idTable)

Several issues here:

  1. ExecuteAsync is not generated at all
  2. It does not compile:

Error The type provider 'FSharp.Data.SqlProgrammabilityProvider' reported an error in the context of provided type 'FSharp.Data.SqlProgrammabilityProvider,ConnectionStringOrName="Data Source=test_server; Initial Catalog=TEST; Integrated Security=True"+sh+SGet', member 'Execute'. The error: Type mismatch when building 'args': invalid parameter for a method or indexer property. Expected 'System.DateTime&', but received type 'Microsoft.FSharp.Core.FSharpOption`1[System.DateTime]'.
Parameter name: receivedType

Execute has the following signature:
image

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

Reproduce the issue with the shown SQL procedure and F# call through SqlProgrammabilityProvider. Inspect how the provider generates Execute and ExecuteAsync for the nullable output parameter. Done means Execute accepts the generated argument types, compiles, and ExecuteAsync is generated for this procedure.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.