Socket
Socket
Sign inDemoInstall

mysql

Package Overview
Dependencies
7
Maintainers
6
Versions
65
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.11.1 to 2.12.0

33

Changes.md

@@ -7,2 +7,17 @@ # Changes

## v2.12.0 (2016-11-02)
* Accept array of type names to `dateStrings` option #605 #1481
* Add `query` method to `PoolNamespace` #1256 #1505 #1506
- Used as `cluster.of(...).query(...)`
* Add new error codes up to MySQL 5.7.16
* Fix edge cases writing certain length coded values
* Fix typo in `HANDSHAKE_NO_SSL_SUPPORT` error message #1534
* Support Node.js 7.x
* Update `bignumber.js` to 2.4.0
* Update `sqlstring` to 2.2.0
- Accept numbers and other value types in `escapeId`
- Escape invalid `Date` objects as `NULL`
- Run `buffer.toString()` through escaping
## v2.11.1 (2016-06-07)

@@ -449,19 +464,19 @@

* [v0.9.0](https://github.com/felixge/node-mysql/compare/v0.8.0...v0.9.0)
* [v0.9.0](https://github.com/mysqljs/mysql/compare/v0.8.0...v0.9.0)
(2011-01-04)
* [v0.8.0](https://github.com/felixge/node-mysql/compare/v0.7.0...v0.8.0)
* [v0.8.0](https://github.com/mysqljs/mysql/compare/v0.7.0...v0.8.0)
(2010-10-30)
* [v0.7.0](https://github.com/felixge/node-mysql/compare/v0.6.0...v0.7.0)
* [v0.7.0](https://github.com/mysqljs/mysql/compare/v0.6.0...v0.7.0)
(2010-10-14)
* [v0.6.0](https://github.com/felixge/node-mysql/compare/v0.5.0...v0.6.0)
* [v0.6.0](https://github.com/mysqljs/mysql/compare/v0.5.0...v0.6.0)
(2010-09-28)
* [v0.5.0](https://github.com/felixge/node-mysql/compare/v0.4.0...v0.5.0)
* [v0.5.0](https://github.com/mysqljs/mysql/compare/v0.4.0...v0.5.0)
(2010-09-17)
* [v0.4.0](https://github.com/felixge/node-mysql/compare/v0.3.0...v0.4.0)
* [v0.4.0](https://github.com/mysqljs/mysql/compare/v0.3.0...v0.4.0)
(2010-09-02)
* [v0.3.0](https://github.com/felixge/node-mysql/compare/v0.2.0...v0.3.0)
* [v0.3.0](https://github.com/mysqljs/mysql/compare/v0.2.0...v0.3.0)
(2010-08-25)
* [v0.2.0](https://github.com/felixge/node-mysql/compare/v0.1.0...v0.2.0)
* [v0.2.0](https://github.com/mysqljs/mysql/compare/v0.1.0...v0.2.0)
(2010-08-22)
* [v0.1.0](https://github.com/felixge/node-mysql/commits/v0.1.0)
* [v0.1.0](https://github.com/mysqljs/mysql/commits/v0.1.0)
(2010-08-22)

@@ -21,3 +21,3 @@ var Crypto = require('crypto');

this._connectCalled = false;
this.state = "disconnected";
this.state = 'disconnected';
this.threadId = null;

@@ -107,3 +107,3 @@ }

this._protocol.on('data', function(data) {
connection._socket.write(data);
connection._socket.write(data);
});

@@ -114,3 +114,3 @@ this._socket.on('data', function(data) {

this._protocol.on('end', function() {
connection._socket.end();
connection._socket.end();
});

@@ -207,3 +207,3 @@ this._socket.on('end', function(err) {

if (!(typeof sql == 'object' && 'typeCast' in sql)) {
if (!(typeof sql === 'object' && 'typeCast' in sql)) {
query.typeCast = this.config.typeCast;

@@ -263,3 +263,3 @@ }

Connection.prototype.destroy = function() {
this.state = "disconnected";
this.state = 'disconnected';
this._implyConnect();

@@ -289,3 +289,3 @@ this._socket.destroy();

Connection.prototype.format = function(sql, values) {
if (typeof this.config.queryFormat == "function") {
if (typeof this.config.queryFormat === 'function') {
return this.config.queryFormat.call(this, sql, values, this.config.timezone);

@@ -444,3 +444,3 @@ }

Connection.prototype._handleProtocolError = function(err) {
this.state = "protocol_error";
this.state = 'protocol_error';
this.emit('error', err);

@@ -454,3 +454,3 @@ };

Connection.prototype._handleProtocolConnect = function() {
this.state = "connected";
this.state = 'connected';
this.emit('connect');

@@ -460,3 +460,3 @@ };

Connection.prototype._handleProtocolHandshake = function _handleProtocolHandshake(packet) {
this.state = "authenticated";
this.state = 'authenticated';
this.threadId = packet.threadId;

@@ -466,3 +466,3 @@ };

Connection.prototype._handleProtocolEnd = function(err) {
this.state = "disconnected";
this.state = 'disconnected';
this.emit('end', err);

@@ -469,0 +469,0 @@ };

@@ -41,7 +41,7 @@ var urlParse = require('url').parse;

if (this.timezone[0] == " ") {
if (this.timezone[0] === ' ') {
// "+" is a url encoded char for space so it
// gets translated to space when giving a
// connection string..
this.timezone = "+" + this.timezone.substr(1);
this.timezone = '+' + this.timezone.substr(1);
}

@@ -48,0 +48,0 @@

@@ -162,3 +162,3 @@ var mysql = require('../');

if (typeof cb != "function") {
if (typeof cb !== 'function') {
cb = function (err) {

@@ -198,3 +198,3 @@ if (err) throw err;

// Long stack trace support
query._callSite = new Error;
query._callSite = new Error();
}

@@ -201,0 +201,0 @@

@@ -0,1 +1,2 @@

var Connection = require('./Connection');
var PoolSelector = require('./PoolSelector');

@@ -57,2 +58,61 @@

PoolNamespace.prototype.query = function (sql, values, cb) {
var cluster = this._cluster;
var clusterNode = this._getClusterNode();
var query = Connection.createQuery(sql, values, cb);
var namespace = this;
if (clusterNode === null) {
var err = null;
if (this._cluster._findNodeIds(this._pattern, true).length !== 0) {
err = new Error('Pool does not have online node.');
err.code = 'POOL_NONEONLINE';
} else {
err = new Error('Pool does not exist.');
err.code = 'POOL_NOEXIST';
}
process.nextTick(function () {
query.on('error', function () {});
query.end(err);
});
return query;
}
if (!(typeof sql === 'object' && 'typeCast' in sql)) {
query.typeCast = clusterNode.pool.config.connectionConfig.typeCast;
}
if (clusterNode.pool.config.connectionConfig.trace) {
// Long stack trace support
query._callSite = new Error();
}
cluster._getConnection(clusterNode, function (err, conn) {
var retry = err && cluster._canRetry
&& cluster._findNodeIds(namespace._pattern).length !== 0;
if (retry) {
namespace.query(query);
return;
}
if (err) {
query.on('error', function () {});
query.end(err);
return;
}
// Release connection based off event
query.once('end', function() {
conn.release();
});
conn.query(query);
});
return query;
};
PoolNamespace.prototype._getClusterNode = function _getClusterNode() {

@@ -59,0 +119,0 @@ var foundNodeIds = this._cluster._findNodeIds(this._pattern);

@@ -29,3 +29,3 @@ var Buffer = require('buffer').Buffer;

// password must be in binary format, not utf8
var stage1 = sha1((new Buffer(password, "utf8")).toString("binary"));
var stage1 = sha1((new Buffer(password, 'utf8')).toString('binary'));
var stage2 = sha1(stage1);

@@ -44,3 +44,3 @@ var stage3 = sha1(scramble.toString('binary') + stage2);

if (typeof password == 'string'){
if (typeof password === 'string'){
password = new Buffer(password);

@@ -51,3 +51,3 @@ }

var c = password[i];
if (c == 32 || c == 9) {
if (c === 32 || c === 9) {
// skip space in password

@@ -111,15 +111,2 @@ continue;

Auth.fmt32 = function(x){
var a = x[0].toString(16),
b = x[1].toString(16);
if (a.length == 1) a = '000'+a;
if (a.length == 2) a = '00'+a;
if (a.length == 3) a = '0'+a;
if (b.length == 1) b = '000'+b;
if (b.length == 2) b = '00'+b;
if (b.length == 3) b = '0'+b;
return '' + a + '/' + b;
};
Auth.xor32 = function(a,b){

@@ -126,0 +113,0 @@ return [a[0] ^ b[0], a[1] ^ b[1]];

@@ -30,3 +30,3 @@ var Types = require('../constants/types');

for (var k in Types) {
if (Types[k] == t) return k;
if (Types[k] === t) return k;
}

@@ -33,0 +33,0 @@

@@ -92,6 +92,6 @@ var Client = require('../constants/client');

var buffer = new Buffer(this.scrambleBuff1.length +
(typeof this.scrambleBuff2 != "undefined" ? this.scrambleBuff2.length : 0));
(typeof this.scrambleBuff2 !== 'undefined' ? this.scrambleBuff2.length : 0));
this.scrambleBuff1.copy(buffer);
if (typeof this.scrambleBuff2 != "undefined") {
if (typeof this.scrambleBuff2 !== 'undefined') {
this.scrambleBuff2.copy(buffer, this.scrambleBuff1.length);

@@ -98,0 +98,0 @@ }

@@ -32,3 +32,3 @@ var Types = require('../constants/types');

if (typeof typeCast == "function") {
if (typeof typeCast === 'function') {
value = typeCast.apply(connection, [ new Field({ packet: fieldPacket, parser: parser }), next ]);

@@ -43,3 +43,3 @@ } else {

if (typeof nestTables == "string" && nestTables.length) {
if (typeof nestTables === 'string' && nestTables.length) {
this[fieldPacket.table + nestTables + fieldPacket.name] = value;

@@ -66,6 +66,6 @@ } else if (nestTables) {

var dateString = parser.parseLengthCodedString();
if (dateStrings) {
return dateString;
if (typeMatch(field.type, dateStrings)) {
return dateString;
}
var dt;

@@ -85,3 +85,3 @@ if (dateString === null) {

dt = new Date(dateString);
var dt = new Date(dateString);
if (isNaN(dt.getTime())) {

@@ -100,3 +100,3 @@ return originalString;

numberString = parser.parseLengthCodedString();
return (numberString === null || (field.zeroFill && numberString[0] == "0"))
return (numberString === null || (field.zeroFill && numberString[0] === '0'))
? numberString : Number(numberString);

@@ -106,3 +106,3 @@ case Types.NEWDECIMAL:

numberString = parser.parseLengthCodedString();
return (numberString === null || (field.zeroFill && numberString[0] == "0"))
return (numberString === null || (field.zeroFill && numberString[0] === '0'))
? numberString

@@ -129,1 +129,12 @@ : ((supportBigNumbers && (bigNumberStrings || (Number(numberString) >= IEEE_754_BINARY_64_PRECISION) || Number(numberString) <= -IEEE_754_BINARY_64_PRECISION))

}
function typeMatch(type, list) {
if (Array.isArray(list)) {
for (var i = 0; i < list.length; i++) {
if (Types[list[i]] === type) return true;
}
return false;
} else {
return Boolean(list);
}
}

@@ -119,6 +119,6 @@ var BIT_16 = Math.pow(2, 16);

if (value <= BIT_16) {
if (value < BIT_16) {
this._allocate(3);
this._buffer[this._offset++] = 252;
} else if (value <= BIT_24) {
} else if (value < BIT_24) {
this._allocate(4);

@@ -135,3 +135,5 @@ this._buffer[this._offset++] = 253;

if (value <= BIT_16) return;
if (value < BIT_16) {
return;
}

@@ -141,3 +143,5 @@ // 24 Bit

if (value <= BIT_24) return;
if (value < BIT_24) {
return;
}

@@ -144,0 +148,0 @@ this._buffer[this._offset++] = (value >> 24) & 0xff;

@@ -141,3 +141,3 @@ var Parser = require('./Parser');

// Long stack trace support
sequence._callSite = sequence._callSite || new Error;
sequence._callSite = sequence._callSite || new Error();
}

@@ -434,3 +434,3 @@

if (this._connection.state !== "disconnected") {
if (this._connection.state !== 'disconnected') {
if(!this._ended) {

@@ -437,0 +437,0 @@ this.end();

@@ -43,3 +43,3 @@ var Sequence = require('./Sequence');

if (!serverSSLSupport) {
var err = new Error('Server does not support secure connnection');
var err = new Error('Server does not support secure connection');

@@ -46,0 +46,0 @@ err.code = 'HANDSHAKE_NO_SSL_SUPPORT';

@@ -18,3 +18,3 @@ var Sequence = require('./Sequence');

Ping.prototype.start = function() {
this.emit('packet', new Packets.ComPingPacket);
this.emit('packet', new Packets.ComPingPacket());
};

@@ -37,3 +37,3 @@ var Sequence = require('./Sequence');

// Then this is a RowDataPacket with an empty string in the first column.
// See: https://github.com/felixge/node-mysql/issues/222
// See: https://github.com/mysqljs/mysql/issues/222
} else if (this._resultSet && this._resultSet.resultSetHeaderPacket

@@ -166,3 +166,2 @@ && this._resultSet.resultSetHeaderPacket.fieldCount !== null) {

this.on('pause', function () {

@@ -169,0 +168,0 @@ localStream.pause();

@@ -17,3 +17,3 @@ var Sequence = require('./Sequence');

Quit.prototype.start = function() {
this.emit('packet', new Packets.ComQuitPacket);
this.emit('packet', new Packets.ComQuitPacket());
};

@@ -6,2 +6,3 @@ var Util = require('util');

// istanbul ignore next: Node.js < 0.10 not covered
var listenerCount = EventEmitter.listenerCount

@@ -8,0 +9,0 @@ || function(emitter, type){ return emitter.listeners(type).length; };

@@ -17,3 +17,3 @@ var Sequence = require('./Sequence');

Statistics.prototype.start = function() {
this.emit('packet', new Packets.ComStatisticsPacket);
this.emit('packet', new Packets.ComStatisticsPacket());
};

@@ -20,0 +20,0 @@

{
"name": "mysql",
"description": "A node.js driver for mysql. It is written in JavaScript, does not require compiling, and is 100% MIT licensed.",
"version": "2.11.1",
"version": "2.12.0",
"license": "MIT",

@@ -13,13 +13,12 @@ "author": "Felix Geisendörfer <felix@debuggable.com> (http://debuggable.com/)",

],
"homepage": "https://github.com/felixge/node-mysql",
"repository": "felixge/node-mysql",
"repository": "mysqljs/mysql",
"dependencies": {
"bignumber.js": "2.3.0",
"bignumber.js": "2.4.0",
"readable-stream": "1.1.14",
"sqlstring": "2.0.1"
"sqlstring": "2.2.0"
},
"devDependencies": {
"after": "0.8.1",
"eslint": "2.11.1",
"istanbul": "0.4.3",
"after": "0.8.2",
"eslint": "3.9.1",
"istanbul": "0.4.5",
"require-all": "2.0.0",

@@ -43,3 +42,3 @@ "rimraf": "2.2.8",

"scripts": {
"lint": "eslint lib/**/*.js index.js test/**/*.js",
"lint": "eslint lib/**/*.js index.js test/**/*.js tool/**/*.js",
"test": "node test/run.js",

@@ -46,0 +45,0 @@ "test-ci": "node test/run-cov.js lcovonly",

@@ -51,2 +51,3 @@ # mysql

- [Debugging and reporting problems](#debugging-and-reporting-problems)
- [Contributing](#contributing)
- [Running tests](#running-tests)

@@ -67,6 +68,6 @@ - [Todo](#todo)

```sh
$ npm install felixge/node-mysql
$ npm install mysqljs/mysql
```
[v0.9 branch]: https://github.com/felixge/node-mysql/tree/v0.9
[v0.9 branch]: https://github.com/mysqljs/mysql/tree/v0.9

@@ -111,3 +112,3 @@ ## Introduction

[GitHub Contributors page]: https://github.com/felixge/node-mysql/graphs/contributors
[GitHub Contributors page]: https://github.com/mysqljs/mysql/graphs/contributors

@@ -134,7 +135,2 @@ Additionally I'd like to thank the following people:

If you are interested in sponsoring a day or more of my time, please
[get in touch][].
[get in touch]: http://felixge.de/#consulting
## Community

@@ -207,3 +203,3 @@

* `stringifyObjects`: Stringify objects instead of converting to values. See
issue [#501](https://github.com/felixge/node-mysql/issues/501). (Default: `'false'`)
issue [#501](https://github.com/mysqljs/mysql/issues/501). (Default: `false`)
* `insecureAuth`: Allow connecting to MySQL instances that ask for the old

@@ -223,4 +219,6 @@ (insecure) authentication method. (Default: `false`)

* `dateStrings`: Force date types (TIMESTAMP, DATETIME, DATE) to be returned as strings rather then
inflated into JavaScript Date objects. (Default: `false`)
* `debug`: Prints protocol details to stdout. (Default: `false`)
inflated into JavaScript Date objects. Can be `true`/`false` or an array of type names to keep as
strings. (Default: `false`)
* `debug`: Prints protocol details to stdout. Can be `true`/`false` or an array of packet type names
that should be printed. (Default: `false`)
* `trace`: Generates stack traces on `Error` to include call site of library

@@ -313,2 +311,6 @@ entrance ("long stack traces"). Slight performance penalty for most calls.

Rather than creating and managing connections one-by-one, this module also
provides built-in connection pooling using `mysql.createPool(config)`.
[Read more about connection pooling](https://en.wikipedia.org/wiki/Connection_pool).
Use pool directly.

@@ -482,2 +484,3 @@ ```js

pool.getConnection(function (err, connection) {});
pool.query(function (err, result) {});

@@ -553,3 +556,3 @@ // close all connections

The most basic way to perform a query is to call the `.query()` method on an object
(like a `Connection` or `Pool` instance).
(like a `Connection`, `Pool`, or `PoolNamespace` instance).

@@ -711,7 +714,14 @@ The simplest form of .`query()` is `.query(sqlString, callback)`, where a SQL string

var sql = 'SELECT * FROM posts ORDER BY ' + connection.escapeId('posts.' + sorter);
connection.query(sql, function(err, results) {
// ...
});
// -> SELECT * FROM posts ORDER BY `posts`.`date`
```
If you do not want to treat `.` as qualified identifiers, you can set the second
argument to `true` in order to keep the string as a literal identifier:
```js
var sorter = 'date.2';
var sql = 'SELECT * FROM posts ORDER BY ' + connection.escapeId(sorter, true);
// -> SELECT * FROM posts ORDER BY `date.2`
```
Alternatively, you can use `??` characters as placeholders for identifiers you would

@@ -1234,3 +1244,3 @@ like to have escaped like this:

```
__WARNING: YOU MUST INVOKE the parser using one of these three field functions in your custom typeCast callback. They can only be called once. (see [#539](https://github.com/felixge/node-mysql/issues/539) for discussion)__
__WARNING: YOU MUST INVOKE the parser using one of these three field functions in your custom typeCast callback. They can only be called once. (see [#539](https://github.com/mysqljs/mysql/issues/539) for discussion)__

@@ -1248,3 +1258,3 @@ ```

```
__You can find which field function you need to use by looking at: [RowDataPacket.prototype._typeCast](https://github.com/felixge/node-mysql/blob/master/lib/protocol/packets/RowDataPacket.js#L41)__
__You can find which field function you need to use by looking at: [RowDataPacket.prototype._typeCast](https://github.com/mysqljs/mysql/blob/master/lib/protocol/packets/RowDataPacket.js#L41)__

@@ -1334,2 +1344,27 @@

## Contributing
This project welcomes contributions from the community. Contributions are
accepted using GitHub pull requests. If you're not familiar with making
GitHub pull requests, please refer to the
[GitHub documentation "Creating a pull request"](https://help.github.com/articles/creating-a-pull-request/).
For a good pull request, we ask you provide the following:
1. Try to include a clear description of your pull request in the description.
It should include the basic "what" and "why"s for the request.
2. The tests should pass as best as you can. See the [Running tests](#running-tests)
section on hwo to run the different tests. GitHub will automatically run
the tests as well, to act as a safety net.
3. The pull request should include tests for the change. A new feature should
have tests for the new feature and bug fixes should include a test that fails
without the corresponding code change and passes after they are applied.
The command `npm run test-cov` will generate a `coverage/` folder that
contains HTML pages of the code coverage, to better understand if everything
you're adding is being tested.
4. If the pull request is a new feature, please be sure to include all
appropriate documentation additions in the `Readme.md` file as well.
5. To help ensure that your code is similar in style to the existing code,
run the command `npm run lint` and fix any displayed issues.
## Running tests

@@ -1371,9 +1406,9 @@

[node-version-url]: https://nodejs.org/en/download/
[travis-image]: https://img.shields.io/travis/felixge/node-mysql/master.svg?label=linux
[travis-url]: https://travis-ci.org/felixge/node-mysql
[travis-image]: https://img.shields.io/travis/mysqljs/mysql/master.svg?label=linux
[travis-url]: https://travis-ci.org/mysqljs/mysql
[appveyor-image]: https://img.shields.io/appveyor/ci/dougwilson/node-mysql/master.svg?label=windows
[appveyor-url]: https://ci.appveyor.com/project/dougwilson/node-mysql
[coveralls-image]: https://img.shields.io/coveralls/felixge/node-mysql/master.svg
[coveralls-url]: https://coveralls.io/r/felixge/node-mysql?branch=master
[coveralls-image]: https://img.shields.io/coveralls/mysqljs/mysql/master.svg
[coveralls-url]: https://coveralls.io/r/mysqljs/mysql?branch=master
[downloads-image]: https://img.shields.io/npm/dm/mysql.svg
[downloads-url]: https://npmjs.org/package/mysql

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc