Skip to content

Commit 8d0f814

Browse files
committed
test(driver-sql,driver-memory): pin a one- and two-digit date year on every dialect — PostgreSQL read the unpadded 9-03-04 as 2004-09-03
Claude-Session: https://claude.ai/code/session_01Bvd69VPa6puiNzzPUroDBx Co-authored-by: Claude <noreply@anthropic.com>
1 parent 9f007c5 commit 8d0f814

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

‎packages/drivers/driver-memory/src/memory-20240-date-year-spelling.test.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ const ROWS = [
3939
];
4040

4141
const Y0999 = -30627504000000; // 0999-06-15T00:00:00.000Z
42+
const Y0099 = Date.parse('0099-03-04T00:00:00.000Z');
43+
const Y0009 = Date.parse('0009-03-04T00:00:00.000Z');
4244
const N = 1769940000000; // 2026-02-01T10:00:00.000Z — the control
4345

4446
const ALL = ['o1', 'o2', 'o3', 'o4', 'o5', 'o6', 'o7'];
@@ -50,6 +52,8 @@ const CELLS: ReadonlyArray<readonly [string, number, string, string[]]> = [
5052
['0999-06-15', Y0999, '$eq', ['o7']],
5153
['0999-06-15', Y0999, '$gte', ALL],
5254
['0999-06-15', Y0999, '$ne', ['o1', 'o2', 'o3', 'o4', 'o5', 'o6']],
55+
['0099-03-04', Y0099, '$lt', []],
56+
['0009-03-04', Y0009, '$gt', ALL],
5357
['2026-02-01 (control)', N, '$gt', ['o3']],
5458
['2026-02-01 (control)', N, '$lt', ['o1', 'o2', 'o5', 'o7']],
5559
['2026-02-01 (control)', N, '$eq', ['o4', 'o6']],

‎packages/drivers/driver-sql/src/sql-driver-20240-date-year-spelling.test.ts‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,13 @@
1717
* | PostgreSQL | 6 / 0 / 1 | 6 / 0 / 1 | the server's `DATE` parser reads `999-06-15` as year 999 |
1818
*
1919
* A direct `create` / `update` stored `999-06-15` on SQLite (PostgreSQL stored
20-
* the day). Each row below asserts one answer for the number, its `Date` and
21-
* its ISO string, plus a 2026 control. A year below 0 or above 9999 is refused
20+
* the day). A shorter year is worse on PostgreSQL: under its default
21+
* `DateStyle` (`ISO, MDY`) the server reads `9-03-04` as 2004-09-03 — a
22+
* different day, stored or compared silently — and refuses `99-03-04`
23+
* (`22008`). The unpadded spelling was restored by ablation to measure those
24+
* two, since this file's 0999 fixture reads right there. Each row below asserts
25+
* one answer for the number, its `Date` and its ISO string, plus a 2026
26+
* control. A year below 0 or above 9999 is refused
2227
* as a comparand one layer up, at the engine's temporal-comparand door
2328
* (`@objectstack/objectql`); this driver's `where` is not that door.
2429
*/
@@ -47,6 +52,8 @@ const ROWS = [
4752
];
4853

4954
const Y0999 = -30627504000000; // 0999-06-15T00:00:00.000Z
55+
const Y0099 = Date.parse('0099-03-04T00:00:00.000Z');
56+
const Y0009 = Date.parse('0009-03-04T00:00:00.000Z');
5057
const N = 1769940000000; // 2026-02-01T10:00:00.000Z — the control
5158

5259
const ALL = ['o1', 'o2', 'o3', 'o4', 'o5', 'o6', 'o7'];
@@ -58,6 +65,8 @@ const CELLS: ReadonlyArray<readonly [string, number, string, string[]]> = [
5865
['0999-06-15', Y0999, '$eq', ['o7']],
5966
['0999-06-15', Y0999, '$gte', ALL],
6067
['0999-06-15', Y0999, '$ne', ['o1', 'o2', 'o3', 'o4', 'o5', 'o6']],
68+
['0099-03-04', Y0099, '$lt', []],
69+
['0009-03-04', Y0009, '$gt', ALL],
6170
['2026-02-01 (control)', N, '$gt', ['o3']],
6271
['2026-02-01 (control)', N, '$lt', ['o1', 'o2', 'o5', 'o7']],
6372
['2026-02-01 (control)', N, '$eq', ['o4', 'o6']],

0 commit comments

Comments
 (0)