Skip to content

Commit

Permalink
Update tarn.js (#3345)
Browse files Browse the repository at this point in the history
* Update tarn.js
* Remove beforeDestroy
  • Loading branch information
kibertoad committed Jul 11, 2019
1 parent 9aa7085 commit fb06464
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Master (Unreleased)

### Changes:

- Config: `beforeDestroy` configuration option was removed

# 0.18.4 - 10 July, 2019

### New features:
Expand Down
5 changes: 5 additions & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## Upgrading to new knex.js versions

### Upgrading to version 0.19.0+

* Passing unknown properties to connection pool configuration now throws errors (see https://github.com/Vincit/tarn.js/issues/19 for details);
* `beforeDestroy` pool configuration option was removed. You should use tarn.js event handlers if you still need similar functionality.

### Upgrading to version 0.18.0+

* Node.js older than 8 is no longer supported, make sure to update your environment;
Expand Down
19 changes: 9 additions & 10 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,15 +266,6 @@ Object.assign(Client.prototype, {
},

destroy: (connection) => {
if (poolConfig.beforeDestroy) {
this.logger.warn(`
beforeDestroy is deprecated, please open an issue if you use this
to discuss alternative apis
`);

poolConfig.beforeDestroy(connection, function() {});
}

if (connection !== void 0) {
return this.destroyRawConnection(connection);
}
Expand All @@ -297,7 +288,15 @@ Object.assign(Client.prototype, {
return;
}

this.pool = new Pool(this.getPoolSettings(config.pool));
const tarnPoolConfig = {
...this.getPoolSettings(config.pool),
};
// afterCreate is an internal knex param, tarn.js does not support it
if (tarnPoolConfig.afterCreate) {
delete tarnPoolConfig.afterCreate;
}

this.pool = new Pool(tarnPoolConfig);
},

validateConnection(connection) {
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "knex",
"version": "0.18.4",
"version": "0.19.0",
"description": "A batteries-included SQL query & schema builder for Postgres, MySQL and SQLite3 and the Browser",
"main": "knex.js",
"types": "types/index.d.ts",
Expand All @@ -14,7 +14,6 @@
"coveralls": "nyc report --reporter=text-lcov | coveralls",
"lint": "eslint \"lib/**/*.js\" \"test/**/*.js\"",
"lint:types": "dtslint types",
"pretest": "npm run lint && npm run lint:types",
"test": "mocha --exit -t 10000 test/index.js && npm run test:tape && npm run test:cli",
"test:nyc": "nyc mocha --exit --check-leaks --globals __core-js_shared__ -t 10000 test/index.js && npm run test:tape && npm run test:cli",
"test:sqlite": "cross-env DB=sqlite3 npm test",
Expand All @@ -38,7 +37,7 @@
"lodash": "^4.17.14",
"mkdirp": "^0.5.1",
"pg-connection-string": "2.0.0",
"tarn": "^1.1.5",
"tarn": "^2.0.0",
"tildify": "2.0.0",
"uuid": "^3.3.2",
"v8flags": "^3.1.3"
Expand Down
2 changes: 1 addition & 1 deletion test/unit/seed/seeder.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ describe('Seeder._waterfallBatch', function() {
it('should throw an error with correct file name', (done) => {
seeder._waterfallBatch(['1-first.js', '2-second.js']).catch((error) => {
expect(error.message).to.match(
/^Error while executing "(\/\w+)+\/1-first\.js" seed: throwing in first file$/
/^Error while executing .*1-first.js" seed: throwing in first file$/
);
done();
});
Expand Down
1 change: 0 additions & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1742,7 +1742,6 @@ declare namespace Knex {
create?: Function;
afterCreate?: Function;
destroy?: Function;
beforeDestroy?: Function;
min?: number;
max?: number;
refreshIdle?: boolean;
Expand Down

0 comments on commit fb06464

Please sign in to comment.