Skip to content

Commit a53d816

Browse files
committed
clean up debugger
1 parent 29f7cea commit a53d816

File tree

2 files changed

+18
-32
lines changed

2 files changed

+18
-32
lines changed

spec/Auth.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,10 @@ describe('Auth', () => {
230230
const role2 = new Parse.Role('role2loadtest' + i, acl2);
231231
role.getUsers().add([user]);
232232
role2.getUsers().add([user2]);
233-
roles.push(role.save());
234-
roles.push(role2.save());
233+
roles.push(role);
234+
roles.push(role2);
235235
}
236-
const savedRoles = await Promise.all(roles);
236+
const savedRoles = await Parse.Object.saveAll(roles);
237237
expect(savedRoles.length).toBe(rolesNumber * 2);
238238
const cloudRoles = await userAuth.getRolesForUser();
239239
const cloudRoles2 = await user2Auth.getRolesForUser();

src/Adapters/Storage/Postgres/PostgresStorageAdapter.js

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
945945
// Just create a table, do not insert in schema
946946
async createTable(className: string, schema: SchemaType, conn: any) {
947947
conn = conn || this._client;
948-
debug('createTable', className, schema);
948+
debug('createTable');
949949
const valuesArray = [];
950950
const patternsArray = [];
951951
const fields = Object.assign({}, schema.fields);
@@ -983,7 +983,6 @@ export class PostgresStorageAdapter implements StorageAdapter {
983983
const qs = `CREATE TABLE IF NOT EXISTS $1:name (${patternsArray.join()})`;
984984
const values = [className, ...valuesArray];
985985

986-
debug(qs, values);
987986
return conn.task('create-table', async t => {
988987
try {
989988
await t.none(qs, values);
@@ -1007,7 +1006,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
10071006
}
10081007

10091008
async schemaUpgrade(className: string, schema: SchemaType, conn: any) {
1010-
debug('schemaUpgrade', { className, schema });
1009+
debug('schemaUpgrade');
10111010
conn = conn || this._client;
10121011
const self = this;
10131012

@@ -1029,7 +1028,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
10291028

10301029
async addFieldIfNotExists(className: string, fieldName: string, type: any, conn: any) {
10311030
// TODO: Must be revised for invalid logic...
1032-
debug('addFieldIfNotExists', { className, fieldName, type });
1031+
debug('addFieldIfNotExists');
10331032
conn = conn || this._client;
10341033
const self = this;
10351034
await conn.tx('add-field-if-not-exists', async t => {
@@ -1148,7 +1147,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
11481147

11491148
// Returns a Promise.
11501149
async deleteFields(className: string, schema: SchemaType, fieldNames: string[]): Promise<void> {
1151-
debug('deleteFields', className, fieldNames);
1150+
debug('deleteFields');
11521151
fieldNames = fieldNames.reduce((list: Array<string>, fieldName: string) => {
11531152
const field = schema.fields[fieldName];
11541153
if (field.type !== 'Relation') {
@@ -1191,7 +1190,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
11911190
// this adapter doesn't know about the schema, return a promise that rejects with
11921191
// undefined as the reason.
11931192
async getClass(className: string) {
1194-
debug('getClass', className);
1193+
debug('getClass');
11951194
return this._client
11961195
.any('SELECT * FROM "_SCHEMA" WHERE "className" = $<className>', {
11971196
className,
@@ -1212,7 +1211,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
12121211
object: any,
12131212
transactionalSession: ?any
12141213
) {
1215-
debug('createObject', className, object);
1214+
debug('createObject');
12161215
let columnsArray = [];
12171216
const valuesArray = [];
12181217
schema = toPostgresSchema(schema);
@@ -1333,7 +1332,6 @@ export class PostgresStorageAdapter implements StorageAdapter {
13331332

13341333
const qs = `INSERT INTO $1:name (${columnsPattern}) VALUES (${valuesPattern})`;
13351334
const values = [className, ...columnsArray, ...valuesArray];
1336-
debug(qs, values);
13371335
const promise = (transactionalSession ? transactionalSession.t : this._client)
13381336
.none(qs, values)
13391337
.then(() => ({ ops: [object] }))
@@ -1369,7 +1367,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
13691367
query: QueryType,
13701368
transactionalSession: ?any
13711369
) {
1372-
debug('deleteObjectsByQuery', className, query);
1370+
debug('deleteObjectsByQuery');
13731371
const values = [className];
13741372
const index = 2;
13751373
const where = buildWhereClause({
@@ -1383,7 +1381,6 @@ export class PostgresStorageAdapter implements StorageAdapter {
13831381
where.pattern = 'TRUE';
13841382
}
13851383
const qs = `WITH deleted AS (DELETE FROM $1:name WHERE ${where.pattern} RETURNING *) SELECT count(*) FROM deleted`;
1386-
debug(qs, values);
13871384
const promise = (transactionalSession ? transactionalSession.t : this._client)
13881385
.one(qs, values, a => +a.count)
13891386
.then(count => {
@@ -1412,7 +1409,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
14121409
update: any,
14131410
transactionalSession: ?any
14141411
): Promise<any> {
1415-
debug('findOneAndUpdate', className, query, update);
1412+
debug('findOneAndUpdate');
14161413
return this.updateObjectsByQuery(className, schema, query, update, transactionalSession).then(
14171414
val => val[0]
14181415
);
@@ -1426,7 +1423,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
14261423
update: any,
14271424
transactionalSession: ?any
14281425
): Promise<[any]> {
1429-
debug('updateObjectsByQuery', className, query, update);
1426+
debug('updateObjectsByQuery');
14301427
const updatePatterns = [];
14311428
const values = [className];
14321429
let index = 2;
@@ -1651,7 +1648,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
16511648
index += 2;
16521649
}
16531650
} else {
1654-
debug('Not supported update', fieldName, fieldValue);
1651+
debug('Not supported update', { fieldName, fieldValue });
16551652
return Promise.reject(
16561653
new Parse.Error(
16571654
Parse.Error.OPERATION_FORBIDDEN,
@@ -1671,7 +1668,6 @@ export class PostgresStorageAdapter implements StorageAdapter {
16711668

16721669
const whereClause = where.pattern.length > 0 ? `WHERE ${where.pattern}` : '';
16731670
const qs = `UPDATE $1:name SET ${updatePatterns.join()} ${whereClause} RETURNING *`;
1674-
debug('update: ', qs, values);
16751671
const promise = (transactionalSession ? transactionalSession.t : this._client).any(qs, values);
16761672
if (transactionalSession) {
16771673
transactionalSession.batch.push(promise);
@@ -1687,7 +1683,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
16871683
update: any,
16881684
transactionalSession: ?any
16891685
) {
1690-
debug('upsertOneObject', { className, query, update });
1686+
debug('upsertOneObject');
16911687
const createValue = Object.assign({}, query, update);
16921688
return this.createObject(className, schema, createValue, transactionalSession).catch(error => {
16931689
// ignore duplicate value errors as it's upsert
@@ -1704,14 +1700,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
17041700
query: QueryType,
17051701
{ skip, limit, sort, keys, caseInsensitive, explain }: QueryOptions
17061702
) {
1707-
debug('find', className, query, {
1708-
skip,
1709-
limit,
1710-
sort,
1711-
keys,
1712-
caseInsensitive,
1713-
explain,
1714-
});
1703+
debug('find');
17151704
const hasLimit = limit !== undefined;
17161705
const hasSkip = skip !== undefined;
17171706
let values = [className];
@@ -1778,7 +1767,6 @@ export class PostgresStorageAdapter implements StorageAdapter {
17781767

17791768
const originalQuery = `SELECT ${columns} FROM $1:name ${wherePattern} ${sortPattern} ${limitPattern} ${skipPattern}`;
17801769
const qs = explain ? this.createExplainableQuery(originalQuery) : originalQuery;
1781-
debug(qs, values);
17821770
return this._client
17831771
.any(qs, values)
17841772
.catch(error => {
@@ -1926,7 +1914,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
19261914
readPreference?: string,
19271915
estimate?: boolean = true
19281916
) {
1929-
debug('count', className, query, readPreference, estimate);
1917+
debug('count');
19301918
const values = [className];
19311919
const where = buildWhereClause({
19321920
schema,
@@ -1962,7 +1950,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
19621950
}
19631951

19641952
async distinct(className: string, schema: SchemaType, query: QueryType, fieldName: string) {
1965-
debug('distinct', className, query);
1953+
debug('distinct');
19661954
let field = fieldName;
19671955
let column = fieldName;
19681956
const isNested = fieldName.indexOf('.') >= 0;
@@ -1989,7 +1977,6 @@ export class PostgresStorageAdapter implements StorageAdapter {
19891977
if (isNested) {
19901978
qs = `SELECT DISTINCT ${transformer}($1:raw) $2:raw FROM $3:name ${wherePattern}`;
19911979
}
1992-
debug(qs, values);
19931980
return this._client
19941981
.any(qs, values)
19951982
.catch(error => {
@@ -2028,7 +2015,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
20282015
hint: ?mixed,
20292016
explain?: boolean
20302017
) {
2031-
debug('aggregate', className, pipeline, readPreference, hint, explain);
2018+
debug('aggregate');
20322019
const values = [className];
20332020
let index: number = 2;
20342021
let columns: string[] = [];
@@ -2209,7 +2196,6 @@ export class PostgresStorageAdapter implements StorageAdapter {
22092196
.filter(Boolean)
22102197
.join()} FROM $1:name ${wherePattern} ${skipPattern} ${groupPattern} ${sortPattern} ${limitPattern}`;
22112198
const qs = explain ? this.createExplainableQuery(originalQuery) : originalQuery;
2212-
debug(qs, values);
22132199
return this._client.any(qs, values).then(a => {
22142200
if (explain) {
22152201
return a;

0 commit comments

Comments
 (0)