-
Notifications
You must be signed in to change notification settings - Fork 68
Add TempTableDefinitions and TableVarMapping #278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
8a9bbff
921ca59
a85d2b8
635b365
d344274
69f6a8e
0f0112d
1962219
d60ead7
a5b454f
a749685
5ecc01a
0b90ac1
68b5fe0
9f6a4d5
622834e
73ea1fa
85e1839
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <packages> | ||
| <package id="FSharp.Core" version="4.2.3" targetFramework="net452" /> | ||
| </packages> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <packages> | ||
| <package id="FSharp.Core" version="4.0.0.1" targetFramework="net40" /> | ||
| </packages> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| <connectionStrings> | ||
| <add name="AdventureWorks" connectionString="Data Source=.;Initial Catalog=AdventureWorks2012;Integrated Security=True" /> | ||
| <add name="AdventureWorksDesignOnly" connectionString="Data Source=.;Initial Catalog=AdventureWorks2012;Integrated Security=True" /> | ||
| <add name="MasterDb" connectionString="Data Source=.;Initial Catalog=master;Integrated Security=True" /> | ||
| </connectionStrings> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,8 +51,8 @@ | |
| <OtherFlags>--warnon:1182</OtherFlags> | ||
| </PropertyGroup> | ||
| <ItemGroup> | ||
| <Reference Include="FSharp.Core, Version=$(TargetFSharpCoreVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> | ||
| <Private>True</Private> | ||
| <Reference Include="FSharp.Core"> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for now we should revert changes to project files, you can keep them local and eventually we will make the solution work better outside of VS2015, but it is easier to know we don't break things without those changes. |
||
| <HintPath>..\..\packages\FSharp.Core.4.0.0.1\lib\net40\FSharp.Core.dll</HintPath> | ||
| </Reference> | ||
| <Reference Include="Microsoft.SqlServer.TransactSql.ScriptDom"> | ||
| <HintPath>..\..\lib\Microsoft.SqlServer.TransactSql.ScriptDom.dll</HintPath> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ open Microsoft.FSharp.Quotations | |
| open FSharp.Data.SqlClient | ||
|
|
||
| open ProviderImplementation.ProvidedTypes | ||
| open System.Text.RegularExpressions | ||
|
|
||
| [<assembly:TypeProviderAssembly()>] | ||
| #if DEBUG | ||
|
|
@@ -53,9 +54,11 @@ type SqlCommandProvider(config : TypeProviderConfig) as this = | |
| ProvidedStaticParameter("ConfigFile", typeof<string>, "") | ||
| ProvidedStaticParameter("AllParametersOptional", typeof<bool>, false) | ||
| ProvidedStaticParameter("DataDirectory", typeof<string>, "") | ||
| ProvidedStaticParameter("TempTableDefinitions", typeof<string>, "") | ||
| ProvidedStaticParameter("TableVarMapping", typeof<string>, "") | ||
| ], | ||
| instantiationFunction = (fun typeName args -> | ||
| let value = lazy this.CreateRootType(typeName, unbox args.[0], unbox args.[1], unbox args.[2], unbox args.[3], unbox args.[4], unbox args.[5], unbox args.[6]) | ||
| let value = lazy this.CreateRootType(typeName, unbox args.[0], unbox args.[1], unbox args.[2], unbox args.[3], unbox args.[4], unbox args.[5], unbox args.[6], unbox args.[7], unbox args.[8]) | ||
| cache.GetOrAdd(typeName, value) | ||
| ) | ||
| ) | ||
|
|
@@ -70,6 +73,8 @@ type SqlCommandProvider(config : TypeProviderConfig) as this = | |
| <param name='AllParametersOptional'>If set all parameters become optional. NULL input values must be handled inside T-SQL.</param> | ||
| <param name='ResolutionFolder'>A folder to be used to resolve relative file paths to *.sql script files at compile time. The default value is the folder that contains the project or script.</param> | ||
| <param name='DataDirectory'>The name of the data directory that replaces |DataDirectory| in connection strings. The default value is the project or script directory.</param> | ||
| <param name='TempTableDefinitions'>Temp tables create command.</param> | ||
| <param name='TableVarMapping'>List table-valued parameters in the format of "@tvp1=[dbo].[TVP_IDs]; @tvp2=[dbo].[TVP_IDs]"</param> | ||
| """ | ||
|
|
||
| this.AddNamespace(nameSpace, [ providerType ]) | ||
|
|
@@ -81,7 +86,7 @@ type SqlCommandProvider(config : TypeProviderConfig) as this = | |
| |> defaultArg | ||
| <| base.ResolveAssembly args | ||
|
|
||
| member internal this.CreateRootType(typeName, sqlStatement, connectionStringOrName: string, resultType, singleRow, configFile, allParametersOptional, dataDirectory) = | ||
| member internal this.CreateRootType(typeName, sqlStatement, connectionStringOrName: string, resultType, singleRow, configFile, allParametersOptional, dataDirectory, tempTableDefinitions, tableVarMapping) = | ||
|
|
||
| if singleRow && not (resultType = ResultType.Records || resultType = ResultType.Tuples) | ||
| then | ||
|
|
@@ -104,13 +109,19 @@ type SqlCommandProvider(config : TypeProviderConfig) as this = | |
| conn.CheckVersion() | ||
| conn.LoadDataTypesMap() | ||
|
|
||
| let parameters = DesignTime.ExtractParameters(conn, sqlStatement, allParametersOptional) | ||
| let designTimeSqlStatement, tempTableNames = | ||
| let sql, tempTableNames = DesignTime.SubstituteTempTables(conn, sqlStatement, tempTableDefinitions) | ||
|
||
| DesignTime.SubstituteTableVar(sql, tableVarMapping), tempTableNames | ||
|
|
||
| let parameters = DesignTime.ExtractParameters(conn, designTimeSqlStatement, allParametersOptional) | ||
|
|
||
| let outputColumns = | ||
| if resultType <> ResultType.DataReader | ||
| then DesignTime.GetOutputColumns(conn, sqlStatement, parameters, isStoredProcedure = false) | ||
| then DesignTime.GetOutputColumns(conn, designTimeSqlStatement, parameters, isStoredProcedure = false) | ||
| else [] | ||
|
|
||
| DesignTime.RemoveSubstitutedTempTables(conn, tempTableNames) | ||
|
|
||
| let rank = if singleRow then ResultRank.SingleRow else ResultRank.Sequence | ||
| let returnType = DesignTime.GetOutputTypes(outputColumns, resultType, rank, hasOutputParameters = false) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <packages> | ||
| <package id="FSharp.Core" version="4.0.0.1" targetFramework="net40" /> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here, let's put that aside for now, you can keep it in your local repository. |
||
| <package id="FSharp.TypeProviders.StarterPack" version="1.1.3.72" targetFramework="net40" /> | ||
| </packages> | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might want to keep new members in this file internal.