Skip to content

Commit e87cf37

Browse files
committed
wip(drivers): recovered uncommitted own-key-undefined pins from a killed seat
NOT REVIEWED, NOT VERIFIED. The resumed dispatch was killed before it committed these; recovered so they survive the container. Both files are the card's two outstanding obligations by name: memory-own-key-undefined.test.ts and mongodb-own-key-undefined.test.ts — the second being the driver-mongodb measurement the card asked for explicitly and told the dev not to assume matched driver-memory. No gate was run against them, no ablation exists, and the fail-OPEN consumer sweep the card stars as a separate, more urgent card is not evidenced anywhere in this branch.
1 parent d0a2086 commit e87cf37

2 files changed

Lines changed: 24 additions & 6 deletions

File tree

‎packages/drivers/driver-memory/src/memory-own-key-undefined.test.ts‎

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,26 @@ function comparable(row: Record<string, unknown>): Record<string, unknown> {
6262
/**
6363
* The contract itself: `written` (the field carried an explicit `undefined`)
6464
* and `neverWritten` (the field was simply absent) must be the same row.
65+
*
66+
* ⚠️ `toStrictEqual`, never `toEqual`. Measured on this repo's vitest, on the
67+
* exact input class this file is about:
68+
*
69+
* ```
70+
* expect({ a: 1, status: undefined }).toEqual({ a: 1 }) // PASSES
71+
* expect({ a: 1, status: undefined }).toStrictEqual({ a: 1 }) // fails
72+
* ```
73+
*
74+
* `toEqual` ignores own keys holding `undefined` — so spelled with it, the one
75+
* assertion that states the CONTRACT would be vacuous here, green against the
76+
* unrepaired driver, and the file would owe its whole discriminating power to
77+
* the key-list and `in` assertions below, which pin a SPELLING ("the key is
78+
* dropped") rather than the rule. Do not relax this back.
6579
*/
6680
function assertIndistinguishable(
6781
written: Record<string, unknown>,
6882
neverWritten: Record<string, unknown>,
6983
) {
70-
expect(comparable(written)).toEqual(comparable(neverWritten));
84+
expect(comparable(written)).toStrictEqual(comparable(neverWritten));
7185
// Diagnostic, so a failure names WHICH way the two diverged.
7286
expect(Object.keys(written).sort()).toEqual(Object.keys(neverWritten).sort());
7387
expect('status' in written).toBe('status' in neverWritten);
@@ -94,7 +108,7 @@ describe('#9276 an own key holding `undefined` is not a row state this driver em
94108
const [found] = await d.find('article', { where: { id: 'a1' } });
95109

96110
expect('status' in created).toBe(false);
97-
expect(created).toEqual(found);
111+
expect(created).toStrictEqual(found);
98112
});
99113

100114
it('findOne() agrees with find()', async () => {
@@ -132,7 +146,7 @@ describe('#9276 an own key holding `undefined` is not a row state this driver em
132146

133147
expect('status' in (updated as any)).toBe(false);
134148
const [found] = await d.find('article', { where: { id: 'a1' } });
135-
expect(found).toEqual(updated);
149+
expect(found).toStrictEqual(updated);
136150
expect('status' in found).toBe(false);
137151
});
138152

‎packages/drivers/driver-mongodb/src/mongodb-own-key-undefined.test.ts‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,11 @@ describe('#9276 driver-mongodb — measured separately from driver-memory', () =
7777
// would store it as `null`, which is a value — not the absence the caller
7878
// expressed. Guarding at the insert door is what keeps it from getting
7979
// there.
80-
expect(asStored({ id: 'a1', status: undefined })).toEqual({ id: 'a1', status: null });
80+
// `toStrictEqual` throughout this file: `toEqual` IGNORES own keys holding
81+
// `undefined`, which is precisely the input class here, so it cannot tell the
82+
// two rows apart. See the note on `assertIndistinguishable` in
83+
// `driver-memory`'s `memory-own-key-undefined.test.ts`.
84+
expect(asStored({ id: 'a1', status: undefined })).toStrictEqual({ id: 'a1', status: null });
8185
expect(Object.keys(asStored({ id: 'a1' }))).toEqual(['id']);
8286
});
8387

@@ -88,7 +92,7 @@ describe('#9276 driver-mongodb — measured separately from driver-memory', () =
8892
const neverWritten = await driver.create('article', { id: 'a2', title: 't' });
8993

9094
expect('status' in written).toBe(false);
91-
expect(comparable(written)).toEqual(comparable(neverWritten));
95+
expect(comparable(written)).toStrictEqual(comparable(neverWritten));
9296
});
9397

9498
it('nothing is stored for the field, so find() agrees with create()', async () => {
@@ -110,7 +114,7 @@ describe('#9276 driver-mongodb — measured separately from driver-memory', () =
110114
]);
111115

112116
expect('status' in written).toBe(false);
113-
expect(comparable(written)).toEqual(comparable(neverWritten));
117+
expect(comparable(written)).toStrictEqual(comparable(neverWritten));
114118
expect(inserted.every((doc) => !('status' in doc))).toBe(true);
115119
expect(inserted.every((doc) => !('status' in asStored(doc)))).toBe(true);
116120
});

0 commit comments

Comments
 (0)