Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Table name contains space char causes syntax error #792

Closed
victor-wiki opened this issue Mar 30, 2020 · 2 comments
Closed

Table name contains space char causes syntax error #792

victor-wiki opened this issue Mar 30, 2020 · 2 comments
Labels

Comments

@victor-wiki
Copy link

@victor-wiki victor-wiki commented Mar 30, 2020

I have a table named "Order Details", when copy data using MySqlBulkCopy, it throws:
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 'Order Details CHARACTER SET utf8mb4 FIELDS TERMINATED BY ' ' ESCAPED BY '\\' LIN' at line 1.

I debugged to find the command text is:

LOAD DATA LOCAL INFILE ':SOURCE:2b58ba020ec74eeb89684c96bb6afd67' INTO TABLE Order Details CHARACTER SET utf8mb4 FIELDS TERMINATED BY '	' ESCAPED BY '\\' LINES TERMINATED BY '
' IGNORE 0 LINES (`OrderID`,`ProductID`,`UnitPrice`,`Quantity`,`Discount`) ;

So, it needs to handle the issue like handle column name above calling method QuoteIdentifier.

@bgrainger
Copy link
Member

@bgrainger bgrainger commented Mar 30, 2020

This is indeed a bug here:

sb.AppendFormat(CultureInfo.InvariantCulture, "INTO TABLE {0} ", TableName);

I need to look into whether that's for backwards compatibility with Connector/NET, which may expect the user to quote the table name manually for MySqlBulkLoader. If so, the fix will be to quote it in MySqlBulkCopy.

@bgrainger
Copy link
Member

@bgrainger bgrainger commented Apr 4, 2020

Fixed in 0.63.1.

Note that if you were quoting the table name to work around this bug, you will have to revert that code after updating.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants