Bug #83973 MySQL syntax error
Submitted: 26 Nov 2016 2:53 Modified: 10 Aug 2022 17:29
Reporter: Charlie Chu (OCA) Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:7.0 OS:Any
Assigned to: CPU Architecture:Any
Tags: syntax error

[26 Nov 2016 2:53] Charlie Chu
Description:
In the where clause of the `HasTablesAsync` method in the *MySQLDatabaseCreator.cs* file, use the incorrect ` character.

How to repeat:
protected override async Task<bool> HasTablesAsync(CancellationToken cancellationToken = default(CancellationToken))
{
 string sql = "SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = `" + _connection.DbConnection.Database + "`";

        long count = (long)await _rawSqlCommandBuilder.Build(sql).ExecuteScalarAsync(_connection, cancellationToken: cancellationToken);
        return count != 0;
}

Suggested fix:
 string sql = "SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '" + _connection.DbConnection.Database + "'";

https://github.com/mysql/mysql-connector-net/pull/5
[26 Nov 2016 3:08] Charlie Chu
syntax error

Attachment: QQ20161126-0@2x.png (image/png, text), 116.40 KiB.

[26 Nov 2016 3:09] Charlie Chu
https://github.com/mysql/mysql-connector-net/pull/5
[28 Nov 2016 6:32] Chiranjeevi Battula
Hello Charlie,

Thank you for the bug report.

Thanks,
Chiranjeevi.
[28 Nov 2016 13:13] Charlie Chu
This issue is fixed in the PR:
https://github.com/mysql/mysql-connector-net/pull/5

I will sign the Oracle Contribution Agreement (OCA) tomorrow.
[29 Nov 2016 3:56] Charlie Chu
An OCA has been submitted.Thanks.
[20 Dec 2016 12:23] Chiranjeevi Battula
http://bugs.mysql.com/bug.php?id=84267 marked as duplicate of this one.
[10 Aug 2022 17:29] Daniel Valdez
Can't reproduce bug. Please use our latest release, Connector/NET 8.0.30.