FSharp.Data.SqlClient icon indicating copy to clipboard operation
FSharp.Data.SqlClient copied to clipboard

Option not inferred for optional sproc parameters of type binary and nvarchar

Open cmeeren opened this issue 5 years ago • 2 comments

Description

SqlClient does not infer the correct optionality for all stored procedure parameters.

For example, given this sproc with three optional parameters

CREATE PROCEDURE [dbo].[Procedure1]
  @param1 int = NULL,
  @param2 nvarchar(10) = NULL,
  @param3 binary(10) = NULL
AS
  SELECT 1

only the first one is inferred to be optional:

image

Note however that the type signature seems correct:

image

cmeeren avatar Mar 30 '20 17:03 cmeeren

@cmeeren this is tied to this:

https://github.com/fsprojects/FSharp.Data.SqlClient/blob/c8148ebcf6deaf38e87f4e4a34862a104d56bd62/src/SqlClient.DesignTime/SqlClientExtensions.fs#L310

Only value type are option wrapped, which I think makes sense.

You may pass null to work around your issue.

smoothdeveloper avatar Mar 30 '20 18:03 smoothdeveloper

I see, I didn't notice that. Then at least I can use my sprocs :)

IMHO a uniform option interface for all optional params would make more sense, to clearly indicate that they are, in fact, optional - and also because in F#, we're usually using option for these arguments anyway, so this would save having to use Option.toObj. Feel free to close this issue if you don't agree. :)

cmeeren avatar Mar 30 '20 18:03 cmeeren