@@ -244,7 +244,7 @@ const buildWhereClause = ({ schema, query, index }) => {
244
244
inPatterns . push ( `${ listElem } ` ) ;
245
245
}
246
246
} ) ;
247
- patterns . push ( `(${ name } )::jsonb @> '[${ inPatterns . join ( ',' ) } ]'::jsonb` ) ;
247
+ patterns . push ( `(${ name } )::jsonb @> '[${ inPatterns . join ( ) } ]'::jsonb` ) ;
248
248
} else if ( fieldValue . $regex ) {
249
249
// Handle later
250
250
} else {
@@ -327,9 +327,9 @@ const buildWhereClause = ({ schema, query, index }) => {
327
327
}
328
328
} ) ;
329
329
if ( allowNull ) {
330
- patterns . push ( `($${ index } :name IS NULL OR $${ index } :name && ARRAY[${ inPatterns . join ( ',' ) } ])` ) ;
330
+ patterns . push ( `($${ index } :name IS NULL OR $${ index } :name && ARRAY[${ inPatterns . join ( ) } ])` ) ;
331
331
} else {
332
- patterns . push ( `$${ index } :name && ARRAY[${ inPatterns . join ( ',' ) } ]` ) ;
332
+ patterns . push ( `$${ index } :name && ARRAY[${ inPatterns . join ( ) } ]` ) ;
333
333
}
334
334
index = index + 1 + inPatterns . length ;
335
335
} else if ( isInOrNin ) {
@@ -353,7 +353,7 @@ const buildWhereClause = ({ schema, query, index }) => {
353
353
inPatterns . push ( `$${ index + 1 + listIndex } ` ) ;
354
354
}
355
355
} ) ;
356
- patterns . push ( `$${ index } :name ${ not } IN (${ inPatterns . join ( ',' ) } )` ) ;
356
+ patterns . push ( `$${ index } :name ${ not } IN (${ inPatterns . join ( ) } )` ) ;
357
357
index = index + 1 + inPatterns . length ;
358
358
}
359
359
} else if ( ! notIn ) {
@@ -673,17 +673,15 @@ export class PostgresStorageAdapter implements StorageAdapter {
673
673
const q1 = this . createTable ( className , schema , t ) ;
674
674
const q2 = t . none ( 'INSERT INTO "_SCHEMA" ("className", "schema", "isParseClass") VALUES ($<className>, $<schema>, true)' , { className, schema } ) ;
675
675
const q3 = this . setIndexesWithSchemaFormat ( className , schema . indexes , { } , schema . fields , t ) ;
676
-
677
676
return t . batch ( [ q1 , q2 , q3 ] ) ;
678
677
} )
679
678
. then ( ( ) => {
680
- return toParseSchema ( schema )
679
+ return toParseSchema ( schema ) ;
681
680
} )
682
- . catch ( ( err ) => {
683
- if ( Array . isArray ( err . data ) && err . data . length > 1 && err . data [ 0 ] . result . code === PostgresTransactionAbortedError ) {
681
+ . catch ( err => {
682
+ if ( err . data [ 0 ] . result . code === PostgresTransactionAbortedError ) {
684
683
err = err . data [ 1 ] . result ;
685
684
}
686
-
687
685
if ( err . code === PostgresUniqueIndexViolationError && err . detail . includes ( className ) ) {
688
686
throw new Parse . Error ( Parse . Error . DUPLICATE_VALUE , `Class ${ className } already exists.` )
689
687
}
@@ -730,17 +728,17 @@ export class PostgresStorageAdapter implements StorageAdapter {
730
728
}
731
729
index = index + 2 ;
732
730
} ) ;
733
- const qs = `CREATE TABLE IF NOT EXISTS $1:name (${ patternsArray . join ( ',' ) } )` ;
731
+ const qs = `CREATE TABLE IF NOT EXISTS $1:name (${ patternsArray . join ( ) } )` ;
734
732
const values = [ className , ...valuesArray ] ;
735
-
733
+
736
734
return conn . task ( 'create-table' , function * ( t ) {
737
735
try {
738
736
yield self . _ensureSchemaCollectionExists ( t ) ;
739
737
yield t . none ( qs , values ) ;
740
738
} catch ( error ) {
741
- if ( error . code !== PostgresDuplicateRelationError ) {
742
- throw error ;
743
- }
739
+ if ( error . code !== PostgresDuplicateRelationError ) {
740
+ throw error ;
741
+ }
744
742
// ELSE: Table already exists, must have been created by a different request. Ignore the error.
745
743
}
746
744
yield t . tx ( 'create-table-tx' , tx => {
@@ -764,14 +762,14 @@ export class PostgresStorageAdapter implements StorageAdapter {
764
762
postgresType : parseTypeToPostgresType ( type )
765
763
} ) ;
766
764
} catch ( error ) {
767
- if ( error . code === PostgresRelationDoesNotExistError ) {
768
- return yield self . createClass ( className , { fields : { [ fieldName ] : type } } , t ) ;
769
- }
770
- if ( error . code !== PostgresDuplicateColumnError ) {
771
- throw error ;
772
- }
773
- // Column already exists, created by other request. Carry on to see if it's the right type.
774
- } ;
765
+ if ( error . code === PostgresRelationDoesNotExistError ) {
766
+ return yield self . createClass ( className , { fields : { [ fieldName ] : type } } , t ) ;
767
+ }
768
+ if ( error . code !== PostgresDuplicateColumnError ) {
769
+ throw error ;
770
+ }
771
+ // Column already exists, created by other request. Carry on to see if it's the right type.
772
+ }
775
773
} else {
776
774
yield t . none ( 'CREATE TABLE IF NOT EXISTS $<joinTable:name> ("relatedId" varChar(120), "owningId" varChar(120), PRIMARY KEY("relatedId", "owningId") )' , { joinTable : `_Join:${ fieldName } :${ className } ` } ) ;
777
775
}
@@ -803,7 +801,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
803
801
const now = new Date ( ) . getTime ( ) ;
804
802
const helpers = this . _pgp . helpers ;
805
803
debug ( 'deleteAllClasses' ) ;
806
-
804
+
807
805
return this . _client . task ( 'delete-all-classes' , function * ( t ) {
808
806
try {
809
807
const results = yield t . any ( 'SELECT * FROM "_SCHEMA"' ) ;
@@ -820,8 +818,8 @@ export class PostgresStorageAdapter implements StorageAdapter {
820
818
// No _SCHEMA collection. Don't delete anything.
821
819
}
822
820
} ) . then ( ( ) => {
823
- debug ( `deleteAllClasses done in ${ new Date ( ) . getTime ( ) - now } ` ) ;
824
- } ) ;
821
+ debug ( `deleteAllClasses done in ${ new Date ( ) . getTime ( ) - now } ` ) ;
822
+ } ) ;
825
823
}
826
824
827
825
// Remove the column and all the data. For Relations, the _Join collection is handled
@@ -869,7 +867,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
869
867
return this . _client . task ( 'get-all-classes' , function * ( t ) {
870
868
yield self . _ensureSchemaCollectionExists ( t ) ;
871
869
return yield t . map ( 'SELECT * FROM "_SCHEMA"' , null , row => toParseSchema ( { className : row . className , ...row . schema } ) ) ;
872
- } ) ;
870
+ } ) ;
873
871
}
874
872
875
873
// Return a promise for the schema with the given name, in Parse format. If
@@ -1001,8 +999,8 @@ export class PostgresStorageAdapter implements StorageAdapter {
1001
999
return `POINT($${ l } , $${ l + 1 } )` ;
1002
1000
} ) ;
1003
1001
1004
- const columnsPattern = columnsArray . map ( ( col , index ) => `$${ index + 2 } :name` ) . join ( ',' ) ;
1005
- const valuesPattern = initialValues . concat ( geoPointsInjects ) . join ( ',' )
1002
+ const columnsPattern = columnsArray . map ( ( col , index ) => `$${ index + 2 } :name` ) . join ( ) ;
1003
+ const valuesPattern = initialValues . concat ( geoPointsInjects ) . join ( )
1006
1004
1007
1005
const qs = `INSERT INTO $1:name (${ columnsPattern } ) VALUES (${ valuesPattern } )`
1008
1006
const values = [ className , ...columnsArray , ...valuesArray ]
@@ -1240,7 +1238,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
1240
1238
values . push ( ...where . values ) ;
1241
1239
1242
1240
const whereClause = where . pattern . length > 0 ? `WHERE ${ where . pattern } ` : '' ;
1243
- const qs = `UPDATE $1:name SET ${ updatePatterns . join ( ',' ) } ${ whereClause } RETURNING *` ;
1241
+ const qs = `UPDATE $1:name SET ${ updatePatterns . join ( ) } ${ whereClause } RETURNING *` ;
1244
1242
debug ( 'update: ' , qs , values ) ;
1245
1243
return this . _client . any ( qs , values ) ;
1246
1244
}
@@ -1284,11 +1282,11 @@ export class PostgresStorageAdapter implements StorageAdapter {
1284
1282
return `"${ key } " ASC` ;
1285
1283
}
1286
1284
return `"${ key } " DESC` ;
1287
- } ) . join ( ',' ) ;
1285
+ } ) . join ( ) ;
1288
1286
sortPattern = sort !== undefined && Object . keys ( sort ) . length > 0 ? `ORDER BY ${ sorting } ` : '' ;
1289
1287
}
1290
1288
if ( where . sorts && Object . keys ( ( where . sorts : any ) ) . length > 0 ) {
1291
- sortPattern = `ORDER BY ${ where . sorts . join ( ',' ) } ` ;
1289
+ sortPattern = `ORDER BY ${ where . sorts . join ( ) } ` ;
1292
1290
}
1293
1291
1294
1292
let columns = '*' ;
@@ -1302,7 +1300,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
1302
1300
return `ts_rank_cd(to_tsvector($${ 2 } , $${ 3 } :name), to_tsquery($${ 4 } , $${ 5 } ), 32) as score` ;
1303
1301
}
1304
1302
return `$${ index + values . length + 1 } :name` ;
1305
- } ) . join ( ',' ) ;
1303
+ } ) . join ( ) ;
1306
1304
values = values . concat ( keys ) ;
1307
1305
}
1308
1306
@@ -1405,7 +1403,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
1405
1403
// Will happily create the same index with multiple names.
1406
1404
const constraintName = `unique_${ fieldNames . sort ( ) . join ( '_' ) } ` ;
1407
1405
const constraintPatterns = fieldNames . map ( ( fieldName , index ) => `$${ index + 3 } :name` ) ;
1408
- const qs = `ALTER TABLE $1:name ADD CONSTRAINT $2:name UNIQUE (${ constraintPatterns . join ( ',' ) } )` ;
1406
+ const qs = `ALTER TABLE $1:name ADD CONSTRAINT $2:name UNIQUE (${ constraintPatterns . join ( ) } )` ;
1409
1407
return this . _client . none ( qs , [ className , constraintName , ...fieldNames ] )
1410
1408
. catch ( error => {
1411
1409
if ( error . code === PostgresDuplicateRelationError && error . message . includes ( constraintName ) ) {
@@ -1549,7 +1547,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
1549
1547
return `"${ key } " ASC` ;
1550
1548
}
1551
1549
return `"${ key } " DESC` ;
1552
- } ) . join ( ',' ) ;
1550
+ } ) . join ( ) ;
1553
1551
sortPattern = sort !== undefined && Object . keys ( sort ) . length > 0 ? `ORDER BY ${ sorting } ` : '' ;
1554
1552
}
1555
1553
}
0 commit comments