Skip to content

Commit

Permalink
[Snyk] Upgrade pg-promise from 10.9.2 to 10.10.1 (parse-community#7286)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
snyk-bot and dplewis authored Apr 29, 2021
1 parent e143fb1 commit 755c494
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 20 deletions.
24 changes: 12 additions & 12 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"mustache": "4.2.0",
"parse": "3.1.0",
"pg-monitor": "1.4.1",
"pg-promise": "10.9.2",
"pg-promise": "10.10.1",
"pluralize": "8.0.0",
"redis": "3.1.1",
"semver": "7.3.4",
Expand Down
11 changes: 4 additions & 7 deletions src/Adapters/Storage/Postgres/PostgresStorageAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -1056,28 +1056,25 @@ 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 },
a => a.column_name
);
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(
Expand Down

0 comments on commit 755c494

Please sign in to comment.