fix: Postgres query on non-existent column throws internal server error (#10308)

This commit is contained in:
Manuel
2026-03-25 00:07:06 +00:00
committed by GitHub
parent 3f888b1aac
commit c5c43259d1
2 changed files with 29 additions and 3 deletions
+21
View File
@@ -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;