From 7f2f3eba7b5331c2e1b4c8893bbe9a98e50bb696 Mon Sep 17 00:00:00 2001 From: Mickey Burks Date: Fri, 24 May 2019 20:17:12 -0700 Subject: [PATCH 1/4] Move native module to subdirectory --- lib/factory.js | 36 +++++++++++++++++++++++++++++++ lib/index.js | 52 +++------------------------------------------ lib/native/index.js | 5 ++++- package.json | 5 ++++- 4 files changed, 47 insertions(+), 51 deletions(-) create mode 100644 lib/factory.js diff --git a/lib/factory.js b/lib/factory.js new file mode 100644 index 000000000..a59e18d09 --- /dev/null +++ b/lib/factory.js @@ -0,0 +1,36 @@ +'use strict' +/** + * Copyright (c) 2010-2017 Brian Carlson (brian.m.carlson@gmail.com) + * All rights reserved. + * + * This source code is licensed under the MIT license found in the + * README.md file in the root directory of this source tree. + */ + +var util = require('util') +var defaults = require('./defaults') +var Connection = require('./connection') +var Pool = require('pg-pool') + +const poolFactory = (Client) => { + var BoundPool = function (options) { + var config = Object.assign({ Client: Client }, options) + return new Pool(config) + } + + util.inherits(BoundPool, Pool) + + return BoundPool +} + +const PG = function (clientConstructor) { + this.defaults = defaults + this.Client = clientConstructor + this.Query = this.Client.Query + this.Pool = poolFactory(this.Client) + this._pools = [] + this.Connection = Connection + this.types = require('pg-types') +} + +module.exports = PG; diff --git a/lib/index.js b/lib/index.js index 8e000a378..491f370b2 100644 --- a/lib/index.js +++ b/lib/index.js @@ -7,53 +7,7 @@ * README.md file in the root directory of this source tree. */ -var util = require('util') -var Client = require('./client') -var defaults = require('./defaults') -var Connection = require('./connection') -var Pool = require('pg-pool') +const Client = require('./client'); +const PG = require('./factory.js'); -const poolFactory = (Client) => { - var BoundPool = function (options) { - var config = Object.assign({ Client: Client }, options) - return new Pool(config) - } - - util.inherits(BoundPool, Pool) - - return BoundPool -} - -var PG = function (clientConstructor) { - this.defaults = defaults - this.Client = clientConstructor - this.Query = this.Client.Query - this.Pool = poolFactory(this.Client) - this._pools = [] - this.Connection = Connection - this.types = require('pg-types') -} - -if (typeof process.env.NODE_PG_FORCE_NATIVE !== 'undefined') { - module.exports = new PG(require('./native')) -} else { - module.exports = new PG(Client) - - // lazy require native module...the native module may not have installed - module.exports.__defineGetter__('native', function () { - delete module.exports.native - var native = null - try { - native = new PG(require('./native')) - } catch (err) { - if (err.code !== 'MODULE_NOT_FOUND') { - throw err - } - /* eslint-disable no-console */ - console.error(err.message) - /* eslint-enable no-console */ - } - module.exports.native = native - return native - }) -} +module.exports = new PG(Client) diff --git a/lib/native/index.js b/lib/native/index.js index eead422a3..9bfd48bf9 100644 --- a/lib/native/index.js +++ b/lib/native/index.js @@ -1,2 +1,5 @@ 'use strict' -module.exports = require('./client') + +const PG = require('../factory.js'); + +module.exports = new PG(require('./client')); diff --git a/package.json b/package.json index c7b3ce039..3cdf631a0 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "pg", + "name": "@micburks/pg", "version": "7.11.0", "description": "PostgreSQL client - pure javascript & libpq with the same API", "keywords": [ @@ -17,6 +17,9 @@ "url": "git://github.com/brianc/node-postgres.git" }, "author": "Brian Carlson ", + "contributors": [ + "Mickey Burks " + ], "main": "./lib", "dependencies": { "buffer-writer": "2.0.0", From 48f05058db979ee866e10bb560bd26e0e54ce2f0 Mon Sep 17 00:00:00 2001 From: Mickey Burks Date: Fri, 24 May 2019 20:17:29 -0700 Subject: [PATCH 2/4] 8.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3cdf631a0..71d4df66f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@micburks/pg", - "version": "7.11.0", + "version": "8.0.0", "description": "PostgreSQL client - pure javascript & libpq with the same API", "keywords": [ "database", From e100d85abb70aa0456ad755dc230ee34c14a35ab Mon Sep 17 00:00:00 2001 From: Mickey Burks Date: Fri, 24 May 2019 21:04:11 -0700 Subject: [PATCH 3/4] Reference forked pg-pool --- lib/factory.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index a59e18d09..c2c825f42 100644 --- a/lib/factory.js +++ b/lib/factory.js @@ -7,10 +7,10 @@ * README.md file in the root directory of this source tree. */ -var util = require('util') -var defaults = require('./defaults') -var Connection = require('./connection') -var Pool = require('pg-pool') +const util = require('util') +const defaults = require('./defaults') +const Connection = require('./connection') +const Pool = require('@micburks/pg-pool') const poolFactory = (Client) => { var BoundPool = function (options) { diff --git a/package.json b/package.json index 71d4df66f..d8416940f 100644 --- a/package.json +++ b/package.json @@ -22,10 +22,10 @@ ], "main": "./lib", "dependencies": { + "@micburks/pg-pool": "^3.0.0", "buffer-writer": "2.0.0", "packet-reader": "1.0.0", "pg-connection-string": "0.1.3", - "pg-pool": "^2.0.4", "pg-types": "~2.0.0", "pgpass": "1.x", "semver": "4.3.2" From 38c93582878e5472359c0ebace3d46ed668e1451 Mon Sep 17 00:00:00 2001 From: Mickey Burks Date: Fri, 24 May 2019 21:04:32 -0700 Subject: [PATCH 4/4] 8.0.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d8416940f..6c2238252 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@micburks/pg", - "version": "8.0.0", + "version": "8.0.1", "description": "PostgreSQL client - pure javascript & libpq with the same API", "keywords": [ "database",