SQLProvider icon indicating copy to clipboard operation
SQLProvider copied to clipboard

Failed on MySQL with schema name containing dash

Open DmitryBatalov opened this issue 7 years ago • 3 comments
trafficstars

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

  1. Create MySQL schema with name "db-test" and add one table "Customers".
  2. 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

DmitryBatalov avatar Jan 25 '18 20:01 DmitryBatalov

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?

Thorium avatar Jan 25 '18 21:01 Thorium

If I set the backticks then SLQProvider doesn't see the database.

DmitryBatalov avatar Jan 28 '18 07:01 DmitryBatalov

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

DmitryBatalov avatar Jan 28 '18 08:01 DmitryBatalov