Skip to content

Commit

Permalink
refactor: Upgrade pg-promise to 11.3.0 and pg-monitor to 2.0.0 (#8453)
Browse files Browse the repository at this point in the history
  • Loading branch information
cbaker6 authored Mar 5, 2023
1 parent 94d558e commit 87cab09
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 47 deletions.
82 changes: 41 additions & 41 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
"mustache": "4.2.0",
"parse": "4.0.1",
"path-to-regexp": "0.1.7",
"pg-monitor": "1.5.0",
"pg-promise": "10.12.1",
"pg-monitor": "2.0.0",
"pg-promise": "11.3.0",
"pluralize": "8.0.0",
"redis": "4.0.6",
"semver": "7.3.8",
Expand Down
20 changes: 17 additions & 3 deletions spec/PostgresConfigParser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ const baseURI = 'postgres://username:password@localhost:5432/db-name';
const testfile = fs.readFileSync('./Dockerfile').toString();
const dbOptionsTest = {};
dbOptionsTest[
`${baseURI}?ssl=true&binary=true&application_name=app_name&fallback_application_name=f_app_name&poolSize=10`
`${baseURI}?ssl=true&binary=true&application_name=app_name&fallback_application_name=f_app_name&poolSize=12`
] = {
ssl: true,
binary: true,
application_name: 'app_name',
fallback_application_name: 'f_app_name',
poolSize: 10,
max: 12,
};
dbOptionsTest[`${baseURI}?ssl=&binary=aa`] = {
binary: false,
Expand Down Expand Up @@ -83,6 +83,20 @@ describe('PostgresConfigParser.getDatabaseOptionsFromURI', () => {
it('sets the poolSize to 10 if the it is not a number', () => {
const result = parser.getDatabaseOptionsFromURI(`${baseURI}?poolSize=sdf`);

expect(result.poolSize).toEqual(10);
expect(result.max).toEqual(10);
});

it('sets the max to 10 if the it is not a number', () => {
const result = parser.getDatabaseOptionsFromURI(`${baseURI}?&max=sdf`);

expect(result.poolSize).toBeUndefined();
expect(result.max).toEqual(10);
});

it('max should take precedence over poolSize', () => {
const result = parser.getDatabaseOptionsFromURI(`${baseURI}?poolSize=20&max=12`);

expect(result.poolSize).toBeUndefined();
expect(result.max).toEqual(12);
});
});
2 changes: 1 addition & 1 deletion src/Adapters/Storage/Postgres/PostgresConfigParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function getDatabaseOptionsFromURI(uri) {
databaseOptions.fallback_application_name = queryParams.fallback_application_name;

if (queryParams.poolSize) {
databaseOptions.poolSize = parseInt(queryParams.poolSize) || 10;
databaseOptions.max = parseInt(queryParams.poolSize) || 10;
}
if (queryParams.max) {
databaseOptions.max = parseInt(queryParams.max) || 10;
Expand Down

0 comments on commit 87cab09

Please sign in to comment.