Skip to content

Commit

Permalink
release 1.5.9
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Morozov committed Feb 12, 2015
1 parent fface4e commit ae07002
Show file tree
Hide file tree
Showing 15 changed files with 81 additions and 14 deletions.
2 changes: 2 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,5 @@
#### 1.5.8 - January 13, 2015
* Fix issue #96 on Sql Azure

#### 1.5.9 - February 11, 2015
* Dynamic sql example. Issue #108
2 changes: 1 addition & 1 deletion src/SqlClient.Samples/WebApi.Controllers/HomeController.fs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module SqlCommand =
//get connection string at run-time
let adventureWorks = WebConfigurationManager.ConnectionStrings.["AdventureWorks2012"].ConnectionString
//create command instance with connection string override
(^a : (new : string -> ^a) adventureWorks)
(^a : (new : string * int -> ^a) (adventureWorks, 30))

| _ -> failwithf "Unrecognized command type %s" typeof<'a>.FullName

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
</ItemGroup>
<ItemGroup>
<Reference Include="FSharp.Data.SqlClient">
<HintPath>..\..\..\packages\FSharp.Data.SqlClient.1.4.4\lib\net40\FSharp.Data.SqlClient.dll</HintPath>
<HintPath>..\..\..\packages\FSharp.Data.SqlClient.1.5.8\lib\net40\FSharp.Data.SqlClient.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="mscorlib" />
Expand Down
2 changes: 1 addition & 1 deletion src/SqlClient.Samples/WebApi.Controllers/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="FSharp.Data.SqlClient" version="1.4.4" targetFramework="net45" />
<package id="FSharp.Data.SqlClient" version="1.5.8" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.2" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.2" targetFramework="net45" />
<package id="Microsoft.SqlServer.Types" version="11.0.1" targetFramework="net45" />
Expand Down
4 changes: 2 additions & 2 deletions src/SqlClient.Samples/WebApi/WebApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
<Reference Include="FSharp.Core, Version=4.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>True</Private>
</Reference>
<Reference Include="FSharp.Data.SqlClient, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<Reference Include="FSharp.Data.SqlClient, Version=1.5.8.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\FSharp.Data.SqlClient.1.4.4\lib\net40\FSharp.Data.SqlClient.dll</HintPath>
<HintPath>..\..\..\packages\FSharp.Data.SqlClient.1.5.8\lib\net40\FSharp.Data.SqlClient.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down
2 changes: 1 addition & 1 deletion src/SqlClient.Samples/WebApi/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="FSharp.Data.SqlClient" version="1.4.4" targetFramework="net45" />
<package id="FSharp.Data.SqlClient" version="1.5.8" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi" version="5.2.2" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.2" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.2" targetFramework="net45" />
Expand Down
2 changes: 1 addition & 1 deletion src/SqlClient.Samples/WpfDataBinding/WpfDataBinding.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="FSharp.Data.SqlClient">
<HintPath>..\..\..\packages\FSharp.Data.SqlClient.1.4.4\lib\net40\FSharp.Data.SqlClient.dll</HintPath>
<HintPath>..\..\..\packages\FSharp.Data.SqlClient.1.5.8\lib\net40\FSharp.Data.SqlClient.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="mscorlib" />
Expand Down
2 changes: 1 addition & 1 deletion src/SqlClient.Samples/WpfDataBinding/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="FSharp.Data.SqlClient" version="1.4.4" targetFramework="net45" />
<package id="FSharp.Data.SqlClient" version="1.5.8" targetFramework="net45" />
<package id="Microsoft.SqlServer.Types" version="11.0.1" targetFramework="net40-Client" />
</packages>
2 changes: 2 additions & 0 deletions src/SqlClient.Tests/ConfigurationTest.fs
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ let RuntimeConfig () =
|> should equal ConfigurationManager.ConnectionStrings.[name].ConnectionString

type Get42RelativePath = SqlCommandProvider<"sampleCommand.sql", "name=AdventureWorks2012", ResolutionFolder="MySqlFolder">

type Get42 = SqlCommandProvider<"SELECT 42", "name=AdventureWorks2012", ConfigFile = "appWithInclude.config">
4 changes: 3 additions & 1 deletion src/SqlClient.Tests/SqlClient.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,16 @@
<Compile Include="SqlEnumTests.fs" />
<Compile Include="DataTablesTests.fs" />
<None Include="Schema.fsx" />
<None Include="app.config" />
<Content Include="connectionStrings.config" />
<Content Include="appWithInclude.config" />
<None Include="SqlCommand.fsx" />
<None Include="SqlProgrammability.fsx" />
<None Include="sampleCommand.sql" />
<None Include="prereqs.sql" />
<None Include="packages.config" />
<None Include="Performance.fsx" />
<None Include="Ado.fsx" />
<None Include="app.config" />
</ItemGroup>
<ItemGroup>
<Reference Include="FSharp.Configuration">
Expand Down
25 changes: 25 additions & 0 deletions src/SqlClient.Tests/TypeProviderTest.fs
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,28 @@ let CommandTimeout() =
use cmd = new LongRunning(commandTimeout = 60)
Assert.Equal(60, cmd.CommandTimeout)
Assert.Equal(Some 42, cmd.Execute())

type DynamicCommand = SqlCommandProvider<"
DECLARE @stmt AS NVARCHAR(MAX) = @tsql
DECLARE @params AS NVARCHAR(MAX) = N'@p1 nvarchar(100)'
DECLARE @p1 AS NVARCHAR(100) = @firstName
EXECUTE sp_executesql @stmt, @params, @p1
WITH RESULT SETS
(
(
Name NVARCHAR(100)
,UUID UNIQUEIDENTIFIER
)
)
", connection>

[<Fact>]
let DynamicSql() =
let cmd = new DynamicCommand()
//provide dynamic sql query with param
cmd.Execute("SELECT CONCAT(FirstName, LastName) AS Name, rowguid AS UUID FROM Person.Person WHERE FirstName = @p1", "Alex") |> Seq.toArray |> Array.length |> should equal 51
//extend where condition by filetering out additional rows
cmd.Execute("SELECT CONCAT(FirstName, LastName) AS Name, rowguid AS UUID FROM Person.Person WHERE FirstName = @p1 AND EmailPromotion = 2", "Alex") |> Seq.toArray |> Array.length |> should equal 9
//accessing completely diff table
cmd.Execute("SELECT Name, rowguid AS UUID FROM Production.Product WHERE Name = @p1", "Chainring Nut") |> Seq.toArray |> Array.length |> should equal 1

26 changes: 26 additions & 0 deletions src/SqlClient.Tests/appWithInclude.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.3.1.0" newVersion="4.3.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.SqlServer.Types" publicKeyToken="89845dcd8080cc91" culture="neutral" />
<bindingRedirect oldVersion="10.0.0.0-12.0.0.0" newVersion="11.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<connectionStrings configSource="connectionStrings.config"/>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
</startup>

<system.diagnostics>
<switches>
<add name="DataMessagesSwitch" value="0" />
</switches>
</system.diagnostics>

</configuration>
4 changes: 4 additions & 0 deletions src/SqlClient.Tests/connectionStrings.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<connectionStrings>
<add name="AdventureWorks2012" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=AdventureWorks2012;Integrated Security=True" />
<add name="MasterDb" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=master;Integrated Security=True" />
</connectionStrings>
6 changes: 3 additions & 3 deletions src/SqlClient/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ open System.Reflection
[<assembly: AssemblyTitleAttribute("SqlClient")>]
[<assembly: AssemblyProductAttribute("FSharp.Data.SqlClient")>]
[<assembly: AssemblyDescriptionAttribute("SqlClient F# type providers")>]
[<assembly: AssemblyVersionAttribute("1.5.8")>]
[<assembly: AssemblyFileVersionAttribute("1.5.8")>]
[<assembly: AssemblyVersionAttribute("1.5.9")>]
[<assembly: AssemblyFileVersionAttribute("1.5.9")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] Version = "1.5.8"
let [<Literal>] Version = "1.5.9"
10 changes: 8 additions & 2 deletions src/SqlClient/SqlClientExtensions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ module SqlDataReader =
let internal getOption<'a> (key: string) (reader: SqlDataReader) =
let v = reader.[key]
if Convert.IsDBNull v then None else Some(unbox<'a> v)

let internal getValueOrDefault<'a> (key: string) defaultValue (reader: SqlDataReader) =
let v = reader.[key]
if Convert.IsDBNull v then defaultValue else unbox<'a> v


let DbNull = box DBNull.Value

Expand Down Expand Up @@ -259,14 +264,15 @@ type SqlConnection with
while reader.Read() do
let user_type_id = reader |> SqlDataReader.getOption<int> "user_type_id"
let system_type_id = reader.["system_type_id"] |> unbox<int>

let x = {
Column.Name = string reader.["name"]
Ordinal = unbox reader.["column_ordinal"]
TypeInfo = findTypeInfoBySqlEngineTypeId (this.ConnectionString, system_type_id, user_type_id)
IsNullable = unbox reader.["is_nullable"]
MaxLength = reader.["max_length"] |> unbox<int16> |> int
ReadOnly = not(unbox reader.["is_updateable"])
Identity = unbox reader.["is_identity_column"]
ReadOnly = not( SqlDataReader.getValueOrDefault "is_updateable" true reader)
Identity = SqlDataReader.getValueOrDefault "is_identity_column" false reader
}
yield x
]
Expand Down

0 comments on commit ae07002

Please sign in to comment.