Skip to content

Commit

Permalink
Skip adding options twice and extend specs
Browse files Browse the repository at this point in the history
  • Loading branch information
Shayon Mukherjee committed Oct 24, 2020
1 parent 52f67d3 commit e3f89ce
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
1 change: 0 additions & 1 deletion packages/pg/lib/connection-parameters.js
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
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

0 comments on commit e3f89ce

Please sign in to comment.