Skip to content

Commit e3f89ce

Browse files
author
Shayon Mukherjee
committed
Skip adding options twice and extend specs
1 parent 52f67d3 commit e3f89ce

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

Diff for: packages/pg/lib/connection-parameters.js

-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ class ConnectionParameters {
143143
add(params, this, 'application_name')
144144
add(params, this, 'fallback_application_name')
145145
add(params, this, 'connect_timeout')
146-
add(params, this, 'options')
147146

148147
addOption(pgOptions, this, 'statement_timeout')
149148
addOption(pgOptions, this, 'idle_in_transaction_session_timeout')

Diff for: packages/pg/test/unit/connection-parameters/creation-tests.js

+22-2
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ test('libpq connection string building', function () {
172172
)
173173
})
174174

175-
test('builds conn string with options', function () {
175+
test('builds conn string with options and statement_timeout', function () {
176176
var config = {
177177
user: 'brian',
178178
password: 'xyz',
@@ -181,13 +181,33 @@ test('libpq connection string building', function () {
181181
database: 'bam',
182182
statement_timeout: 5000,
183183
idle_in_transaction_session_timeout: 5000,
184+
options: '-c geqo=off -c foobar=off',
184185
}
185186
var subject = new ConnectionParameters(config)
186187
subject.getLibpqConnectionString(
187188
assert.calls(function (err, constring) {
188189
assert(!err)
189190
var parts = constring.split(/ (?=([^\']*\'[^\']*\')*[^\']*$)/)
190-
checkForPart(parts, "options='-c statement_timeout=5000 -c idle_in_transaction_session_timeout=5000'")
191+
checkForPart(parts, "options='-c statement_timeout=5000 -c idle_in_transaction_session_timeout=5000 -c geqo=off -c foobar=off'")
192+
})
193+
)
194+
})
195+
196+
test('builds conn string with options and without statement_timeout', function () {
197+
var config = {
198+
user: 'brian',
199+
password: 'xyz',
200+
port: 888,
201+
host: 'localhost',
202+
database: 'bam',
203+
options: '-c geqo=off -c foobar=off',
204+
}
205+
var subject = new ConnectionParameters(config)
206+
subject.getLibpqConnectionString(
207+
assert.calls(function (err, constring) {
208+
assert(!err)
209+
var parts = constring.split(/ (?=([^\']*\'[^\']*\')*[^\']*$)/)
210+
checkForPart(parts, "options='-c geqo=off -c foobar=off'")
191211
})
192212
)
193213
})

0 commit comments

Comments
 (0)