SQLProvider
SQLProvider copied to clipboard
Type Provider putting in extra backslash before non-default parameter values.
Description
TP puts in an extra \ (backslash) before any non-default parameter values. I noticed this first by specifying a value for the the Owner parameter (see this issue #400) but then realized that this happens for any other parameter as well (e.g. UseOptionTypes)
Repro steps
Initialize the SqlDataProvider like so:
let [<Literal>] resPath = __SOURCE_DIRECTORY__ + @"..\..\packages\Npgsql.3.1.0\lib\net45\"
let [<Literal>] dbVendor = Common.DatabaseProviderTypes.POSTGRESQL
type dbCon =
SqlDataProvider<DatabaseVendor = dbVendor,
ConnectionString = dbConStr,
ResolutionPath = resPath,
UseOptionTypes = false,
Owner = "backoffice">
OR like this
type dbCon =
SqlDataProvider<DatabaseVendor = dbVendor,
ConnectionString = dbConStr,
ResolutionPath = resPath,
UseOptionTypes = true>
Actual behavior
In both cases I get an error for the type provider.
In the first case (with the Owner param):
Error FS3028 The type provider 'FSharp.Data.Sql.SqlTypeProvider' reported an error: Expected provided type named 'SqlDataProvider,DatabaseVendor="2",ConnectionString="Host=xxx; Database=xxx; Username=xxx; Password=xxx",ResolutionPath="C:\\Users\\xxx\\packages\\Npgsql.3.1.0\\lib\\net45\\",Owner="backoffice"' but provided type has 'Name' with value 'SqlDataProvider,DatabaseVendor="2",ConnectionString="Host=xxx; Database=xxx; Username=xxx; Password=xxx",ResolutionPath="C:\\Users\\xxx\\packages\\Npgsql.3.1.0\\lib\\net45\",Owner=\"backoffice"' C:\Users\xxx\Desktop\xxx\Library1.fs
In the second case (with the UserOptionTypes param having the non-default value of true):
Error FS3028 The type provider 'FSharp.Data.Sql.SqlTypeProvider' reported an error: Expected provided type named 'SqlDataProvider,DatabaseVendor="2",ConnectionString="Host=xxx; Database=xxx; Username=xxx; Password=xxx",ResolutionPath="C:\\Users\\xxx\\packages\\Npgsql.3.1.0\\lib\\net45\\",UseOptionTypes="True"' but provided type has 'Name' with value 'SqlDataProvider,DatabaseVendor="2",ConnectionString="Host=xxx; Database=xxx; Username=xxx; Password=xxx",ResolutionPath="C:\\Users\\xxx\\packages\\Npgsql.3.1.0\\lib\\net45\",UseOptionTypes=\"True"' C:\Users\xxx\Desktop\xxx\Library1.fs
Notice the extra backslash before the value of the parameter: Owner=\"backoffice" and UseOptionTypes=\"True"
Related information
- PostgreSql 9.4
- Windows 7
- Visual Studio 2017 Community
- .NET Framework 4.5
- FSharp 4.4.1.0
Related to #400 and #399
Hmm. Just tested, couldn't reproduce, everything working fine.
My config was:
- PostgreSQL 9.6.2
- Windows 10
- Visual Studio 2017 Enterprise
- .NET Framework 4.7
- F# Interactive version 4.1
- Npgsql.dll v 3.1.7 from Nuget
Can you get more info how this is happening?
This could somehow come from .NET string concatenation where @ -mark is doubling the backslashes.
Meanwhile I don't know what is causing this (works on my machine™) there is a solution in #373
let [<Literal>] resPath = @"""packages\Npgsql.3.2.5\lib\net451"""