Skip to content

Commit b353777

Browse files
committed
test(rest): the #20240 datetime control now reads a 2026 instant; the out-of-range number is refused on datetime too (#20264)
Claude-Session: https://claude.ai/code/session_01N8TPEsoJxPsdSdNKGnNGEN Co-authored-by: Claude <noreply@anthropic.com>
1 parent fb6eaa6 commit b353777

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

‎packages/rest/src/data-query-date-year-range.test.ts‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,9 @@ describe('[#20240] a four-digit year — the number, the Date and the ISO string
171171
}
172172
});
173173

174-
describe('[#20240] a year outside 0..9999 — the number and the Date are refused as their ISO string is, before any read', () => {
174+
describe('[#20240] a year outside the four-digit years — the number and the Date are refused as their ISO string is, before any read', () => {
175175
for (const [day, ms] of [['10000-01-01', Y10000], ['-1-01-01', YNEG1]] as const) {
176-
it(`${day}: INVALID_FILTER / 400 at where and at the per-aggregation filter, on both doors; the datetime control is read`, async () => {
176+
it(`${day}: INVALID_FILTER / 400 at where and at the per-aggregation filter, on both doors — on a datetime too [#20264]; a 2026 instant is read`, async () => {
177177
const { engine, post, reads } = await boot();
178178
for (const op of ['$gt', '$lt', '$eq'] as const) {
179179
for (const [form, comparand] of [['number', ms], ['Date', new Date(ms)], ['ISO string', new Date(ms).toISOString()]] as const) {
@@ -200,11 +200,17 @@ describe('[#20240] a year outside 0..9999 — the number and the Date are refuse
200200
}
201201
expect(reads.n, 'no read of the object — the refusal precedes the driver').toBe(0);
202202

203-
// Control: the same numbers on a `datetime` field are instants its rule reads.
203+
// [#20264] The same numbers on a `datetime` field are refused too — the
204+
// supported years 0001..9999 hold for both kinds.
204205
for (const comparand of [ms, new Date(ms)]) {
205-
await expect(engine.find(OBJECT, { where: { opened_at: { $gt: comparand } } })).resolves.toBeDefined();
206+
const err = await refusalOf(engine.find(OBJECT, { where: { opened_at: { $gt: comparand } } }));
207+
expect(err).toMatchObject({ code: 'INVALID_FILTER', status: 400 });
206208
}
207-
const control = await post({ where: { opened_at: { $gt: ms } } });
209+
const refused = await post({ where: { opened_at: { $gt: ms } } });
210+
expect(refused._status).toBe(400);
211+
expect(reads.n).toBe(0);
212+
// Control: a 2026 instant on the same field is read.
213+
const control = await post({ where: { opened_at: { $gt: N } } });
208214
expect(control._status ?? 200, JSON.stringify(control._json)).toBe(200);
209215
expect(reads.n).toBeGreaterThan(0);
210216
});

0 commit comments

Comments
 (0)