Skip to content

Commit 5d4a318

Browse files
committed
test: Add rawValues coverage for $addFields stage
1 parent fcd49ae commit 5d4a318

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

spec/ParseQuery.Aggregate.spec.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,21 @@ describe('Parse.Query Aggregate testing', () => {
556556
expect(results[0]._created_at).toEqual(jasmine.objectContaining({ $date: jasmine.any(String) }));
557557
});
558558

559+
it_id('f01a0001-0006-0006-0006-000000000006')(it_exclude_dbs(['postgres']))('rawValues: true deserializes EJSON in `$addFields`', async () => {
560+
const obj = new TestObject();
561+
await obj.save();
562+
const iso = '2026-01-01T00:00:00.000Z';
563+
const pipeline = [
564+
{ $match: { objectId: obj.id } },
565+
{ $addFields: { pinned: { $date: iso } } },
566+
{ $project: { _id: 1, pinned: 1 } },
567+
];
568+
const query = new Parse.Query('TestObject');
569+
const results = await query.aggregate(pipeline, { rawValues: true, useMasterKey: true });
570+
expect(results.length).toBe(1);
571+
expect(results[0].pinned).toEqual(jasmine.objectContaining({ $date: jasmine.any(String) }));
572+
});
573+
559574
it_only_db('postgres')(
560575
'can group by any date field postgres (it does not work if you have dirty data)', // rows in your collection with non date data in the field that is supposed to be a date
561576
done => {

0 commit comments

Comments
 (0)