fsprojects / SQLProvider

A general F# SQL database erasing type provider, supporting LINQ queries, schema exploration, individuals, CRUD operations and much more besides.
https://fsprojects.github.io/SQLProvider
Other
564 stars 144 forks source link

Queries failing for schemas / tables that contain special characters - MySQL #776

Open Choc13 opened 1 year ago

Choc13 commented 1 year ago

Describe the bug We have a schema name like my-schema in MySQL. When querying this schema we are required to enclose it in backticks to escape the hyphen. It seems however that the SQL generated by SQL Provider does not contain backticks around schema or table names (although it does around column names).

In principle would it be possible to always wrap schema and table names in backticks to ensure they are properly escaped? If so I'm happy to submit a PR.

On a side note I think this might be the underlying cause of the other issue (#773) I opened about the missing Create(...) functions.

To Reproduce Create a schema in MySQL that contains a - in the name and try to query it.

Expected behavior The generated SQL should be more like:

SELECT `a` as `a`
FROM `my-schema`.`my-table`