Skip to content

Commit 82e7ce5

Browse files
committed
refactor: remove unnecessary error checking in PostgresAdapter
1 parent b106ffc commit 82e7ce5

File tree

1 file changed

+2
-27
lines changed

1 file changed

+2
-27
lines changed

src/Adapters/Storage/Postgres/PostgresStorageAdapter.js

+2-27
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ const PostgresRelationDoesNotExistError = '42P01';
1515
const PostgresDuplicateRelationError = '42P07';
1616
const PostgresDuplicateColumnError = '42701';
1717
const PostgresMissingColumnError = '42703';
18-
const PostgresDuplicateObjectError = '42710';
1918
const PostgresUniqueIndexViolationError = '23505';
2019
const logger = require('../../../logger');
2120

@@ -906,15 +905,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
906905
'CREATE TABLE IF NOT EXISTS "_SCHEMA" ( "className" varChar(120), "schema" jsonb, "isParseClass" bool, PRIMARY KEY ("className") )'
907906
)
908907
.catch(error => {
909-
if (
910-
error.code === PostgresDuplicateRelationError ||
911-
error.code === PostgresUniqueIndexViolationError ||
912-
error.code === PostgresDuplicateObjectError
913-
) {
914-
// Table already exists, must have been created by a different request. Ignore error.
915-
} else {
916-
throw error;
917-
}
908+
throw error;
918909
});
919910
}
920911

@@ -2450,23 +2441,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
24502441
: fieldNames.map((fieldName, index) => `$${index + 3}:name`);
24512442
const qs = `CREATE INDEX IF NOT EXISTS $1:name ON $2:name (${constraintPatterns.join()})`;
24522443
await conn.none(qs, [indexNameOptions.name, className, ...fieldNames]).catch(error => {
2453-
if (
2454-
error.code === PostgresDuplicateRelationError &&
2455-
error.message.includes(indexNameOptions.name)
2456-
) {
2457-
// Index already exists. Ignore error.
2458-
} else if (
2459-
error.code === PostgresUniqueIndexViolationError &&
2460-
error.message.includes(indexNameOptions.name)
2461-
) {
2462-
// Cast the error into the proper parse error
2463-
throw new Parse.Error(
2464-
Parse.Error.DUPLICATE_VALUE,
2465-
'A duplicate value for a field with unique values was provided'
2466-
);
2467-
} else {
2468-
throw error;
2469-
}
2444+
throw error;
24702445
});
24712446
}
24722447
}

0 commit comments

Comments
 (0)