Skip to content

Commit

Permalink
Remove pool.releaseConnection method
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeFoodPixels committed Dec 8, 2020
1 parent 53a190c commit 6cd7cc6
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 34 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,8 @@ The options used to create a pool cluster. See [mysqljs/mysql documentation](htt

`poolCluster.on`: Add a listener to the pool cluster object. See [mysqljs/mysql documentation](https://github.com/mysqljs/mysql#poolcluster) for events that may be listened for.

## Upgrading from v3
## Upgrading from v3 to v4
The main difference is that `mysql.createPool` now returns a promise. Besides this, the API is the same and you should be able to upgrade straight to v4. The only other difference is the extra options in the [connectionOptions object](#connectionoptions-object).

## Upgrading from v4 to v5
The `pool.releaseConnection` has been removed, please use `poolConnection.release` instead.
5 changes: 0 additions & 5 deletions lib/pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ class pool {
});
}

releaseConnection(connection) {
//Use the underlying connection from the mysql-module here:
return this.pool.releaseConnection(connection.connection);
}

query() {
return promiseCallback.apply(this.pool, ['query', arguments, this.returnArgumentsArray]);
}
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "promise-mysql",
"version": "4.1.4",
"version": "5.0.0",
"description": "A bluebird wrapper for node-mysql",
"main": "index.js",
"scripts": {
Expand Down
26 changes: 0 additions & 26 deletions test/pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ sinon.addBehavior(`callsLastArgWith`, (fake, errVal, retVal) => {

const poolMock = {
getConnection: sinon.stub().callsLastArgWith(null, `getConnectionPromise`).returns(`getConnectionReturn`),
releaseConnection: sinon.stub().returns(`releaseConnectionReturn`),
query: sinon.stub().callsLastArgWith(null, `queryPromise`).returns(`queryReturn`),
end: sinon.stub().callsLastArgWith(null, `endPromise`).returns(`endReturn`),
escape: sinon.stub().returnsArg(0),
Expand All @@ -36,7 +35,6 @@ const pool = proxyquire(`../lib/pool.js`, {
tap.beforeEach((done) => {
createPool.resetHistory();
poolMock.getConnection.resetHistory();
poolMock.releaseConnection.resetHistory();
poolMock.query.resetHistory();
poolMock.end.resetHistory();
poolMock.escape.resetHistory();
Expand Down Expand Up @@ -230,30 +228,6 @@ tap.test(`calls the underlying methods`, (t) => {
});
});

t.test(`pool.releaseConnection should call the underlying releaseConnection method with the correct arguments`, (t) => {
const connection = {
connection: 'test'
}

const retVal = pool.releaseConnection(connection)

t.ok(poolMock.releaseConnection.calledOnce, `underlying releaseConnection method called`)
t.equal(
poolMock.releaseConnection.lastCall.args.length,
1,
`underlying releaseConnection called with correct number of arguments`
);
t.ok(poolMock.releaseConnection.calledWith(connection.connection));

t.same(
retVal,
`releaseConnectionReturn`,
`returns arguments`
);

t.end();
});

t.end();
});
})
Expand Down

0 comments on commit 6cd7cc6

Please sign in to comment.