SQLProvider
SQLProvider copied to clipboard
Failed on MySQL with schema name containing dash
Description
When trying to get Individuals, for example, you'll get the error
error FS3021: Unexpected exception from provided type FSharp.Data.Sql.SqlDataProvider,DatabaseVendor="3",ConnectionString="Server=localhost;Database='prefix-portal';User=user;Password=******",ResolutionPath="c:\\Projects\\tmp\\sql\\MySqlDemo/../../../packages/scripts/MySql.Data/lib/net45",UseOptionTypes="True",Owner="prefix-portal"+dataContext+prefix-portal.customers.Individuals' member 'GetMethods': The type provider 'FSharp.Data.Sql.SqlTypeProvider' reported an error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-portal.customers LIMIT 1000' at line 1
`
Repro steps
Please provide the steps required to reproduce the problem
- Create MySQL schema with name "db-test" and add one table "Customers".
- Create script try to get individuals of Customers.
Expected behavior
It should run without error.
Actual behavior
Fails with the message shown above.
Known workarounds
Rename schema, but in my case, it's not possible.
Related information
- Used database - MySQL
- Operating system - Windows 10
- Branch - master
- .NET Runtime, CoreCLR or Mono Version - .NET CORE 2.0
Ok, this is clearly not very typical database:
MariaDB [(none)]> create database db-test;
ERROR 1064 (42000): You have an error in your SQL syntax;
check the manual that corresponds to your MariaDB server version
for the right syntax to use near '-test' at line 1
Hmm... would it have a side effects, adding backticks to SQLProvider database names?
If I set the backticks then SLQProvider doesn't see the database.
In my case the workaround could be applied, I've just created synonym database. https://dev.mysql.com/doc/refman/5.7/en/sys-create-synonym-db.html