[Snyk] Upgrade pg-promise from 10.9.2 to 10.10.1 (#7286)

* fix: upgrade pg-promise from 10.9.2 to 10.9.3

Snyk has created this PR to upgrade pg-promise from 10.9.2 to 10.9.3.

See this package in npm:
https://www.npmjs.com/package/pg-promise

See this project in Snyk:
https://app.snyk.io/org/acinader/project/8c1a9edb-c8f5-4dc1-b221-4d6030a323eb?utm_source=github&utm_medium=upgrade-pr

* bump pg-promise to 10.10.1

* fix add field if not exists

* lint

Co-authored-by: Diamond Lewis <findlewis@gmail.com>
This commit is contained in:
Snyk bot
2021-04-29 20:10:15 +03:00
committed by GitHub
parent e143fb1bf6
commit 755c49404d
3 changed files with 17 additions and 20 deletions

View File

@@ -1056,7 +1056,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
conn = conn || this._client;
const self = this;
await conn.tx('schema-upgrade', async t => {
await conn.task('schema-upgrade', async t => {
const columns = await t.map(
'SELECT column_name FROM information_schema.columns WHERE table_name = $<className>',
{ className },
@@ -1064,20 +1064,17 @@ export class PostgresStorageAdapter implements StorageAdapter {
);
const newColumns = Object.keys(schema.fields)
.filter(item => columns.indexOf(item) === -1)
.map(fieldName =>
self.addFieldIfNotExists(className, fieldName, schema.fields[fieldName], t)
);
.map(fieldName => self.addFieldIfNotExists(className, fieldName, schema.fields[fieldName]));
await t.batch(newColumns);
});
}
async addFieldIfNotExists(className: string, fieldName: string, type: any, conn: any) {
async addFieldIfNotExists(className: string, fieldName: string, type: any) {
// TODO: Must be revised for invalid logic...
debug('addFieldIfNotExists');
conn = conn || this._client;
const self = this;
await conn.tx('add-field-if-not-exists', async t => {
await this._client.tx('add-field-if-not-exists', async t => {
if (type.type !== 'Relation') {
try {
await t.none(