Skip to content

Commit

Permalink
Merge pull request #421 from suou-ryuu/issue-420
Browse files Browse the repository at this point in the history
Issue 420: restored TVP column ordering to, expected, column_id
  • Loading branch information
smoothdeveloper authored May 8, 2022
2 parents 66c3613 + 995a318 commit 712b8cb
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 11 deletions.
11 changes: 11 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
#### 2.1.2 May 08, 2022

* Issue #420 fix "TVP Column Ordering is incorrect as of version 2.1.0"
* Contributor: Suou Ryuu (https://github.com/suou-ryuu)

#### 2.1.1-beta0 April 07, 2022

* Issue #413 fix "Fixed length binary columns in user defined table types fail when constructed"
* Breaking change: removal of net40 support
* Contributor: Suou Ryuu (https://github.com/suou-ryuu)

#### 2.1.0-beta1 December 17, 2020

* fix reading from app.config vs App.config on case sensitive file system
Expand Down
8 changes: 4 additions & 4 deletions src/SqlClient.DesignTime/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ open System.Runtime.CompilerServices
[<assembly: AssemblyTitleAttribute("SqlClient.DesignTime")>]
[<assembly: AssemblyProductAttribute("FSharp.Data.SqlClient.DesignTime")>]
[<assembly: AssemblyDescriptionAttribute("SqlClient F# type providers")>]
[<assembly: AssemblyVersionAttribute("2.0.5")>]
[<assembly: AssemblyFileVersionAttribute("2.0.5")>]
[<assembly: AssemblyVersionAttribute("2.1.2")>]
[<assembly: AssemblyFileVersionAttribute("2.1.2")>]
[<assembly: InternalsVisibleToAttribute("SqlClient.Tests")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] AssemblyTitle = "SqlClient.DesignTime"
let [<Literal>] AssemblyProduct = "FSharp.Data.SqlClient.DesignTime"
let [<Literal>] AssemblyDescription = "SqlClient F# type providers"
let [<Literal>] AssemblyVersion = "2.0.5"
let [<Literal>] AssemblyFileVersion = "2.0.5"
let [<Literal>] AssemblyVersion = "2.1.2"
let [<Literal>] AssemblyFileVersion = "2.1.2"
let [<Literal>] InternalsVisibleTo = "SqlClient.Tests"
6 changes: 3 additions & 3 deletions src/SqlClient.DesignTime/SqlClientExtensions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -526,10 +526,10 @@ select
c.name, c.system_type_id, c.user_type_id, c.is_nullable, c.max_length, c.is_identity, c.is_computed, tt.user_type_id table_type_user_type_id, c.[precision], c.scale
from sys.table_types as tt
inner join sys.columns as c on tt.type_table_object_id = c.object_id
order by
tt.user_type_id
order by
c.column_id
, tt.user_type_id
, c.user_type_id
, c.column_id
"""
, this)
use reader = cmd.ExecuteReader()
Expand Down
8 changes: 4 additions & 4 deletions src/SqlClient/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ open System.Runtime.CompilerServices
[<assembly: AssemblyTitleAttribute("SqlClient")>]
[<assembly: AssemblyProductAttribute("FSharp.Data.SqlClient")>]
[<assembly: AssemblyDescriptionAttribute("SqlClient F# type providers")>]
[<assembly: AssemblyVersionAttribute("2.0.5")>]
[<assembly: AssemblyFileVersionAttribute("2.0.5")>]
[<assembly: AssemblyVersionAttribute("2.1.2")>]
[<assembly: AssemblyFileVersionAttribute("2.1.2")>]
[<assembly: InternalsVisibleToAttribute("SqlClient.Tests")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] AssemblyTitle = "SqlClient"
let [<Literal>] AssemblyProduct = "FSharp.Data.SqlClient"
let [<Literal>] AssemblyDescription = "SqlClient F# type providers"
let [<Literal>] AssemblyVersion = "2.0.5"
let [<Literal>] AssemblyFileVersion = "2.0.5"
let [<Literal>] AssemblyVersion = "2.1.2"
let [<Literal>] AssemblyFileVersion = "2.1.2"
let [<Literal>] InternalsVisibleTo = "SqlClient.Tests"
16 changes: 16 additions & 0 deletions tests/SqlClient.Tests/TVPTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -222,4 +222,20 @@ let ``Using Fixed Length Binary TVP``() =
]
|> Seq.map (fun d -> FixedLengthBinaryTVP.FixedLengthBinaryTVPTest (Some d))
|> cmd.Execute
|> ignore


type TestTVPColumnOrder = SqlCommandProvider<"EXEC [dbo].[TestTVPColumnOrder] @tvp", ConnectionStrings.AdventureWorksLiteral>
[<Fact>]
let ``User Defined Table Types should list columns orderd by Column Id (i.e. the order in which they appear in the declared type)`` () =
use cmd = new TestTVPColumnOrder(ConnectionStrings.AdventureWorksLiteral)

[
(1, "some string", true)
(2, "some other string", false)
(3, "yet another string", true)
]
|> Seq.map (fun (i, s, b) -> TestTVPColumnOrder.TVPColumnOrder(i, s, b))
|> Seq.toList
|> cmd.Execute
|> ignore
22 changes: 22 additions & 0 deletions tests/SqlClient.Tests/extensions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ GO
IF OBJECT_ID('dbo.FixedLengthBinaryTVPTestProc') IS NOT NULL
DROP PROCEDURE [dbo].[FixedLengthBinaryTVPTestProc]
GO
IF OBJECT_ID('dbo.TestTVPColumnOrder') IS NOT NULL
DROP PROCEDURE [dbo].[TestTVPColumnOrder]
GO
IF OBJECT_ID('Sales.GetUKSalesOrders') IS NOT NULL
DROP FUNCTION Sales.GetUKSalesOrders;
GO
Expand Down Expand Up @@ -127,6 +130,10 @@ IF TYPE_ID(N'dbo.FixedLengthBinaryTVPTest') IS NOT NULL
DROP TYPE [dbo].[FixedLengthBinaryTVPTest]
GO

IF TYPE_ID(N'dbo.TVPColumnOrder') IS NOT NULL
DROP TYPE [dbo].[TVPColumnOrder]
GO


CREATE TYPE dbo.MyTableType AS TABLE (myId int not null, myName nvarchar(30) null)
GO
Expand Down Expand Up @@ -154,6 +161,13 @@ CREATE TYPE [dbo].[FixedLengthBinaryTVPTest] AS TABLE (
)
GO

CREATE TYPE [dbo].[TVPColumnOrder] AS TABLE(
[Param1] INT NOT NULL,
[Param2] NVARCHAR(100) NOT NULL,
[Param3] BIT NOT NULL
)
GO

--TABLES

CREATE TABLE dbo.TableHavingColumnNamesWithSpaces (
Expand Down Expand Up @@ -269,6 +283,14 @@ BEGIN
END
GO

CREATE PROCEDURE [dbo].[TestTVPColumnOrder](
@tvpColumnOrder [dbo].[TVPColumnOrder] READONLY
)
AS
SELECT *
FROM @tvpColumnOrder
GO


CREATE FUNCTION dbo.ufnGetStock2(@ProductID [int] = NULL)
RETURNS [int]
Expand Down

0 comments on commit 712b8cb

Please sign in to comment.