Closed
Description
As mentioned in the MySQL changelogs
It is possible to define a column named * (single asterisk character), but SELECT
*
was treated identically to SELECT *,
making it impossible to select only this column in a query; in other words, the asterisk character was expanded to a list
of all table columns even when it was surrounded by backticks. (Bug #30528450)
Now that its possible to quote the *
character and use it as a column name,
automatic column name escaping is broken when using *
as one of the columns being escaped.
Example
const mysql = require('mysql2');
// create the connection to database
const connection = mysql.createConnection({
host: 'localhost',
user: 'root',
password: 'test',
database: 'test'
});
// simple query
connection.query(
'SELECT ?? FROM ??',
[['*'], 'testTable'],
function(err, results, fields) {
console.log(err);
console.log(results); // results contains rows returned by server
}
);
In version MySQL 8.0.21 this code throws the following error: Error: Unknown column '*' in 'field list'
Metadata
Metadata
Assignees
Labels
No labels