Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: brianc/node-postgres
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v7.14.0
Choose a base ref
...
head repository: brianc/node-postgres
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: pg@7.15.0
Choose a head ref
  • 7 commits
  • 125 files changed
  • 3 contributors

Commits on Nov 20, 2019

  1. Add PostgreSQL 10 to CI (#1947)

    * Exit with error code when create-test-tables fails
    
    * Add PostgreSQL 10 to CI
    
    and change to Ubuntu 18.04 so building OpenSSL isn’t necessary, and move old PostgreSQL version tests to the latest Node LTS.
    
    * Add Node 13 to CI
    
    * Preserve create-test-tables’s compatibility with PostgreSQL <9.4
    charmander authored and brianc committed Nov 20, 2019
    Copy the full SHA
    8f56b8c View commit details

Commits on Dec 12, 2019

  1. Clear connection timeout on error (#2015)

    Cancel the connection timeout upon stream error, to avoid getting a stream error followed later by a connection error.
    adam-nielsen authored and brianc committed Dec 12, 2019
    Copy the full SHA
    b03a3bd View commit details
  2. Remove unreachable branch in parseE (#2020)

    The message is created with a fixed name.
    
    56b7c41, released in pg 2.4.0, was when this became applicable and the type of a `notice` event’s argument changed to an Error.
    charmander authored and brianc committed Dec 12, 2019
    Copy the full SHA
    c1f954b View commit details

Commits on Dec 17, 2019

  1. Warn when functions intended as constructors are called without new (#…

    …2021)
    
    * Warn when pg.Pool() isn’t called as a constructor
    
    in preparation for #1541. `eval` is a bit awkward, but it’s more accurate than an `instanceof` check and will work on platforms new enough to support pg 8 (i.e. only not Node 4).
    
    * Warn when Query() isn’t called as a constructor
    charmander authored and brianc committed Dec 17, 2019
    Copy the full SHA
    2b59209 View commit details
  2. Monorepo (#2014)

    * First crack at monorepo
    
    * Update test command
    
    * Update path to script
    
    * Remove node 6 from CI
    brianc authored Dec 17, 2019
    Copy the full SHA
    1b5f3e3 View commit details
  3. Update changelog

    brianc committed Dec 17, 2019
    Copy the full SHA
    7feaafd View commit details
  4. Publish

     - pg@7.15.0
    brianc committed Dec 17, 2019
    Copy the full SHA
    ebb81db View commit details
Showing with 5,661 additions and 190 deletions.
  1. +29 −32 .travis.yml
  2. +5 −0 CHANGELOG.md
  3. +0 −9 ci_scripts/build.sh
  4. +0 −38 ci_scripts/install_libpq.sh
  5. +0 −35 ci_scripts/install_openssl.sh
  6. +8 −0 lerna.json
  7. +12 −48 package.json
  8. 0 { → packages/pg}/Makefile
  9. +1 −0 { → packages/pg}/lib/client.js
  10. +22 −0 packages/pg/lib/compat/check-constructor.js
  11. +19 −0 packages/pg/lib/compat/warn-deprecation.js
  12. 0 { → packages/pg}/lib/connection-parameters.js
  13. +8 −16 { → packages/pg}/lib/connection.js
  14. 0 { → packages/pg}/lib/defaults.js
  15. +4 −0 { → packages/pg}/lib/index.js
  16. 0 { → packages/pg}/lib/native/client.js
  17. 0 { → packages/pg}/lib/native/index.js
  18. 0 { → packages/pg}/lib/native/query.js
  19. +4 −1 { → packages/pg}/lib/query.js
  20. 0 { → packages/pg}/lib/result.js
  21. 0 { → packages/pg}/lib/sasl.js
  22. 0 { → packages/pg}/lib/type-overrides.js
  23. 0 { → packages/pg}/lib/utils.js
  24. +54 −0 packages/pg/package.json
  25. +31 −11 { → packages/pg}/script/create-test-tables.js
  26. 0 { → packages/pg}/script/dump-db-types.js
  27. 0 { → packages/pg}/script/list-db-types.js
  28. 0 { → packages/pg}/test/buffer-list.js
  29. 0 { → packages/pg}/test/cli.js
  30. 0 { → packages/pg}/test/integration/client/api-tests.js
  31. 0 { → packages/pg}/test/integration/client/appname-tests.js
  32. 0 { → packages/pg}/test/integration/client/array-tests.js
  33. 0 { → packages/pg}/test/integration/client/big-simple-query-tests.js
  34. 0 { → packages/pg}/test/integration/client/configuration-tests.js
  35. 0 { → packages/pg}/test/integration/client/connection-timeout-tests.js
  36. 0 { → packages/pg}/test/integration/client/custom-types-tests.js
  37. 0 { → packages/pg}/test/integration/client/empty-query-tests.js
  38. 0 { → packages/pg}/test/integration/client/error-handling-tests.js
  39. 0 { → packages/pg}/test/integration/client/field-name-escape-tests.js
  40. 0 { → packages/pg}/test/integration/client/huge-numeric-tests.js
  41. 0 { → packages/pg}/test/integration/client/json-type-parsing-tests.js
  42. 0 { → packages/pg}/test/integration/client/multiple-results-tests.js
  43. 0 { → packages/pg}/test/integration/client/network-partition-tests.js
  44. 0 { → packages/pg}/test/integration/client/no-data-tests.js
  45. 0 { → packages/pg}/test/integration/client/no-row-result-tests.js
  46. 0 { → packages/pg}/test/integration/client/notice-tests.js
  47. 0 { → packages/pg}/test/integration/client/parse-int-8-tests.js
  48. 0 { → packages/pg}/test/integration/client/prepared-statement-tests.js
  49. 0 { → packages/pg}/test/integration/client/promise-api-tests.js
  50. 0 { → packages/pg}/test/integration/client/query-as-promise-tests.js
  51. 0 { → packages/pg}/test/integration/client/query-column-names-tests.js
  52. 0 { → packages/pg}/test/integration/client/query-error-handling-prepared-statement-tests.js
  53. 0 { → packages/pg}/test/integration/client/query-error-handling-tests.js
  54. 0 { → packages/pg}/test/integration/client/quick-disconnect-tests.js
  55. 0 { → packages/pg}/test/integration/client/result-metadata-tests.js
  56. 0 { → packages/pg}/test/integration/client/results-as-array-tests.js
  57. 0 { → packages/pg}/test/integration/client/row-description-on-results-tests.js
  58. 0 { → packages/pg}/test/integration/client/sasl-scram-tests.js
  59. 0 { → packages/pg}/test/integration/client/simple-query-tests.js
  60. 0 { → packages/pg}/test/integration/client/ssl-tests.js
  61. 0 { → packages/pg}/test/integration/client/statement_timeout-tests.js
  62. 0 { → packages/pg}/test/integration/client/test-helper.js
  63. 0 { → packages/pg}/test/integration/client/timezone-tests.js
  64. 0 { → packages/pg}/test/integration/client/transaction-tests.js
  65. 0 { → packages/pg}/test/integration/client/type-coercion-tests.js
  66. 0 { → packages/pg}/test/integration/client/type-parser-override-tests.js
  67. 0 { → packages/pg}/test/integration/connection-pool/connection-pool-size-tests.js
  68. 0 { → packages/pg}/test/integration/connection-pool/error-tests.js
  69. 0 { → packages/pg}/test/integration/connection-pool/idle-timeout-tests.js
  70. 0 { → packages/pg}/test/integration/connection-pool/native-instance-tests.js
  71. 0 { → packages/pg}/test/integration/connection-pool/test-helper.js
  72. 0 { → packages/pg}/test/integration/connection-pool/yield-support-tests.js
  73. 0 { → packages/pg}/test/integration/connection/bound-command-tests.js
  74. 0 { → packages/pg}/test/integration/connection/copy-tests.js
  75. 0 { → packages/pg}/test/integration/connection/dynamic-password.js
  76. 0 { → packages/pg}/test/integration/connection/notification-tests.js
  77. 0 { → packages/pg}/test/integration/connection/query-tests.js
  78. 0 { → packages/pg}/test/integration/connection/test-helper.js
  79. 0 { → packages/pg}/test/integration/domain-tests.js
  80. 0 { → packages/pg}/test/integration/gh-issues/130-tests.js
  81. 0 { → packages/pg}/test/integration/gh-issues/131-tests.js
  82. 0 { → packages/pg}/test/integration/gh-issues/1382-tests.js
  83. 0 { → packages/pg}/test/integration/gh-issues/1854-tests.js
  84. 0 { → packages/pg}/test/integration/gh-issues/199-tests.js
  85. 0 { → packages/pg}/test/integration/gh-issues/507-tests.js
  86. 0 { → packages/pg}/test/integration/gh-issues/600-tests.js
  87. 0 { → packages/pg}/test/integration/gh-issues/675-tests.js
  88. 0 { → packages/pg}/test/integration/gh-issues/699-tests.js
  89. 0 { → packages/pg}/test/integration/gh-issues/787-tests.js
  90. 0 { → packages/pg}/test/integration/gh-issues/882-tests.js
  91. 0 { → packages/pg}/test/integration/gh-issues/981-tests.js
  92. 0 { → packages/pg}/test/integration/test-helper.js
  93. 0 { → packages/pg}/test/native/callback-api-tests.js
  94. 0 { → packages/pg}/test/native/evented-api-tests.js
  95. 0 { → packages/pg}/test/native/missing-native.js
  96. 0 { → packages/pg}/test/native/native-vs-js-error-tests.js
  97. 0 { → packages/pg}/test/native/stress-tests.js
  98. 0 { → packages/pg}/test/suite.js
  99. 0 { → packages/pg}/test/test-buffers.js
  100. 0 { → packages/pg}/test/test-helper.js
  101. 0 { → packages/pg}/test/unit/client/cleartext-password-tests.js
  102. 0 { → packages/pg}/test/unit/client/configuration-tests.js
  103. 0 { → packages/pg}/test/unit/client/early-disconnect-tests.js
  104. 0 { → packages/pg}/test/unit/client/escape-tests.js
  105. 0 { → packages/pg}/test/unit/client/md5-password-tests.js
  106. 0 { → packages/pg}/test/unit/client/notification-tests.js
  107. 0 { → packages/pg}/test/unit/client/prepared-statement-tests.js
  108. 0 { → packages/pg}/test/unit/client/query-queue-tests.js
  109. 0 { → packages/pg}/test/unit/client/result-metadata-tests.js
  110. 0 { → packages/pg}/test/unit/client/sasl-scram-tests.js
  111. 0 { → packages/pg}/test/unit/client/set-keepalives.js
  112. 0 { → packages/pg}/test/unit/client/simple-query-tests.js
  113. 0 { → packages/pg}/test/unit/client/stream-and-query-error-interaction-tests.js
  114. 0 { → packages/pg}/test/unit/client/test-helper.js
  115. 0 { → packages/pg}/test/unit/client/throw-in-type-parser-tests.js
  116. 0 { → packages/pg}/test/unit/connection-parameters/creation-tests.js
  117. 0 { → packages/pg}/test/unit/connection-parameters/environment-variable-tests.js
  118. 0 { → packages/pg}/test/unit/connection/error-tests.js
  119. 0 { → packages/pg}/test/unit/connection/inbound-parser-tests.js
  120. 0 { → packages/pg}/test/unit/connection/outbound-sending-tests.js
  121. 0 { → packages/pg}/test/unit/connection/startup-tests.js
  122. 0 { → packages/pg}/test/unit/connection/test-helper.js
  123. 0 { → packages/pg}/test/unit/test-helper.js
  124. 0 { → packages/pg}/test/unit/utils-tests.js
  125. +5,464 −0 yarn.lock
61 changes: 29 additions & 32 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,50 +1,47 @@
language: node_js
sudo: true
dist: trusty
dist: bionic

before_script:
- node script/create-test-tables.js pg://postgres@127.0.0.1:5432/postgres

before_install:
- if [ $TRAVIS_OS_NAME == "linux" ]; then
if [[ $(node -v) =~ v[1-9][0-9] ]]; then
source ./ci_scripts/build.sh;
fi
fi

- node packages/pg/script/create-test-tables.js pg://postgres@127.0.0.1:5432/postgres

env:
- CC=clang CXX=clang++ npm_config_clang=1 PGUSER=postgres PGDATABASE=postgres

node_js:
- lts/dubnium
- lts/erbium
- 13

addons:
postgresql: "10"

matrix:
include:
- node_js: "lts/boron"
addons:
postgresql: "9.6"
- node_js: "lts/argon"
addons:
postgresql: "9.6"
- node_js: "10"
addons:
postgresql: "9.6"
- node_js: "12"
- node_js: lts/carbon
addons:
postgresql: "9.6"
- node_js: "lts/carbon"
addons:
postgresql: "9.1"
postgresql: "9.5"
dist: precise
- node_js: "lts/carbon"
addons:
postgresql: "9.2"
- node_js: "lts/carbon"

# different PostgreSQL versions on Node LTS
- node_js: lts/erbium
addons:
postgresql: "9.3"
- node_js: "lts/carbon"
- node_js: lts/erbium
addons:
postgresql: "9.4"
- node_js: "lts/carbon"
- node_js: lts/erbium
addons:
postgresql: "9.5"
- node_js: "lts/carbon"
- node_js: lts/erbium
addons:
postgresql: "9.6"

# PostgreSQL 9.1 and 9.2 only work on precise
- node_js: lts/carbon
addons:
postgresql: "9.1"
dist: precise
- node_js: lts/carbon
addons:
postgresql: "9.2"
dist: precise
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -4,6 +4,11 @@ For richer information consult the commit log on github with referenced pull req

We do not include break-fix version release in this file.

### 7.15.0

- Change repository structure to support lerna & future monorepo [development](https://github.com/brianc/node-postgres/pull/2014).
- [Warn about deprecation](https://github.com/brianc/node-postgres/pull/2021) for calling constructors without `new`.

### 7.14.0

- Reverts 7.13.0 as it contained [an accidental breaking change](https://github.com/brianc/node-postgres/pull/2010) for self-signed SSL cert verification. 7.14.0 is identical to 7.12.1.
9 changes: 0 additions & 9 deletions ci_scripts/build.sh

This file was deleted.

38 changes: 0 additions & 38 deletions ci_scripts/install_libpq.sh

This file was deleted.

35 changes: 0 additions & 35 deletions ci_scripts/install_openssl.sh

This file was deleted.

8 changes: 8 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"packages": [
"packages/*"
],
"npmClient": "yarn",
"useWorkspaces": true,
"version": "independent"
}
60 changes: 12 additions & 48 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,54 +1,18 @@
{
"name": "pg",
"version": "7.14.0",
"description": "PostgreSQL client - pure javascript & libpq with the same API",
"keywords": [
"database",
"libpq",
"pg",
"postgre",
"postgres",
"postgresql",
"rdbms"
"name": "node-postgres",
"description": "node postgres monorepo",
"main": "index.js",
"private": true,
"repository": "git@github.com:brianc/node-postgres.git",
"author": "Brian M. Carlson <brian.m.carlson@gmail.com>",
"license": "MIT",
"workspaces": [
"packages/*"
],
"homepage": "http://github.com/brianc/node-postgres",
"repository": {
"type": "git",
"url": "git://github.com/brianc/node-postgres.git"
},
"author": "Brian Carlson <brian.m.carlson@gmail.com>",
"main": "./lib",
"dependencies": {
"buffer-writer": "2.0.0",
"packet-reader": "1.0.0",
"pg-connection-string": "0.1.3",
"pg-pool": "^2.0.7",
"pg-types": "^2.1.0",
"pgpass": "1.x",
"semver": "4.3.2"
},
"devDependencies": {
"async": "0.9.0",
"bluebird": "3.5.2",
"co": "4.6.0",
"eslint": "^6.0.1",
"eslint-config-standard": "^13.0.1",
"eslint-plugin-import": "^2.18.1",
"eslint-plugin-node": "^9.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.0",
"pg-copy-streams": "0.3.0"
},
"minNativeVersion": "2.0.0",
"scripts": {
"test": "make test-all"
"test": "yarn lerna exec --parallel yarn test"
},
"files": [
"lib",
"SPONSORS.md"
],
"license": "MIT",
"engines": {
"node": ">= 4.5.0"
"devDependencies": {
"lerna": "^3.19.0"
}
}
File renamed without changes.
1 change: 1 addition & 0 deletions lib/client.js → packages/pg/lib/client.js
Original file line number Diff line number Diff line change
@@ -251,6 +251,7 @@ Client.prototype._connect = function (callback) {
? new Error('Connection terminated')
: new Error('Connection terminated unexpectedly')

clearTimeout(connectionTimeoutHandle)
this._errorAllQueries(error)

if (!this._ending) {
22 changes: 22 additions & 0 deletions packages/pg/lib/compat/check-constructor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict'

const warnDeprecation = require('./warn-deprecation')

// Node 4 doesn’t support new.target.
let hasNewTarget

try {
// eslint-disable-next-line no-eval
eval('(function () { new.target })')
hasNewTarget = true
} catch (error) {
hasNewTarget = false
}

const checkConstructor = (name, code, getNewTarget) => {
if (hasNewTarget && getNewTarget() === undefined) {
warnDeprecation(`Constructing a ${name} without new is deprecated and will stop working in pg 8.`, code)
}
}

module.exports = checkConstructor
19 changes: 19 additions & 0 deletions packages/pg/lib/compat/warn-deprecation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
'use strict'

const util = require('util')

const dummyFunctions = new Map()

// Node 4 doesn’t support process.emitWarning(message, 'DeprecationWarning', code).
const emitDeprecationWarning = (message, code) => {
let dummy = dummyFunctions.get(code)

if (dummy === undefined) {
dummy = util.deprecate(() => {}, message)
dummyFunctions.set(code, dummy)
}

dummy()
}

module.exports = emitDeprecationWarning
File renamed without changes.
24 changes: 8 additions & 16 deletions lib/connection.js → packages/pg/lib/connection.js
Original file line number Diff line number Diff line change
@@ -594,27 +594,19 @@ Connection.prototype._readValue = function (buffer) {
// parses error
Connection.prototype.parseE = function (buffer, length) {
var fields = {}
var msg, item
var input = new Message('error', length)
var fieldType = this.readString(buffer, 1)
while (fieldType !== '\0') {
fields[fieldType] = this.parseCString(buffer)
fieldType = this.readString(buffer, 1)
}
if (input.name === 'error') {
// the msg is an Error instance
msg = new Error(fields.M)
for (item in input) {
// copy input properties to the error
if (Object.prototype.hasOwnProperty.call(input, item)) {
msg[item] = input[item]
}
}
} else {
// the msg is an object literal
msg = input
msg.message = fields.M
}

// the msg is an Error instance
var msg = new Error(fields.M)

// for compatibility with Message
msg.name = 'error'
msg.length = length

msg.severity = fields.S
msg.code = fields.C
msg.detail = fields.D
File renamed without changes.
4 changes: 4 additions & 0 deletions lib/index.js → packages/pg/lib/index.js
Original file line number Diff line number Diff line change
@@ -12,9 +12,13 @@ var Client = require('./client')
var defaults = require('./defaults')
var Connection = require('./connection')
var Pool = require('pg-pool')
const checkConstructor = require('./compat/check-constructor')

const poolFactory = (Client) => {
var BoundPool = function (options) {
// eslint-disable-next-line no-eval
checkConstructor('pg.Pool', 'PG-POOL-NEW', () => eval('new.target'))

var config = Object.assign({ Client: Client }, options)
return new Pool(config)
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 4 additions & 1 deletion lib/query.js → packages/pg/lib/query.js
Original file line number Diff line number Diff line change
@@ -9,12 +9,15 @@

var EventEmitter = require('events').EventEmitter
var util = require('util')
const checkConstructor = require('./compat/check-constructor')

var Result = require('./result')
var utils = require('./utils')

var Query = function (config, values, callback) {
// use of "new" optional
// use of "new" optional in pg 7
// eslint-disable-next-line no-eval
checkConstructor('Query', 'PG-QUERY-NEW', () => eval('new.target'))
if (!(this instanceof Query)) { return new Query(config, values, callback) }

config = utils.normalizeQueryConfig(config, values, callback)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading