mirror of
https://github.com/parse-community/parse-server
synced 2026-08-09 13:03:18 +00:00
fix: Postgres query on non-existent column throws internal server error (#10308)
This commit is contained in:
@@ -217,6 +217,27 @@ describe('rest query', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('query internal field that has no database column', async () => {
|
||||
const user = new Parse.User();
|
||||
user.setUsername('user1');
|
||||
user.setPassword('password');
|
||||
await user.signUp();
|
||||
// _tombstone is registered as an internal field but has no column in the
|
||||
// Postgres _User table. Querying it with master key should return empty
|
||||
// results (consistent with MongoDB behavior), not throw an error.
|
||||
const results = await new Parse.Query(Parse.User).exists('_tombstone').find({ useMasterKey: true });
|
||||
expect(results.length).toBe(0);
|
||||
});
|
||||
|
||||
it('count internal field that has no database column', async () => {
|
||||
const user = new Parse.User();
|
||||
user.setUsername('user1');
|
||||
user.setPassword('password');
|
||||
await user.signUp();
|
||||
const count = await new Parse.Query(Parse.User).exists('_tombstone').count({ useMasterKey: true });
|
||||
expect(count).toBe(0);
|
||||
});
|
||||
|
||||
it('query protected field', async () => {
|
||||
const user = new Parse.User();
|
||||
user.setUsername('username1');
|
||||
|
||||
@@ -1992,8 +1992,10 @@ export class PostgresStorageAdapter implements StorageAdapter {
|
||||
return this._client
|
||||
.any(qs, values)
|
||||
.catch(error => {
|
||||
// Query on non existing table, don't crash
|
||||
if (error.code !== PostgresRelationDoesNotExistError) {
|
||||
if (
|
||||
error.code !== PostgresRelationDoesNotExistError &&
|
||||
error.code !== PostgresMissingColumnError
|
||||
) {
|
||||
throw error;
|
||||
}
|
||||
return [];
|
||||
@@ -2189,7 +2191,10 @@ export class PostgresStorageAdapter implements StorageAdapter {
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
if (error.code !== PostgresRelationDoesNotExistError) {
|
||||
if (
|
||||
error.code !== PostgresRelationDoesNotExistError &&
|
||||
error.code !== PostgresMissingColumnError
|
||||
) {
|
||||
throw error;
|
||||
}
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user