Comments (7)
Thanks, I'll try to check. You have whole query commented here - is that what you want? Uncommented part is ;;
from node-mysql2.
Can't reproduce. This works for me (5.6.10 MySQL Community Server (GPL)
):
db.query("select 1+1 v /* this is comment */", function(err, rows, fields) {
console.log(err, rows, fields);
});
result:
null [ { v: '2' } ] [ { catalog: 'def',
schema: '',
table: '',
orgTable: '',
name: 'v',
orgName: '',
characterSet: 63,
columnLength: 3,
columnType: 8,
flags: 129,
decimals: 0 } ]
db.execute("select 1+1 v /* this is comment */", function(err, rows, fields) {
console.log(err, rows, fields);
});
result:
null [ { v: '2' } ] [ { catalog: 'def',
schema: '',
table: '',
orgTable: '',
name: 'v',
orgName: '',
characterSet: 63,
columnLength: 3,
columnType: 8,
flags: 129,
decimals: 0 } ]
from node-mysql2.
It looks mysql does not like /*!
comment beginning. If you remove !
error disappear.
from node-mysql2.
But comments beginning with /*! are valid in mysql. It's a conditional execution.
from node-mysql2.
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
from node-mysql2.
Should work now - could you try with v0.8.19?
from node-mysql2.
@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:
ERROR: 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 'SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COL' at line 9
from node-mysql2.
Related Issues (20)
- Add support for auth_gssapi_client MariaDB authentication plugin HOT 4
- Connection Timeout on ubuntu 22.04 (works fine on windows) HOT 2
- Decimals
- Error: Can't add new command when connection is in closed state HOT 1
- awsCaBundle not working as intended for import RDS cert HOT 5
- idleTimeout doenst work in lambda environment?
- `connection.stream` does not close in Bun HOT 6
- Issue with `sha256_password` auth plugin for `MySQL v8.0.35-27` HOT 1
- Connection.end() not compatible with mysql HOT 1
- deleted: Buffer(1) [ 0 ], HOT 7
- Probably -VE Testcase: TypeError: cb is not a function at C:\Development\YADAMU\src\node_modules\mysql2\lib\pool.js:64:18 HOT 1
- Probably -VE Testcase : Error: Cannot read properties of undefined (reading 'on') at PromisePoolConnection.query (C:\Development\YADAMU\src\node_modules\mysql2\promise.js:94:22) HOT 6
- Compatibility issue - Possible corruption of values with min and max values for a double. HOT 2
- Pool does not detect nor recover from failover
- Graceful poolcluster management with AWS Aurora
- [Bug?] node-mysql2 seems to swap `x` and `y` values of a geographic Point (SRID 4326) stored in mysql8 HOT 5
- problem HOT 3
- Can't add new command when connection is in closed state
- Wrong error returned without correcting sending internal Fatal error message
- createPoolCluster does not maintain a connection to the same database throughout execution
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-mysql2.