Skip to content

Commit 606bb9c

Browse files
committed
Add proper error message when empty connect string is provided for creating connection pools
1 parent c231bdf commit 606bb9c

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

doc/src/release_notes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ Thin Mode Changes
5050
#) Added new properties in `oracledb` that can enable users to customize and set session information,
5151
making it easier to manage and monitor database interactions.
5252

53+
#) Error ``NJS-125`` is now raised when an empty connect string is provided
54+
for creating pools.
55+
5356
Thick Mode changes
5457
++++++++++++++++++
5558

lib/thin/pool.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ class ThinPoolImpl extends PoolImpl {
4444
if (!params.homogeneous) {
4545
errors.throwErr(errors.ERR_NOT_IMPLEMENTED, 'Heterogeneous Pooling');
4646
}
47+
if (!params.connectString) {
48+
errors.throwErr(errors.ERR_EMPTY_CONNECT_STRING);
49+
}
4750
thinUtil.checkCredentials(params);
4851

4952
this._availableObjects = [];

test/list.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,9 @@ Overview of node-oracledb functional tests
8080
2.11.2 error occurs at getConnection() when poolMin is the default value 0
8181
2.12 connectionString alias
8282
2.12.1 allows connectionString to be used as an alias for connectString
83-
2.13 connectString & connectionString provided
83+
2.13 connect string
8484
2.13.1 both connectString & connectionString provided
85+
2.13.2 Negative - empty connect string
8586
2.14 username alias
8687
2.14.1 allows username to be used as an alias for user
8788
2.14.2 both user and username specified

test/pool.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ describe('2. pool.js', function() {
616616
});
617617
}); // 2.12
618618

619-
describe('2.13 connectString & connectionString provided', function() {
619+
describe('2.13 connect string', function() {
620620

621621
it('2.13.1 both connectString & connectionString provided', async function() {
622622
const config = {...dbConfig,
@@ -630,6 +630,21 @@ describe('2. pool.js', function() {
630630
/NJS-075:/
631631
);
632632
}); // 2.13.1
633+
634+
it('2.13.2 Negative - empty connect string', async function() {
635+
const config = {...dbConfig,
636+
connectString: dbConfig.connectString_does_not_exist,
637+
poolMin: 1,
638+
poolMax: 1,
639+
poolIncrement: 0
640+
};
641+
await assert.rejects(
642+
async () => await oracledb.createPool(config),
643+
/ORA-01017:|NJS-125:/
644+
// ORA-01017: invalid username/password; logon denied
645+
// NJS-125: "connectString" cannot be empty or undefined. Bequeath connections are not supported in Thin mode
646+
);
647+
}); // 2.13.2
633648
}); // 2.13
634649

635650
describe('2.14 username alias', function() {

0 commit comments

Comments
 (0)