Comments (5)
@aaron13100 do you want to send a PR with added null, 0
?
from node-mysql2.
Edited
This happens when you change the native JSON.stringify
method:
// It's a string
return ((function () {
return class TextRow {
constructor(fields) {
}
next(packet, fields, options) {
this.packet = packet;
const result = {};
//
"version()": : VAR_STRING
result[
"version()": ] = packet.readLengthCodedString(fields[0].encoding);
return result;
}
};
})())
Look at that:
// "version()": : VAR_STRING
Now, what it should be:
// It's a string
return ((function () {
return class TextRow {
constructor(fields) {
}
next(packet, fields, options) {
this.packet = packet;
const result = {};
// "version()": VAR_STRING
result["version()"] = packet.readLengthCodedString(fields[0].encoding);
return result;
}
};
})())
from node-mysql2.
Since this error comes from an external dependency, I will close this issue as not planned.
But feel free to ask anything and reopen it at anytime 🙋🏻♂️
from node-mysql2.
the error actually comes from srcEscape, here is smaller self contained example:
const originalStringify = JSON.stringify;
if (true) {
/* without this override there is no error */
JSON.stringify = function (obj, replacer = null, space = 2) {
return originalStringify(obj, replacer, space);
};
}
function srcEscape(str) {
return JSON.stringify({
[str]: 1
}).slice(1, -3);
}
console.log(srcEscape(`test("test")`));
we can probably change to something more reliable:
return JSON.stringify({
[str]: 1
}).trim().slice(1, -1).split('\n').filter(s => s.length > 0).split(':').slice(0, -1).join('')
or just use some more simple way of escaping. JSON.stringify + key extract works both fast and reliable but I'm open to other suggestions.
Another fix that would work with @aaron13100 example is to just pass replacer and space explicitly in srcEscape:
function srcEscape(str) {
return JSON.stringify({
[str]: 1
}, null, 0).slice(1, -3);
}
from node-mysql2.
Thanks, @sidorares 🙋🏻♂️
I've adjusted my comment.
from node-mysql2.
Related Issues (20)
- Type 'Query' must have a '[Symbol.iterator]()' method that returns an iterator.ts(2488) Exception HOT 1
- re escaping special chars in json values HOT 1
- Timeout since 3.9.4 HOT 2
- HANDSHAKE_SSL_ERROR with RDS and 3.9.3+ HOT 12
- Can't create more than max prepared stmtount statements(current value: 16382) HOT 4
- Release 3.9.4 breaks code that depended on .hasOwnProperty() HOT 3
- got warning when host is an IP address HOT 3
- Transaction issue in my code. Please Help!
- read ECONNRESET after upgrading HOT 11
- typeCast: false causes out of bounds reads to packet when result set contains NULL values and binary protocol is used.
- README documentation HOT 1
- True negative: ssl-mode query params in connectionString considered as invalid HOT 1
- TypeError: LRU is not a constructor HOT 3
- PoolConnection.execute() retrun object v3.9.7 HOT 6
- Deadlock found when trying to get lock HOT 3
- [createConnection] Can't add new command when connection is in closed state HOT 8
- Sporadic read ETIMEDOUT error HOT 9
- Incorrect typings lead to pool.destroy is not a function HOT 2
- Invalid ssl option but still DB connection working fine HOT 1
- Access Denied after database restart (but granted after login via CLI) HOT 23
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.