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: pg@8.2.2
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@8.3.0
Choose a head ref
  • 5 commits
  • 11 files changed
  • 2 contributors

Commits on May 14, 2020

  1. Support options connection parameter

    This supports the connection parameter documented here:
    https://www.postgresql.org/docs/9.1/libpq-connect.html#LIBPQ-CONNECT-OPTIONS
    rafiss committed May 14, 2020
    Copy the full SHA
    06cdf3e View commit details

Commits on Jul 8, 2020

  1. Merge pull request #2216 from rafiss/pgoptions

    Support options connection parameter
    brianc authored Jul 8, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    da5d4ef View commit details
  2. Add integration test for #2216

    brianc committed Jul 8, 2020
    Copy the full SHA
    3360697 View commit details
  3. Merge pull request #2269 from brianc/bmc/add-integration-test

    Add integration test for #2216
    brianc authored Jul 8, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    c22cc33 View commit details

Commits on Jul 9, 2020

  1. Publish

     - pg-connection-string@2.3.0
     - pg-cursor@2.3.0
     - pg-query-stream@3.2.0
     - pg@8.3.0
    brianc committed Jul 9, 2020
    Copy the full SHA
    cf20343 View commit details
1 change: 1 addition & 0 deletions packages/pg-connection-string/index.d.ts
Original file line number Diff line number Diff line change
@@ -11,4 +11,5 @@ export interface ConnectionOptions {

application_name?: string
fallback_application_name?: string
options?: string
}
2 changes: 1 addition & 1 deletion packages/pg-connection-string/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pg-connection-string",
"version": "2.2.3",
"version": "2.3.0",
"description": "Functions for dealing with a PostgresSQL connection string",
"main": "./index.js",
"types": "./index.d.ts",
6 changes: 3 additions & 3 deletions packages/pg-connection-string/test/parse.js
Original file line number Diff line number Diff line change
@@ -188,10 +188,10 @@ describe('parse', function () {
subject.fallback_application_name.should.equal('TheAppFallback')
})

it('configuration parameter fallback_application_name', function () {
var connectionString = 'pg:///?fallback_application_name=TheAppFallback'
it('configuration parameter options', function () {
var connectionString = 'pg:///?options=-c geqo=off'
var subject = parse(connectionString)
subject.fallback_application_name.should.equal('TheAppFallback')
subject.options.should.equal('-c geqo=off')
})

it('configuration parameter ssl=true', function () {
4 changes: 2 additions & 2 deletions packages/pg-cursor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pg-cursor",
"version": "2.2.2",
"version": "2.3.0",
"description": "Query cursor extension for node-postgres",
"main": "index.js",
"directories": {
@@ -17,6 +17,6 @@
"license": "MIT",
"devDependencies": {
"mocha": "^7.1.2",
"pg": "^8.2.2"
"pg": "^8.3.0"
}
}
6 changes: 3 additions & 3 deletions packages/pg-query-stream/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pg-query-stream",
"version": "3.1.2",
"version": "3.2.0",
"description": "Postgres query result returned as readable stream",
"main": "index.js",
"scripts": {
@@ -26,12 +26,12 @@
"concat-stream": "~1.0.1",
"eslint-plugin-promise": "^3.5.0",
"mocha": "^7.1.2",
"pg": "^8.2.2",
"pg": "^8.3.0",
"stream-spec": "~0.3.5",
"stream-tester": "0.0.5",
"through": "~2.3.4"
},
"dependencies": {
"pg-cursor": "^2.2.2"
"pg-cursor": "^2.3.0"
}
}
3 changes: 3 additions & 0 deletions packages/pg/lib/client.js
Original file line number Diff line number Diff line change
@@ -391,6 +391,9 @@ Client.prototype.getStartupConf = function () {
if (params.idle_in_transaction_session_timeout) {
data.idle_in_transaction_session_timeout = String(parseInt(params.idle_in_transaction_session_timeout, 10))
}
if (params.options) {
data.options = params.options
}

return data
}
2 changes: 2 additions & 0 deletions packages/pg/lib/connection-parameters.js
Original file line number Diff line number Diff line change
@@ -70,6 +70,7 @@ var ConnectionParameters = function (config) {
})

this.binary = val('binary', config)
this.options = val('options', config)

this.ssl = typeof config.ssl === 'undefined' ? readSSLConfigFromEnvironment() : config.ssl

@@ -126,6 +127,7 @@ ConnectionParameters.prototype.getLibpqConnectionString = function (cb) {
add(params, this, 'application_name')
add(params, this, 'fallback_application_name')
add(params, this, 'connect_timeout')
add(params, this, 'options')

var ssl = typeof this.ssl === 'object' ? this.ssl : this.ssl ? { sslmode: this.ssl } : {}
add(params, ssl, 'sslmode')
2 changes: 2 additions & 0 deletions packages/pg/lib/defaults.js
Original file line number Diff line number Diff line change
@@ -53,6 +53,8 @@ module.exports = {

fallback_application_name: undefined,

options: undefined,

parseInputDatesAsUTC: false,

// max milliseconds any query using this connection will execute for before timing out in error.
4 changes: 2 additions & 2 deletions packages/pg/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pg",
"version": "8.2.2",
"version": "8.3.0",
"description": "PostgreSQL client - pure javascript & libpq with the same API",
"keywords": [
"database",
@@ -21,7 +21,7 @@
"dependencies": {
"buffer-writer": "2.0.0",
"packet-reader": "1.0.0",
"pg-connection-string": "^2.2.3",
"pg-connection-string": "^2.3.0",
"pg-pool": "^3.2.1",
"pg-protocol": "^1.2.5",
"pg-types": "^2.1.0",
13 changes: 13 additions & 0 deletions packages/pg/test/integration/client/connection-parameter-tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const helper = require('../test-helper')
const suite = new helper.Suite()
const { Client } = helper.pg

suite.test('it sends options', async () => {
const client = new Client({
options: '--default_transaction_isolation=serializable',
})
await client.connect()
const { rows } = await client.query('SHOW default_transaction_isolation')
console.log(rows)
await client.end()
})
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@ var compare = function (actual, expected, type) {
assert.equal(actual.password, expected.password, type + ' password')
assert.equal(actual.binary, expected.binary, type + ' binary')
assert.equal(actual.statement_timeout, expected.statement_timeout, type + ' statement_timeout')
assert.equal(actual.options, expected.options, type + ' options')
assert.equal(
actual.idle_in_transaction_session_timeout,
expected.idle_in_transaction_session_timeout,
@@ -48,12 +49,14 @@ test('ConnectionParameters initializing from defaults with connectionString set'
binary: defaults.binary,
statement_timeout: false,
idle_in_transaction_session_timeout: false,
options: '-c geqo=off',
}

var original_value = defaults.connectionString
// Just changing this here doesn't actually work because it's no longer in scope when viewed inside of
// of ConnectionParameters() so we have to pass in the defaults explicitly to test it
defaults.connectionString = 'postgres://brians-are-the-best:mypassword@foo.bar.net:7777/scoobysnacks'
defaults.connectionString =
'postgres://brians-are-the-best:mypassword@foo.bar.net:7777/scoobysnacks?options=-c geqo=off'
var subject = new ConnectionParameters(defaults)
defaults.connectionString = original_value
compare(subject, config, 'defaults-connectionString')
@@ -73,6 +76,7 @@ test('ConnectionParameters initializing from config', function () {
},
statement_timeout: 15000,
idle_in_transaction_session_timeout: 15000,
options: '-c geqo=off',
}
var subject = new ConnectionParameters(config)
compare(subject, config, 'config')