Comparing version 3.12.0 to 3.12.1-canary.51da6534
@@ -8,2 +8,3 @@ 'use strict'; | ||
const getBinaryParser = require('../parsers/binary_parser.js'); | ||
const getStaticBinaryParser = require('../parsers/static_binary_parser.js'); | ||
@@ -29,3 +30,3 @@ class Execute extends Command { | ||
this._localStream = null; | ||
this._unpipeStream = function() {}; | ||
this._unpipeStream = function () {}; | ||
this._streamFactory = options.infileStreamFactory; | ||
@@ -36,2 +37,6 @@ this._connection = null; | ||
buildParserFromFields(fields, connection) { | ||
if (this.options.disableEval) { | ||
return getStaticBinaryParser(fields, this.options, connection.config); | ||
} | ||
return getBinaryParser(fields, this.options, connection.config); | ||
@@ -48,3 +53,3 @@ } | ||
connection.config.charsetNumber, | ||
connection.config.timezone | ||
connection.config.timezone, | ||
); | ||
@@ -75,3 +80,3 @@ //For reasons why this try-catch is here, please see | ||
packet, | ||
connection.clientEncoding | ||
connection.clientEncoding, | ||
); | ||
@@ -95,3 +100,3 @@ this._receivedFieldsCount++; | ||
this._fields[this._resultIndex], | ||
connection | ||
connection, | ||
))(); | ||
@@ -98,0 +103,0 @@ return Execute.prototype.row; |
@@ -11,2 +11,3 @@ 'use strict'; | ||
const getTextParser = require('../parsers/text_parser.js'); | ||
const staticParser = require('../parsers/static_text_parser.js'); | ||
const ServerStatus = require('../constants/server_status.js'); | ||
@@ -34,3 +35,3 @@ | ||
this._localStream = null; | ||
this._unpipeStream = function () { }; | ||
this._unpipeStream = function () {}; | ||
this._streamFactory = options.infileStreamFactory; | ||
@@ -60,3 +61,3 @@ this._connection = null; | ||
this.sql, | ||
connection.config.charsetNumber | ||
connection.config.charsetNumber, | ||
); | ||
@@ -126,3 +127,3 @@ connection.writePacket(cmdPacket.toPacket(1)); | ||
console.log( | ||
` Resultset header received, expecting ${rs.fieldCount} column definition packets` | ||
` Resultset header received, expecting ${rs.fieldCount} column definition packets`, | ||
); | ||
@@ -147,3 +148,3 @@ } | ||
this._localStreamError = new Error( | ||
`As a result of LOCAL INFILE command server wants to read ${path} file, but as of v2.0 you must provide streamFactory option returning ReadStream.` | ||
`As a result of LOCAL INFILE command server wants to read ${path} file, but as of v2.0 you must provide streamFactory option returning ReadStream.`, | ||
); | ||
@@ -167,3 +168,3 @@ connection.writePacket(EmptyPacket); | ||
connection.writePacket( | ||
new Packets.Packet(0, dataWithHeader, 0, dataWithHeader.length) | ||
new Packets.Packet(0, dataWithHeader, 0, dataWithHeader.length), | ||
); | ||
@@ -175,3 +176,3 @@ }; | ||
}; | ||
const onError = err => { | ||
const onError = (err) => { | ||
this._localStreamError = err; | ||
@@ -206,3 +207,3 @@ connection.removeListener('error', onConnectionError); | ||
packet, | ||
connection.clientEncoding | ||
connection.clientEncoding, | ||
); | ||
@@ -223,3 +224,11 @@ this._fields[this._resultIndex].push(field); | ||
this.emit('fields', fields); | ||
this._rowParser = new (getTextParser(fields, this.options, connection.config))(fields); | ||
if (this.options.disableEval) { | ||
this._rowParser = staticParser(fields, this.options, connection.config); | ||
} else { | ||
this._rowParser = new (getTextParser( | ||
fields, | ||
this.options, | ||
connection.config, | ||
))(fields); | ||
} | ||
return Query.prototype.fieldsEOF; | ||
@@ -254,3 +263,3 @@ } | ||
this._fields[this._resultIndex], | ||
this.options | ||
this.options, | ||
); | ||
@@ -287,3 +296,3 @@ } catch (err) { | ||
}); | ||
this.on('error', err => { | ||
this.on('error', (err) => { | ||
stream.emit('error', err); // Pass on any errors | ||
@@ -294,3 +303,3 @@ }); | ||
}); | ||
this.on('fields', fields => { | ||
this.on('fields', (fields) => { | ||
stream.emit('fields', fields); // replicate old emitter | ||
@@ -307,6 +316,3 @@ }); | ||
const timeoutHandler = this._handleTimeoutError.bind(this); | ||
this.queryTimeout = Timers.setTimeout( | ||
timeoutHandler, | ||
this.timeout | ||
); | ||
this.queryTimeout = Timers.setTimeout(timeoutHandler, this.timeout); | ||
} | ||
@@ -313,0 +319,0 @@ } |
@@ -13,3 +13,3 @@ // This file was modified by Oracle on September 21, 2021. | ||
const Charsets = require('./constants/charsets'); | ||
const { version } = require('../package.json') | ||
const { version } = require('../package.json'); | ||
let SSLProfiles = null; | ||
@@ -63,2 +63,3 @@ | ||
user: 1, | ||
disableEval: 1, | ||
// These options are used for Pool | ||
@@ -71,3 +72,3 @@ connectionLimit: 1, | ||
waitForConnections: 1, | ||
jsonStrings: 1 | ||
jsonStrings: 1, | ||
}; | ||
@@ -93,3 +94,3 @@ | ||
console.error( | ||
`Ignoring invalid configuration option passed to Connection: ${key}. This is currently a warning, but in future versions of MySQL2, an error will be thrown if you pass an invalid configuration option to a Connection` | ||
`Ignoring invalid configuration option passed to Connection: ${key}. This is currently a warning, but in future versions of MySQL2, an error will be thrown if you pass an invalid configuration option to a Connection`, | ||
); | ||
@@ -101,3 +102,6 @@ } | ||
this.host = options.host || 'localhost'; | ||
this.port = (typeof options.port === 'string' ? parseInt(options.port, 10) : options.port)|| 3306; | ||
this.port = | ||
(typeof options.port === 'string' | ||
? parseInt(options.port, 10) | ||
: options.port) || 3306; | ||
this.localAddress = options.localAddress; | ||
@@ -136,3 +140,3 @@ this.socketPath = options.socketPath; | ||
console.error( | ||
`Ignoring invalid timezone passed to Connection: ${options.timezone}. This is currently a warning, but in future versions of MySQL2, an error will be thrown if you pass an invalid configuration option to a Connection` | ||
`Ignoring invalid timezone passed to Connection: ${options.timezone}. This is currently a warning, but in future versions of MySQL2, an error will be thrown if you pass an invalid configuration option to a Connection`, | ||
); | ||
@@ -156,2 +160,3 @@ // SqlStrings falls back to UTC on invalid timezone | ||
this.typeCast = options.typeCast === undefined ? true : options.typeCast; | ||
this.disableEval = Boolean(options.disableEval); | ||
if (this.timezone[0] === ' ') { | ||
@@ -166,3 +171,3 @@ // "+" is a url encoded char for space so it | ||
throw new TypeError( | ||
`SSL profile must be an object, instead it's a ${typeof this.ssl}` | ||
`SSL profile must be an object, instead it's a ${typeof this.ssl}`, | ||
); | ||
@@ -182,11 +187,14 @@ } | ||
ConnectionConfig.getDefaultFlags(options), | ||
options.flags || '' | ||
options.flags || '', | ||
); | ||
// Default connection attributes | ||
// https://dev.mysql.com/doc/refman/8.0/en/performance-schema-connection-attribute-tables.html | ||
const defaultConnectAttributes = { | ||
const defaultConnectAttributes = { | ||
_client_name: 'Node-MySQL-2', | ||
_client_version: version | ||
_client_version: version, | ||
}; | ||
this.connectAttributes = { ...defaultConnectAttributes, ...(options.connectAttributes || {})}; | ||
this.connectAttributes = { | ||
...defaultConnectAttributes, | ||
...(options.connectAttributes || {}), | ||
}; | ||
this.maxPreparedStatements = options.maxPreparedStatements || 16000; | ||
@@ -241,3 +249,3 @@ this.jsonStrings = options.jsonStrings || false; | ||
'SESSION_TRACK', | ||
'CONNECT_ATTRS' | ||
'CONNECT_ATTRS', | ||
]; | ||
@@ -244,0 +252,0 @@ if (options && options.multipleStatements) { |
@@ -77,3 +77,3 @@ 'use strict'; | ||
const fieldEscape = (field) => { | ||
const fieldEscape = (field, isEval = true) => { | ||
if (privateObjectProps.has(field)) { | ||
@@ -85,5 +85,4 @@ throw new Error( | ||
return srcEscape(field); | ||
return isEval ? srcEscape(field) : field; | ||
}; | ||
exports.fieldEscape = fieldEscape; |
{ | ||
"name": "mysql2", | ||
"version": "3.12.0", | ||
"version": "3.12.1-canary.51da6534", | ||
"description": "fast mysql driver. Implements core protocol, prepared statements, ssl and compression in native JS", | ||
@@ -11,8 +11,9 @@ "main": "index.js", | ||
"lint:code": "eslint index.js promise.js index.d.ts promise.d.ts \"typings/**/*.ts\" \"lib/**/*.js\" \"test/**/*.{js,cjs,mjs,ts}\" \"benchmarks/**/*.js\"", | ||
"lint:fix": "npm run lint:docs -- --fix &&npm run lint:code -- --fix", | ||
"lint:docs": "eslint Contributing.md README.md", | ||
"lint:typings": "npx prettier --check ./typings", | ||
"lint:tests": "npx prettier --check ./test", | ||
"test": "poku -d test/esm test/unit test/integration", | ||
"test:bun": "poku -d --bun test/esm test/unit test/integration", | ||
"test:deno": "deno run --allow-read --allow-env --allow-run npm:poku -d --deno --denoAllow=\"read,env,net,sys\" test/esm test/unit test/integration", | ||
"test": "poku -d -r=verbose --sequential test/esm test/unit test/integration", | ||
"test:bun": "bun poku -d --sequential test/esm test/unit test/integration", | ||
"test:deno": "deno run --allow-read --allow-env --allow-run npm:poku -d --sequential --denoAllow=\"read,env,net,sys\" test/esm test/unit test/integration", | ||
"test:tsc-build": "cd \"test/tsc-build\" && npx tsc -p \"tsconfig.json\"", | ||
@@ -82,7 +83,7 @@ "coverage-test": "c8 npm run test", | ||
"eslint": "^8.27.0", | ||
"eslint-config-prettier": "^9.0.0", | ||
"eslint-config-prettier": "^10.0.1", | ||
"eslint-plugin-async-await": "0.0.0", | ||
"eslint-plugin-markdown": "^5.0.0", | ||
"lint-staged": "^15.0.1", | ||
"poku": "^2.0.0", | ||
"poku": "^3.0.0", | ||
"portfinder": "^1.0.28", | ||
@@ -89,0 +90,0 @@ "prettier": "^3.0.0", |
@@ -326,2 +326,4 @@ // This file was modified by Oracle on November 04, 2021. | ||
disableEval?: boolean; | ||
authPlugins?: { | ||
@@ -328,0 +330,0 @@ [key: string]: AuthPlugin; |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
520615
123
14225
1
26