Bug #64049 Syntax errors if schema name contains a dash '-'
Submitted: 17 Jan 2012 12:57 Modified: 17 Feb 2012 13:40
Reporter: Jon Burney Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Workbench: SQL Editor Severity:S3 (Non-critical)
Version:5.2.36 (rev 8542) OS:Linux (Ubuntu 10.10)
Assigned to: CPU Architecture:Any

[17 Jan 2012 12:57] Jon Burney
Description:
Right clicking on a table and selecting "Select rows" from the menu causes a syntax error if the schema name contains a 'dash' because the generated queries aren't wrapped in back quotes.

e.g.

SELECT * FROM live-db.user_data;

rather than 

SELECT * FROM `live-db`.`user_data`;

Running MySQL Workbench 5.2.36 against MySQL 5.1.56

How to repeat:
Create a new schema called 'live-db' with one table

CREATE SCHEMA `live-db` ;

CREATE  TABLE `live-db`.`user_data` (
  `id` INT NOT NULL ,
  `name` VARCHAR(45) NULL ,
  PRIMARY KEY (`id`) 
);

Right click on the table name in MySQL workbench and click "Select Rows". 

The following incorrect query is generated

SELECT * FROM live-db.user_data;

Which results in the following error

Error Code: 1064. 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 '-db.user_data' at line 1

Suggested fix:
Wrapping the generated query in back quotes fixes the issue

SELECT * FROM live-db.user_data;

Replace with

SELECT * FROM `live-db`.`user_data`;
[17 Jan 2012 13:40] Valeriy Kravchuk
Please, check if newer version, 5.2.37, solves the problem for you. I do not see it on Windows XP with 5.2.37 at least.
[18 Feb 2012 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".