Skip to content

Commit 87cab09

Browse files
authored
refactor: Upgrade pg-promise to 11.3.0 and pg-monitor to 2.0.0 (#8453)
1 parent 94d558e commit 87cab09

File tree

4 files changed

+61
-47
lines changed

4 files changed

+61
-47
lines changed

package-lock.json

+41-41
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@
5050
"mustache": "4.2.0",
5151
"parse": "4.0.1",
5252
"path-to-regexp": "0.1.7",
53-
"pg-monitor": "1.5.0",
54-
"pg-promise": "10.12.1",
53+
"pg-monitor": "2.0.0",
54+
"pg-promise": "11.3.0",
5555
"pluralize": "8.0.0",
5656
"redis": "4.0.6",
5757
"semver": "7.3.8",

spec/PostgresConfigParser.spec.js

+17-3
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ const baseURI = 'postgres://username:password@localhost:5432/db-name';
2727
const testfile = fs.readFileSync('./Dockerfile').toString();
2828
const dbOptionsTest = {};
2929
dbOptionsTest[
30-
`${baseURI}?ssl=true&binary=true&application_name=app_name&fallback_application_name=f_app_name&poolSize=10`
30+
`${baseURI}?ssl=true&binary=true&application_name=app_name&fallback_application_name=f_app_name&poolSize=12`
3131
] = {
3232
ssl: true,
3333
binary: true,
3434
application_name: 'app_name',
3535
fallback_application_name: 'f_app_name',
36-
poolSize: 10,
36+
max: 12,
3737
};
3838
dbOptionsTest[`${baseURI}?ssl=&binary=aa`] = {
3939
binary: false,
@@ -83,6 +83,20 @@ describe('PostgresConfigParser.getDatabaseOptionsFromURI', () => {
8383
it('sets the poolSize to 10 if the it is not a number', () => {
8484
const result = parser.getDatabaseOptionsFromURI(`${baseURI}?poolSize=sdf`);
8585

86-
expect(result.poolSize).toEqual(10);
86+
expect(result.max).toEqual(10);
87+
});
88+
89+
it('sets the max to 10 if the it is not a number', () => {
90+
const result = parser.getDatabaseOptionsFromURI(`${baseURI}?&max=sdf`);
91+
92+
expect(result.poolSize).toBeUndefined();
93+
expect(result.max).toEqual(10);
94+
});
95+
96+
it('max should take precedence over poolSize', () => {
97+
const result = parser.getDatabaseOptionsFromURI(`${baseURI}?poolSize=20&max=12`);
98+
99+
expect(result.poolSize).toBeUndefined();
100+
expect(result.max).toEqual(12);
87101
});
88102
});

src/Adapters/Storage/Postgres/PostgresConfigParser.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function getDatabaseOptionsFromURI(uri) {
5858
databaseOptions.fallback_application_name = queryParams.fallback_application_name;
5959

6060
if (queryParams.poolSize) {
61-
databaseOptions.poolSize = parseInt(queryParams.poolSize) || 10;
61+
databaseOptions.max = parseInt(queryParams.poolSize) || 10;
6262
}
6363
if (queryParams.max) {
6464
databaseOptions.max = parseInt(queryParams.max) || 10;

0 commit comments

Comments
 (0)