You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Option not inferred for optional sproc parameters of type binary and nvarchar #377
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. :)
Only parameters whose CLR type is a value type (int, float, DateTime, etc.) get wrapped as T option when they have a NULL default. Reference types like string (nvarchar) and byte[] (binary/varbinary) are excluded because null is already a valid F# value for those types — so you can pass null today as the workaround.
Making this consistent (wrapping all nullable-defaulted params as option) would be a breaking API change: existing code passing null for string/byte[] parameters would need to be updated to None. Because of this, a fix would need to be opt-in (e.g., a UniformOptionalParameters static parameter on the type provider) or version-gated.
The immediate workaround is indeed to pass null for nvarchar/binary optional parameters, as @smoothdeveloper noted. For example:
myCommand.Execute(param1 = Some 42, param2 =null, param3 =null)
Activity
smoothdeveloper commentedon Mar 30, 2020
@cmeeren this is tied to this:
FSharp.Data.SqlClient/src/SqlClient.DesignTime/SqlClientExtensions.fs
Line 310 in c8148eb
Only value type are option wrapped, which I think makes sense.
You may pass
nullto work around your issue.cmeeren commentedon Mar 30, 2020
I see, I didn't notice that. Then at least I can use my sprocs :)
IMHO a uniform
optioninterface 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 usingoptionfor these arguments anyway, so this would save having to useOption.toObj. Feel free to close this issue if you don't agree. :)github-actions commentedon Mar 10, 2026
🤖 This is an automated response from Repo Assist.
Thanks for the detailed report. The root cause is in
SqlClientExtensions.fsline 375:Only parameters whose CLR type is a value type (
int,float,DateTime, etc.) get wrapped asT optionwhen they have aNULLdefault. Reference types likestring(nvarchar) andbyte[](binary/varbinary) are excluded becausenullis already a valid F# value for those types — so you can passnulltoday as the workaround.Making this consistent (wrapping all nullable-defaulted params as
option) would be a breaking API change: existing code passingnullforstring/byte[]parameters would need to be updated toNone. Because of this, a fix would need to be opt-in (e.g., aUniformOptionalParametersstatic parameter on the type provider) or version-gated.The immediate workaround is indeed to pass
nullfornvarchar/binaryoptional parameters, as@smoothdevelopernoted. For example:Warning
The following domain was blocked by the firewall during workflow execution:
fsprojects.github.ioTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.