@@ -611,6 +611,9 @@ const buildWhereClause = ({ schema, query, index }) => {
611
611
}
612
612
613
613
export class PostgresStorageAdapter implements StorageAdapter {
614
+
615
+ canSortOnJoinTables : boolean ;
616
+
614
617
// Private
615
618
_collectionPrefix : string ;
616
619
_client : any ;
@@ -625,6 +628,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
625
628
const { client, pgp } = createClient ( uri , databaseOptions ) ;
626
629
this . _client = client ;
627
630
this . _pgp = pgp ;
631
+ this . canSortOnJoinTables = false ;
628
632
}
629
633
630
634
handleShutdown ( ) {
@@ -862,7 +866,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
862
866
return this . _client . task ( 'delete-all-classes' , function * ( t ) {
863
867
try {
864
868
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 ) => {
866
870
return list . concat ( joinTablesForSchema ( schema . schema ) ) ;
867
871
} , [ ] ) ;
868
872
const classes = [ '_SCHEMA' , '_PushStatus' , '_JobStatus' , '_JobSchedule' , '_Hooks' , '_GlobalConfig' , '_Audience' , ...results . map ( result => result . className ) , ...joins ] ;
@@ -895,7 +899,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
895
899
// Returns a Promise.
896
900
deleteFields ( className : string , schema : SchemaType , fieldNames : string [ ] ) : Promise < void > {
897
901
debug ( 'deleteFields' , className , fieldNames ) ;
898
- fieldNames = fieldNames . reduce ( ( list , fieldName ) => {
902
+ fieldNames = fieldNames . reduce ( ( list : Array < string > , fieldName : string ) => {
899
903
const field = schema . fields [ fieldName ]
900
904
if ( field . type !== 'Relation' ) {
901
905
list . push ( fieldName ) ;
@@ -1149,14 +1153,14 @@ export class PostgresStorageAdapter implements StorageAdapter {
1149
1153
} else if ( fieldName == 'authData' ) {
1150
1154
// This recursively sets the json_object
1151
1155
// Only 1 level deep
1152
- const generate = ( jsonb , key , value ) => {
1156
+ const generate = ( jsonb : string , key : string , value : any ) => {
1153
1157
return `json_object_set_key(COALESCE(${ jsonb } , '{}'::jsonb), ${ key } , ${ value } )::jsonb` ;
1154
1158
}
1155
1159
const lastKey = `$${ index } :name` ;
1156
1160
const fieldNameIndex = index ;
1157
1161
index += 1 ;
1158
1162
values . push ( fieldName ) ;
1159
- const update = Object . keys ( fieldValue ) . reduce ( ( lastKey , key ) => {
1163
+ const update = Object . keys ( fieldValue ) . reduce ( ( lastKey : string , key : string ) => {
1160
1164
const str = generate ( lastKey , `$${ index } ::text` , `$${ index + 1 } ::jsonb` )
1161
1165
index += 2 ;
1162
1166
let value = fieldValue [ key ] ;
@@ -1265,7 +1269,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
1265
1269
return value && value . __op === 'Delete' && k . split ( '.' ) . length === 2 && k . split ( "." ) [ 0 ] === fieldName ;
1266
1270
} ) . map ( k => k . split ( '.' ) [ 1 ] ) ;
1267
1271
1268
- const deletePatterns = keysToDelete . reduce ( ( p , c , i ) => {
1272
+ const deletePatterns = keysToDelete . reduce ( ( p : string , c : string , i : number ) => {
1269
1273
return p + ` - '$${ index + 1 + i } :value'` ;
1270
1274
} , '' ) ;
1271
1275
0 commit comments