Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Skip adding options twice and extend specs
  • Loading branch information
Shayon Mukherjee committed Oct 24, 2020
commit e3f89ce5d9ce8df38c87f9df848b0e5bbe314b71
1 change: 0 additions & 1 deletion packages/pg/lib/connection-parameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ class ConnectionParameters {
add(params, this, 'application_name')
add(params, this, 'fallback_application_name')
add(params, this, 'connect_timeout')
add(params, this, 'options')

addOption(pgOptions, this, 'statement_timeout')
addOption(pgOptions, this, 'idle_in_transaction_session_timeout')
Expand Down
24 changes: 22 additions & 2 deletions packages/pg/test/unit/connection-parameters/creation-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ test('libpq connection string building', function () {
)
})

test('builds conn string with options', function () {
test('builds conn string with options and statement_timeout', function () {
var config = {
user: 'brian',
password: 'xyz',
Expand All @@ -181,13 +181,33 @@ test('libpq connection string building', function () {
database: 'bam',
statement_timeout: 5000,
idle_in_transaction_session_timeout: 5000,
options: '-c geqo=off -c foobar=off',
}
var subject = new ConnectionParameters(config)
subject.getLibpqConnectionString(
assert.calls(function (err, constring) {
assert(!err)
var parts = constring.split(/ (?=([^\']*\'[^\']*\')*[^\']*$)/)
checkForPart(parts, "options='-c statement_timeout=5000 -c idle_in_transaction_session_timeout=5000'")
checkForPart(parts, "options='-c statement_timeout=5000 -c idle_in_transaction_session_timeout=5000 -c geqo=off -c foobar=off'")
})
)
})

test('builds conn string with options and without statement_timeout', function () {
var config = {
user: 'brian',
password: 'xyz',
port: 888,
host: 'localhost',
database: 'bam',
options: '-c geqo=off -c foobar=off',
}
var subject = new ConnectionParameters(config)
subject.getLibpqConnectionString(
assert.calls(function (err, constring) {
assert(!err)
var parts = constring.split(/ (?=([^\']*\'[^\']*\')*[^\']*$)/)
checkForPart(parts, "options='-c geqo=off -c foobar=off'")
})
)
})
Expand Down