Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 60 additions & 2 deletions tests/SqlClient.Tests/TVPTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ open FSharp.Data.SqlClient
#else
module FSharp.Data.SqlClient.TVPTests
#endif

open System
open FSharp.Data
open Xunit

Expand Down Expand Up @@ -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
|> 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">

[<Fact>]
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
)
()
39 changes: 39 additions & 0 deletions tests/SqlClient.Tests/extensions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
);