-
-
Notifications
You must be signed in to change notification settings - Fork 612
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
Error executing query with c-style comments #26
Comments
Thanks, I'll try to check. You have whole query commented here - is that what you want? Uncommented part is |
Can't reproduce. This works for me ( db.query("select 1+1 v /* this is comment */", function(err, rows, fields) {
console.log(err, rows, fields);
}); result:
db.execute("select 1+1 v /* this is comment */", function(err, rows, fields) {
console.log(err, rows, fields);
}); result:
|
It looks mysql does not like |
But comments beginning with /*! are valid in mysql. It's a conditional execution. |
I wasn't aware about conditional comments. Just for the record: http://dev.mysql.com/doc/refman/5.5/en/comments.html The problem here is likely with multiple queries in one command. I'll check if this is the case |
Should work now - could you try with v0.8.19? |
@sidorares I'm still getting this exact error on version 3.9.7, trying to execute a dump I pulled from a running MySQL instance. e.g. import mysql from "mysql2";
const schema = `
--
-- MySQL dump 10.13 Distrib 8.0.33, for Linux (x86_64)
--
-- Host: localhost Database: blue
-- ------------------------------------------------------
-- Server version 8.0.33
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!50503 SET NAMES UTF8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table \`myTable\`
--
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE \`myTable\` (
\`id\` int NOT NULL AUTO_INCREMENT,
PRIMARY KEY (\`id\`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table \`myTable\`
--
LOCK TABLES \`myTable\` WRITE;
/*!40000 ALTER TABLE \`myTable\` DISABLE KEYS */;
/*!40000 ALTER TABLE \`myTable\` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2024-08-02 14:32:21
`;
async function initSchema(): Promise<void> {
const connection = mysql.createConnection({
user: "username",
password: "password",
host: "host",
port: "port",
});
await new Promise<void>((resolve, reject) => {
connection.connect((err: Error | null | undefined) => {
if (err) {
reject(err);
} else {
resolve();
}
});
});
await new Promise<void>((resolve, reject) => {
connection.query(schema, (err) => {
if (err) {
reject(err);
} else {
resolve();
}
});
});
await new Promise<void>((resolve, reject) => {
connection.end((err: Error | null | undefined) => {
if (err) {
reject(err);
} else {
resolve();
}
});
});
} Results in: |
Hello, I'm trying to execute some queries that have comments wrapped by /* and */ and I'm getting:
Are these comments supported?
Thanks.
The text was updated successfully, but these errors were encountered: