Skip to content

Commit 1142423

Browse files
greenkeeper[bot]peril-parse-community[bot]
authored andcommitted
Update pg-promise to the latest version 🚀 (parse-community#5857)
* fix(package): update pg-promise to version 9.0.0 * chore(package): update lockfile package-lock.json * remove es6 generators
1 parent ee12a0c commit 1142423

File tree

3 files changed

+45
-45
lines changed

3 files changed

+45
-45
lines changed

‎package-lock.json

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"mongodb": "3.2.7",
4545
"node-rsa": "1.0.5",
4646
"parse": "2.5.1",
47-
"pg-promise": "8.7.5",
47+
"pg-promise": "9.0.0",
4848
"redis": "2.8.0",
4949
"semver": "6.3.0",
5050
"subscriptions-transport-ws": "0.9.16",

‎src/Adapters/Storage/Postgres/PostgresStorageAdapter.js

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -830,15 +830,15 @@ export class PostgresStorageAdapter implements StorageAdapter {
830830

831831
setClassLevelPermissions(className: string, CLPs: any) {
832832
const self = this;
833-
return this._client.task('set-class-level-permissions', function*(t) {
834-
yield self._ensureSchemaCollectionExists(t);
833+
return this._client.task('set-class-level-permissions', async (t) => {
834+
await self._ensureSchemaCollectionExists(t);
835835
const values = [
836836
className,
837837
'schema',
838838
'classLevelPermissions',
839839
JSON.stringify(CLPs),
840840
];
841-
yield t.none(
841+
await t.none(
842842
`UPDATE "_SCHEMA" SET $2:name = json_object_set_key($2:name, $3::text, $4::jsonb) WHERE "className"=$1`,
843843
values
844844
);
@@ -895,15 +895,15 @@ export class PostgresStorageAdapter implements StorageAdapter {
895895
});
896896
}
897897
});
898-
return conn.tx('set-indexes-with-schema-format', function*(t) {
898+
return conn.tx('set-indexes-with-schema-format', async (t) => {
899899
if (insertedIndexes.length > 0) {
900-
yield self.createIndexes(className, insertedIndexes, t);
900+
await self.createIndexes(className, insertedIndexes, t);
901901
}
902902
if (deletedIndexes.length > 0) {
903-
yield self.dropIndexes(className, deletedIndexes, t);
903+
await self.dropIndexes(className, deletedIndexes, t);
904904
}
905-
yield self._ensureSchemaCollectionExists(t);
906-
yield t.none(
905+
await self._ensureSchemaCollectionExists(t);
906+
await t.none(
907907
'UPDATE "_SCHEMA" SET $2:name = json_object_set_key($2:name, $3::text, $4::jsonb) WHERE "className"=$1',
908908
[className, 'schema', 'indexes', JSON.stringify(existingIndexes)]
909909
);
@@ -991,17 +991,17 @@ export class PostgresStorageAdapter implements StorageAdapter {
991991
const values = [className, ...valuesArray];
992992

993993
debug(qs, values);
994-
return conn.task('create-table', function*(t) {
994+
return conn.task('create-table', async (t) => {
995995
try {
996-
yield self._ensureSchemaCollectionExists(t);
997-
yield t.none(qs, values);
996+
await self._ensureSchemaCollectionExists(t);
997+
await t.none(qs, values);
998998
} catch (error) {
999999
if (error.code !== PostgresDuplicateRelationError) {
10001000
throw error;
10011001
}
10021002
// ELSE: Table already exists, must have been created by a different request. Ignore the error.
10031003
}
1004-
yield t.tx('create-table-tx', tx => {
1004+
await t.tx('create-table-tx', tx => {
10051005
return tx.batch(
10061006
relations.map(fieldName => {
10071007
return tx.none(
@@ -1019,8 +1019,8 @@ export class PostgresStorageAdapter implements StorageAdapter {
10191019
conn = conn || this._client;
10201020
const self = this;
10211021

1022-
return conn.tx('schema-upgrade', function*(t) {
1023-
const columns = yield t.map(
1022+
return conn.tx('schema-upgrade', async (t) => {
1023+
const columns = await t.map(
10241024
'SELECT column_name FROM information_schema.columns WHERE table_name = $<className>',
10251025
{ className },
10261026
a => a.column_name
@@ -1036,7 +1036,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
10361036
)
10371037
);
10381038

1039-
yield t.batch(newColumns);
1039+
await t.batch(newColumns);
10401040
});
10411041
}
10421042

@@ -1050,10 +1050,10 @@ export class PostgresStorageAdapter implements StorageAdapter {
10501050
debug('addFieldIfNotExists', { className, fieldName, type });
10511051
conn = conn || this._client;
10521052
const self = this;
1053-
return conn.tx('add-field-if-not-exists', function*(t) {
1053+
return conn.tx('add-field-if-not-exists', async (t) => {
10541054
if (type.type !== 'Relation') {
10551055
try {
1056-
yield t.none(
1056+
await t.none(
10571057
'ALTER TABLE $<className:name> ADD COLUMN $<fieldName:name> $<postgresType:raw>',
10581058
{
10591059
className,
@@ -1063,7 +1063,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
10631063
);
10641064
} catch (error) {
10651065
if (error.code === PostgresRelationDoesNotExistError) {
1066-
return yield self.createClass(
1066+
return await self.createClass(
10671067
className,
10681068
{ fields: { [fieldName]: type } },
10691069
t
@@ -1075,13 +1075,13 @@ export class PostgresStorageAdapter implements StorageAdapter {
10751075
// Column already exists, created by other request. Carry on to see if it's the right type.
10761076
}
10771077
} else {
1078-
yield t.none(
1078+
await t.none(
10791079
'CREATE TABLE IF NOT EXISTS $<joinTable:name> ("relatedId" varChar(120), "owningId" varChar(120), PRIMARY KEY("relatedId", "owningId") )',
10801080
{ joinTable: `_Join:${fieldName}:${className}` }
10811081
);
10821082
}
10831083

1084-
const result = yield t.any(
1084+
const result = await t.any(
10851085
'SELECT "schema" FROM "_SCHEMA" WHERE "className" = $<className> and ("schema"::json->\'fields\'->$<fieldName>) is not null',
10861086
{ className, fieldName }
10871087
);
@@ -1090,7 +1090,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
10901090
throw 'Attempted to add a field that already exists';
10911091
} else {
10921092
const path = `{fields,${fieldName}}`;
1093-
yield t.none(
1093+
await t.none(
10941094
'UPDATE "_SCHEMA" SET "schema"=jsonb_set("schema", $<path>, $<type>) WHERE "className"=$<className>',
10951095
{ path, type, className }
10961096
);
@@ -1120,9 +1120,9 @@ export class PostgresStorageAdapter implements StorageAdapter {
11201120
debug('deleteAllClasses');
11211121

11221122
return this._client
1123-
.task('delete-all-classes', function*(t) {
1123+
.task('delete-all-classes', async (t) => {
11241124
try {
1125-
const results = yield t.any('SELECT * FROM "_SCHEMA"');
1125+
const results = await t.any('SELECT * FROM "_SCHEMA"');
11261126
const joins = results.reduce((list: Array<string>, schema: any) => {
11271127
return list.concat(joinTablesForSchema(schema.schema));
11281128
}, []);
@@ -1142,7 +1142,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
11421142
query: 'DROP TABLE IF EXISTS $<className:name>',
11431143
values: { className },
11441144
}));
1145-
yield t.tx(tx => tx.none(helpers.concat(queries)));
1145+
await t.tx(tx => tx.none(helpers.concat(queries)));
11461146
} catch (error) {
11471147
if (error.code !== PostgresRelationDoesNotExistError) {
11481148
throw error;
@@ -1190,13 +1190,13 @@ export class PostgresStorageAdapter implements StorageAdapter {
11901190
})
11911191
.join(', DROP COLUMN');
11921192

1193-
return this._client.tx('delete-fields', function*(t) {
1194-
yield t.none(
1193+
return this._client.tx('delete-fields', async (t) => {
1194+
await t.none(
11951195
'UPDATE "_SCHEMA" SET "schema"=$<schema> WHERE "className"=$<className>',
11961196
{ schema, className }
11971197
);
11981198
if (values.length > 1) {
1199-
yield t.none(`ALTER TABLE $1:name DROP COLUMN ${columns}`, values);
1199+
await t.none(`ALTER TABLE $1:name DROP COLUMN ${columns}`, values);
12001200
}
12011201
});
12021202
}
@@ -1206,9 +1206,9 @@ export class PostgresStorageAdapter implements StorageAdapter {
12061206
// rejection reason are TBD.
12071207
getAllClasses() {
12081208
const self = this;
1209-
return this._client.task('get-all-classes', function*(t) {
1210-
yield self._ensureSchemaCollectionExists(t);
1211-
return yield t.map('SELECT * FROM "_SCHEMA"', null, row =>
1209+
return this._client.task('get-all-classes', async (t) => {
1210+
await self._ensureSchemaCollectionExists(t);
1211+
return await t.map('SELECT * FROM "_SCHEMA"', null, row =>
12121212
toParseSchema({ className: row.className, ...row.schema })
12131213
);
12141214
});

0 commit comments

Comments
 (0)