FSharp.Data.SqlClient
FSharp.Data.SqlClient copied to clipboard
Option not inferred for optional sproc parameters of type binary and nvarchar
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:

Note however that the type signature seems correct:

@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.
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. :)