SQLProvider icon indicating copy to clipboard operation
SQLProvider copied to clipboard

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

Open Choc13 opened this issue 3 years ago • 0 comments
trafficstars

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`

Choc13 avatar Nov 17 '22 14:11 Choc13