Socket
Socket
Sign inDemoInstall

mysql

Package Overview
Dependencies
Maintainers
9
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mysql - npm Package Compare versions

Comparing version 2.6.2 to 2.7.0

8

Changes.md

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

## v2.6.0 (2015-05-27)
* Destroy/end connections removed from the pool on error
* Delay implied connect until after `.query` argument validation
* Do not remove connections with non-fatal errors from the pool
* Error early if `callback` argument to `.query` is not a function #1060
* Lazy-load modules from many entry point; reduced memory use
## v2.6.2 (2015-04-14)

@@ -9,0 +17,0 @@

141

index.js

@@ -1,26 +0,137 @@

var Connection = require('./lib/Connection');
var ConnectionConfig = require('./lib/ConnectionConfig');
var Types = require('./lib/protocol/constants/types');
var SqlString = require('./lib/protocol/SqlString');
var Pool = require('./lib/Pool');
var PoolConfig = require('./lib/PoolConfig');
var PoolCluster = require('./lib/PoolCluster');
var Classes = Object.create(null);
exports.createConnection = function(config) {
/**
* Create a new Connection instance.
* @param {object} config
* @public
*/
exports.createConnection = function createConnection(config) {
var Connection = loadClass('Connection');
var ConnectionConfig = loadClass('ConnectionConfig');
return new Connection({config: new ConnectionConfig(config)});
};
exports.createPool = function(config) {
/**
* Create a new Pool instance.
* @param {object} config
* @public
*/
exports.createPool = function createPool(config) {
var Pool = loadClass('Pool');
var PoolConfig = loadClass('PoolConfig');
return new Pool({config: new PoolConfig(config)});
};
exports.createPoolCluster = function(config) {
/**
* Create a new PoolCluster instance.
* @param {object} config
* @public
*/
exports.createPoolCluster = function createPoolCluster(config) {
var PoolCluster = loadClass('PoolCluster');
return new PoolCluster(config);
};
exports.createQuery = Connection.createQuery;
/**
* Create a new Query instance.
* @public
*/
exports.createQuery = function createQuery(sql, values, callback) {
var Connection = loadClass('Connection');
exports.Types = Types;
exports.escape = SqlString.escape;
exports.escapeId = SqlString.escapeId;
exports.format = SqlString.format;
return Connection.createQuery(sql, values, callback);
};
/**
* Escape a value for SQL.
* @param {*} value
* @param {boolean} [stringifyObjects=false]
* @param {string} [timeZone=local]
* @public
*/
exports.escape = function escape(value, stringifyObjects, timeZone) {
var SqlString = loadClass('SqlString');
return SqlString.escape(value, stringifyObjects, timeZone);
};
/**
* Escape an identifier for SQL.
* @param {*} value
* @param {boolean} [forbidQualified]
* @public
*/
exports.escapeId = function escapeId(value, forbidQualified) {
var SqlString = loadClass('SqlString');
return SqlString.escapeId(value, forbidQualified);
};
/**
* Format SQL and replacement values into a SQL string.
* @param {string} sql
* @param {array} [values]
* @param {boolean} [stringifyObjects=false]
* @param {string} [timeZone=local]
* @public
*/
exports.format = function format(sql, values, stringifyObjects, timeZone) {
var SqlString = loadClass('SqlString');
return SqlString.format(sql, values, stringifyObjects, timeZone);
};
/**
* The type constants.
* @public
*/
Object.defineProperty(exports, 'Types', {
get: loadClass.bind(null, 'Types')
});
/**
* Load the given class.
* @private
*/
function loadClass(className) {
var Class = Classes[className];
if (Class !== undefined) {
return Class;
}
// This uses a switch for static require analysis
switch (className) {
case 'Connection':
Class = require('./lib/Connection');
break;
case 'ConnectionConfig':
Class = require('./lib/ConnectionConfig');
break;
case 'Pool':
Class = require('./lib/Pool');
break;
case 'PoolCluster':
Class = require('./lib/PoolCluster');
break;
case 'PoolConfig':
Class = require('./lib/PoolConfig');
break;
case 'SqlString':
Class = require('./lib/protocol/SqlString');
break;
case 'Types':
Class = require('./lib/protocol/constants/types');
break;
default:
throw new Error('Cannot find class \'' + className + '\'');
}
// Store to prevent invoking require()
Classes[className] = Class;
return Class;
}

10

lib/Connection.js

@@ -70,2 +70,6 @@ var Crypto = require('crypto');

if (cb === undefined && callback !== undefined) {
throw new TypeError('argument callback must be a function when provided');
}
return new Query(options, cb);

@@ -184,5 +188,3 @@ };

Connection.prototype.query = function(sql, values, cb) {
this._implyConnect();
Connection.prototype.query = function query(sql, values, cb) {
var query = Connection.createQuery(sql, values, cb);

@@ -199,2 +201,4 @@ query._connection = this;

this._implyConnect();
return this._protocol._enqueue(query);

@@ -201,0 +205,0 @@ };

@@ -17,3 +17,7 @@ var inherits = require('util').inherits;

this.on('end', this._removeFromPool);
this.on('error', this._removeFromPool);
this.on('error', function (err) {
if (err.fatal) {
this._removeFromPool();
}
});
}

@@ -54,3 +58,3 @@

PoolConnection.prototype._removeFromPool = function(connection) {
PoolConnection.prototype._removeFromPool = function _removeFromPool() {
if (!this._pool || this._pool._closed) {

@@ -63,3 +67,3 @@ return;

pool._removeConnection(this);
pool._purgeConnection(this);
};
{
"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.6.2",
"version": "2.7.0",
"license": "MIT",

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

@@ -127,3 +127,3 @@ # mysql

* [pinkbike.com](http://pinkbike.com/)
* [Holiday Extras](http://www.holidayextras.co.uk/) (they are [hiring](http://join.holidayextras.co.uk/vacancy/software-engineer/))
* [Holiday Extras](http://www.holidayextras.co.uk/) (they are [hiring](http://join.holidayextras.co.uk/vacancy/software-engineer-5/))
* [Newscope](http://newscope.com/) (they are [hiring](http://www.newscope.com/stellenangebote))

@@ -485,3 +485,3 @@

* `restoreNodeTimeout`: If connection fails, specifies the number of milliseconds
before another connection attempt will be made. If set to `0`, then node will bd
before another connection attempt will be made. If set to `0`, then node will be
removed instead and never re-used. (Default: `0`)

@@ -1163,2 +1163,5 @@ * `defaultSelector`: The default selector. (Default: `RR`)

**Note** text in the binary character set is returned as `Buffer`, rather
than a string.
* CHAR

@@ -1233,3 +1236,3 @@ * VARCHAR

**Please note that some available flags that are not not supported (e.g.: Compression),
**Please note that some available flags that are not supported (e.g.: Compression),
are still not allowed to be specified.**

@@ -1236,0 +1239,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc