From 8c606ff50eb23d63b67e97d0148c3e5a822caee3 Mon Sep 17 00:00:00 2001 From: Charmander <~@charmander.me> Date: Fri, 17 Jan 2020 08:49:06 -0800 Subject: [PATCH] =?UTF-8?q?Continue=20support=20for=20creating=20a=20pg.Po?= =?UTF-8?q?ol=20from=20another=20instance=E2=80=99s=20options=20(#2076)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add failing test for creating a `BoundPool` from another instance’s settings * Continue support for creating a pg.Pool from another instance’s options by dropping the requirement for the `password` property to be enumerable. --- packages/pg/lib/index.js | 3 +-- .../unit/connection-pool/configuration-tests.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 packages/pg/test/unit/connection-pool/configuration-tests.js diff --git a/packages/pg/lib/index.js b/packages/pg/lib/index.js index c3062947..c73064cf 100644 --- a/packages/pg/lib/index.js +++ b/packages/pg/lib/index.js @@ -15,8 +15,7 @@ var Pool = require('pg-pool') const poolFactory = (Client) => { return class BoundPool extends Pool { constructor (options) { - var config = Object.assign({ Client: Client }, options) - super(config) + super(options, Client) } } } diff --git a/packages/pg/test/unit/connection-pool/configuration-tests.js b/packages/pg/test/unit/connection-pool/configuration-tests.js new file mode 100644 index 00000000..10c99183 --- /dev/null +++ b/packages/pg/test/unit/connection-pool/configuration-tests.js @@ -0,0 +1,14 @@ +'use strict' + +const assert = require('assert') +const helper = require('../test-helper') + +test('pool with copied settings includes password', () => { + const original = new helper.pg.Pool({ + password: 'original', + }) + + const copy = new helper.pg.Pool(original.options) + + assert.equal(copy.options.password, 'original') +})