Skip to content

Commit 1c8c9fb

Browse files
committed
Fixes issue related to flow types
1 parent ebf65bf commit 1c8c9fb

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

src/Adapters/Storage/Mongo/MongoStorageAdapter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ export class MongoStorageAdapter implements StorageAdapter {
161161
return this.connectionPromise;
162162
}
163163

164-
handleError<T>(error: ?Error): Promise<T> {
164+
handleError<T>(error: ?(Error | Parse.Error)): Promise<T> {
165165
if (error && error.code === 13) { // Unauthorized error
166166
delete this.client;
167167
delete this.database;

src/Adapters/Storage/Postgres/PostgresStorageAdapter.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,9 @@ const buildWhereClause = ({ schema, query, index }) => {
611611
}
612612

613613
export class PostgresStorageAdapter implements StorageAdapter {
614+
615+
canSortOnJoinTables: boolean;
616+
614617
// Private
615618
_collectionPrefix: string;
616619
_client: any;
@@ -625,6 +628,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
625628
const { client, pgp } = createClient(uri, databaseOptions);
626629
this._client = client;
627630
this._pgp = pgp;
631+
this.canSortOnJoinTables = false;
628632
}
629633

630634
handleShutdown() {
@@ -862,7 +866,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
862866
return this._client.task('delete-all-classes', function * (t) {
863867
try {
864868
const results = yield t.any('SELECT * FROM "_SCHEMA"');
865-
const joins = results.reduce((list, schema) => {
869+
const joins = results.reduce((list: Array<string>, schema: any) => {
866870
return list.concat(joinTablesForSchema(schema.schema));
867871
}, []);
868872
const classes = ['_SCHEMA', '_PushStatus', '_JobStatus', '_JobSchedule', '_Hooks', '_GlobalConfig', '_Audience', ...results.map(result => result.className), ...joins];
@@ -895,7 +899,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
895899
// Returns a Promise.
896900
deleteFields(className: string, schema: SchemaType, fieldNames: string[]): Promise<void> {
897901
debug('deleteFields', className, fieldNames);
898-
fieldNames = fieldNames.reduce((list, fieldName) => {
902+
fieldNames = fieldNames.reduce((list: Array<string>, fieldName: string) => {
899903
const field = schema.fields[fieldName]
900904
if (field.type !== 'Relation') {
901905
list.push(fieldName);
@@ -1149,14 +1153,14 @@ export class PostgresStorageAdapter implements StorageAdapter {
11491153
} else if (fieldName == 'authData') {
11501154
// This recursively sets the json_object
11511155
// Only 1 level deep
1152-
const generate = (jsonb, key, value) => {
1156+
const generate = (jsonb: string, key: string, value: any) => {
11531157
return `json_object_set_key(COALESCE(${jsonb}, '{}'::jsonb), ${key}, ${value})::jsonb`;
11541158
}
11551159
const lastKey = `$${index}:name`;
11561160
const fieldNameIndex = index;
11571161
index += 1;
11581162
values.push(fieldName);
1159-
const update = Object.keys(fieldValue).reduce((lastKey, key) => {
1163+
const update = Object.keys(fieldValue).reduce((lastKey: string, key: string) => {
11601164
const str = generate(lastKey, `$${index}::text`, `$${index + 1}::jsonb`)
11611165
index += 2;
11621166
let value = fieldValue[key];
@@ -1265,7 +1269,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
12651269
return value && value.__op === 'Delete' && k.split('.').length === 2 && k.split(".")[0] === fieldName;
12661270
}).map(k => k.split('.')[1]);
12671271

1268-
const deletePatterns = keysToDelete.reduce((p, c, i) => {
1272+
const deletePatterns = keysToDelete.reduce((p: string, c: string, i: number) => {
12691273
return p + ` - '$${index + 1 + i}:value'`;
12701274
}, '');
12711275

src/Adapters/Storage/StorageAdapter.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ export type UpdateQueryOptions = {
2424
export type FullQueryOptions = QueryOptions & UpdateQueryOptions;
2525

2626
export interface StorageAdapter {
27+
canSortOnJoinTables: boolean;
28+
2729
classExists(className: string): Promise<boolean>;
2830
setClassLevelPermissions(className: string, clps: any): Promise<void>;
2931
createClass(className: string, schema: SchemaType): Promise<void>;

0 commit comments

Comments
 (0)