public override bool DoesColumnExist(IDbConnection db, string columnName, string tableName, string schema = null)
{
tableName = GetTableName(tableName, schema);
var sql = "SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS"
+ " WHERE TABLE_NAME = @tableName AND COLUMN_NAME = @columnName AND TABLE_SCHEMA = @schema"
.SqlFmt(GetTableName(tableName, schema).StripDbQuotes(), columnName);
var result = db.SqlScalar<long>(sql, new { tableName, columnName, schema = db.Database });
return result > 0;
}
The method GetTableName() in the first line will escape any special MySql names with the quotes and this quoted name will be applied into the SqlScalar() parameter which is wrong, as the table and column names stored in the INFORMATION_SCHEMA.COLUMNS are not escaped.
In our case, we have a signal table, which gets escaped into 'signal'. Because of that, check on the ColumnExists() fails and looks more-less like: TABLE_NAME = "'signal'" but should: TABLE_NAME = "signal"