fsprojects / fsprojects/FSharp.Data.SqlClient
Fixed length binary columns in user defined table types fail when constructed
Nobody has claimed this yet.
- Dominant language
- F#
- Stars
- 206
- Forks
- 66
- PR merge metrics
- No merged PRs in 30d
Description
Issue Summary
When using a user defined table type with a fixed length binary column the wrong constructor for SqlMetaData is used resulting in the following exception.
System.ArgumentException: 'The dbType Binary is invalid for this constructor.'
This line looks like it's causing the issue, which incorrectly assumes if it is a fixed length that it can safely use the two parameter constructor:
To Reproduce
- Create a custom table type
CREATE TYPE [dbo].[CustomTableType] AS TABLE(
[Value] [binary](16)
)
- Use the type in a query
type StaticProvider =
SqlCommandProvider<"
Declare @Updates as CustomTableType = @Inputs;
" , staticConnectionString>
use cmd = new StaticProvider(context.connection, transaction = context.transaction)
cmd.AsyncExecute(
data.inputs
|> List.map(fun x ->
StaticProvider.CustomTableType( // <--- Error in constructor
Value = x.value
)
)
Error
System.ArgumentException: 'The dbType Binary is invalid for this constructor.'
Expected behavior
There should not be an error in this case.
What you can do
- I am willing to contribute a PR with a unit test showcasing the issue
- I am willing to test the bug fix before next release
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading src/SqlClient.DesignTime/DesignTime.fs around line 544 and reproduce the supplied custom table type using a binary(16) column. Add a regression unit test for constructing the generated table-type value, then verify that it completes without the reported SqlMetaData constructor exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- fsharp, sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100