Skip to content
Open
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions spec/PostgresStorageAdapter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,35 @@ describe_only_db('postgres')('PostgresStorageAdapter', () => {
await adapter.deleteIdempotencyFunction();
await client.none(qs);
});

it('saves object with a pointer field set to undefined', async () => {
Copy link
Member

@mtrezza mtrezza Jun 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test should be moved to where the existing pointer tests are, as it's not a postgres specific test, even if the issue occurs only with postgres.

const pointerTestClassName = 'PointerTest';
const pointerTestSchema = new Parse.Schema(pointerTestClassName);
await pointerTestSchema.save();

// Make another class 'Test' with a pointer field to the first class
const testClassName = 'Test';
const testSchema = new Parse.Schema(testClassName);
const pointerToFieldName = 'pointerTo';
testSchema.addPointer(pointerToFieldName, pointerTestClassName); // Field points to Pointer Test
await testSchema.save();

// Create a 'Test' parse object with the 'pointerTo' field set to undefined
const obj = new Parse.Object(testClassName);
obj.set(pointerToFieldName, undefined);
expectAsync(obj.save()).toBeResolved();

// Create a 'Test parse object with the fields set to undefined directly in the constructor
const fields = {
[pointerToFieldName]: undefined,
};
const obj2 = new Parse.Object(testClassName, fields);
expectAsync(obj2.save()).toBeResolved();

// Create a 'Test' parse object with the fields set to undefined directly in the save method
const obj3 = new Parse.Object(testClassName);
expectAsync(obj3.save(fields)).toBeResolved();
});
});

describe_only_db('postgres')('PostgresStorageAdapter shutdown', () => {
Expand Down