diff --git a/tests/SqlClient.Tests/TVPTests.fs b/tests/SqlClient.Tests/TVPTests.fs index 4bae1bf0..7d2b86f8 100644 --- a/tests/SqlClient.Tests/TVPTests.fs +++ b/tests/SqlClient.Tests/TVPTests.fs @@ -4,7 +4,7 @@ open FSharp.Data.SqlClient #else module FSharp.Data.SqlClient.TVPTests #endif - +open System open FSharp.Data open Xunit @@ -238,4 +238,62 @@ let ``User Defined Table Types should list columns orderd by Column Id (i.e. the |> Seq.map (fun (i, s, b) -> TestTVPColumnOrder.TVPColumnOrder(i, s, b)) |> Seq.toList |> cmd.Execute - |> ignore \ No newline at end of file + |> ignore + + +type AddSqlCommandIssue424 = SqlCommandProvider<" +insert [testtable_424] +( + c1, + c2, + c11, + c4, + c3, + c5, + c6, + c7, + c8, + c9, + c10 +) +select + @c1, + @c2, + @c11, + @c4, + x.c3, + x.c5, + x.c6, + x.c7, + x.c8, + x.c9, + x.c10 +from @c12 x; +" , ConnectionStrings.AdventureWorksLiteral, TableVarMapping = "@c12=testtable_424_item"> + +[] +let ``Issue #424 conversion failed when using UDTT`` () = + use cmd = new AddSqlCommandIssue424(ConnectionStrings.AdventureWorksLiteral) + + let items = + [ + AddSqlCommandIssue424.testtable_424_item( + c3 = Guid.NewGuid(), + c5 = "TestName", + c6 = Some "C6", + c7 = "C7", + c8 = 1, + c9 = "C9", + c10 = Guid.NewGuid() + ) + ] + + let r = + cmd.Execute( + c1 = Guid.NewGuid(), + c2 = Guid.NewGuid(), + c4 = "C4 Name", + c11 = Guid.NewGuid(), + c12 = items + ) + () \ No newline at end of file diff --git a/tests/SqlClient.Tests/extensions.sql b/tests/SqlClient.Tests/extensions.sql index 33a709ad..b315a7f4 100644 --- a/tests/SqlClient.Tests/extensions.sql +++ b/tests/SqlClient.Tests/extensions.sql @@ -439,3 +439,42 @@ begin select created_at from @tvp end go + + +-- issue #424 +if object_id('dbo.testtable_424') is not null + drop table dbo.testtable_424 +go + +create table testtable_424 ( + c1 uniqueidentifier not null, + c2 uniqueidentifier not null, + c3 uniqueidentifier not null, + + c4 nvarchar(100) not null, + c5 nvarchar(100) not null, + c6 nvarchar(100) null, + c7 nvarchar(1000) not null, + + c8 int not null, + + c9 varchar(10) not null, + c10 uniqueidentifier not null, + c11 uniqueidentifier not null, + + constraint pk_id_testtable_424 primary key clustered(c1, c2, c3) +); + +if type_id('dbo.testtable_424_item') is not null + drop type dbo.testtable_424_item +go + +create type dbo.testtable_424_item as table( + c3 uniqueidentifier not null, + c5 nvarchar(100) not null, + c6 nvarchar(100) null, + c7 nvarchar(1000) not null, + c8 int not null, + c9 varchar(10) not null, + c10 uniqueidentifier not null +);