From dee1620fb2906bdf7404b7811755a7dfa335ddab Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 6 Jan 2026 09:17:04 +0000 Subject: [PATCH 1/3] Initial plan From ac8ee00d8789f0f953490da45070656ba8d95325 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 6 Jan 2026 09:23:50 +0000 Subject: [PATCH 2/3] Replace hardcoded BigInt values with Number.MAX_SAFE_INTEGER + 1 Co-authored-by: kevin-dp <17384006+kevin-dp@users.noreply.github.com> --- packages/db/tests/query/group-by.test.ts | 34 ++++++++++++------------ 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/packages/db/tests/query/group-by.test.ts b/packages/db/tests/query/group-by.test.ts index 840ba0a6a..422036bdd 100644 --- a/packages/db/tests/query/group-by.test.ts +++ b/packages/db/tests/query/group-by.test.ts @@ -1121,25 +1121,25 @@ function createGroupByTests(autoIndex: `off` | `eager`): void { const sampleDistricts: Array = [ { id: 1, - district_id: BigInt('9007199254740991'), // Max safe integer + 1 + district_id: BigInt(Number.MAX_SAFE_INTEGER + 1), name: 'District A', status: 'active', }, { id: 2, - district_id: BigInt('9007199254740992'), + district_id: BigInt(Number.MAX_SAFE_INTEGER + 1) + 1n, name: 'District B', status: 'active', }, { id: 3, - district_id: BigInt('9007199254740991'), // Same as first + district_id: BigInt(Number.MAX_SAFE_INTEGER + 1), // Same as first name: 'District C', status: 'inactive', }, { id: 4, - district_id: BigInt('9007199254740993'), + district_id: BigInt(Number.MAX_SAFE_INTEGER + 1) + 2n, name: 'District D', status: 'active', }, @@ -1170,23 +1170,23 @@ function createGroupByTests(autoIndex: `off` | `eager`): void { // Should have 3 groups (two districts share the same district_id) expect(districtSummary.size).toBe(3) - // Check the group with BigInt('9007199254740991') + // Check the group with BigInt(Number.MAX_SAFE_INTEGER + 1) const group1 = Array.from(districtSummary.values()).find( - (d) => d.district_id === BigInt('9007199254740991'), + (d) => d.district_id === BigInt(Number.MAX_SAFE_INTEGER + 1), ) expect(group1).toBeDefined() expect(group1?.count).toBe(2) // Districts 1 and 3 - // Check the group with BigInt('9007199254740992') + // Check the group with BigInt(Number.MAX_SAFE_INTEGER + 1) + 1n const group2 = Array.from(districtSummary.values()).find( - (d) => d.district_id === BigInt('9007199254740992'), + (d) => d.district_id === BigInt(Number.MAX_SAFE_INTEGER + 1) + 1n, ) expect(group2).toBeDefined() expect(group2?.count).toBe(1) // District 2 - // Check the group with BigInt('9007199254740993') + // Check the group with BigInt(Number.MAX_SAFE_INTEGER + 1) + 2n const group3 = Array.from(districtSummary.values()).find( - (d) => d.district_id === BigInt('9007199254740993'), + (d) => d.district_id === BigInt(Number.MAX_SAFE_INTEGER + 1) + 2n, ) expect(group3).toBeDefined() expect(group3?.count).toBe(1) // District 4 @@ -1383,19 +1383,19 @@ function createGroupByTests(autoIndex: `off` | `eager`): void { const sampleSchools: Array = [ { id: 1, - district_id: BigInt('9007199254740991'), + district_id: BigInt(Number.MAX_SAFE_INTEGER + 1), name: 'School A', status: 'active', }, { id: 2, - district_id: BigInt('9007199254740991'), + district_id: BigInt(Number.MAX_SAFE_INTEGER + 1), name: 'School B', status: 'active', }, { id: 3, - district_id: BigInt('9007199254740992'), + district_id: BigInt(Number.MAX_SAFE_INTEGER + 1) + 1n, name: 'School C', status: 'inactive', }, @@ -1426,19 +1426,19 @@ function createGroupByTests(autoIndex: `off` | `eager`): void { expect(schoolSummary.size).toBe(2) // Two distinct combinations - // Find the group with BigInt('9007199254740991') and 'active' + // Find the group with BigInt(Number.MAX_SAFE_INTEGER + 1) and 'active' const group1 = Array.from(schoolSummary.values()).find( (s) => - s.district_id === BigInt('9007199254740991') && + s.district_id === BigInt(Number.MAX_SAFE_INTEGER + 1) && s.status === 'active', ) expect(group1).toBeDefined() expect(group1?.count).toBe(2) // Schools 1 and 2 - // Find the group with BigInt('9007199254740992') and 'inactive' + // Find the group with BigInt(Number.MAX_SAFE_INTEGER + 1) + 1n and 'inactive' const group2 = Array.from(schoolSummary.values()).find( (s) => - s.district_id === BigInt('9007199254740992') && + s.district_id === BigInt(Number.MAX_SAFE_INTEGER + 1) + 1n && s.status === 'inactive', ) expect(group2).toBeDefined() From 678f110dd938dec61ae2a2dcfe4ec69b2c251526 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 6 Jan 2026 09:25:36 +0000 Subject: [PATCH 3/3] Extract MAX_SAFE_BIGINT constant to improve readability Co-authored-by: kevin-dp <17384006+kevin-dp@users.noreply.github.com> --- packages/db/tests/query/group-by.test.ts | 40 ++++++++++++++---------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/packages/db/tests/query/group-by.test.ts b/packages/db/tests/query/group-by.test.ts index 422036bdd..89055585f 100644 --- a/packages/db/tests/query/group-by.test.ts +++ b/packages/db/tests/query/group-by.test.ts @@ -1118,28 +1118,31 @@ function createGroupByTests(autoIndex: `off` | `eager`): void { status: string } + // Use BigInt values beyond MAX_SAFE_INTEGER to test BigInt serialization + const MAX_SAFE_BIGINT = BigInt(Number.MAX_SAFE_INTEGER + 1) + const sampleDistricts: Array = [ { id: 1, - district_id: BigInt(Number.MAX_SAFE_INTEGER + 1), + district_id: MAX_SAFE_BIGINT, name: 'District A', status: 'active', }, { id: 2, - district_id: BigInt(Number.MAX_SAFE_INTEGER + 1) + 1n, + district_id: MAX_SAFE_BIGINT + 1n, name: 'District B', status: 'active', }, { id: 3, - district_id: BigInt(Number.MAX_SAFE_INTEGER + 1), // Same as first + district_id: MAX_SAFE_BIGINT, // Same as first name: 'District C', status: 'inactive', }, { id: 4, - district_id: BigInt(Number.MAX_SAFE_INTEGER + 1) + 2n, + district_id: MAX_SAFE_BIGINT + 2n, name: 'District D', status: 'active', }, @@ -1170,23 +1173,23 @@ function createGroupByTests(autoIndex: `off` | `eager`): void { // Should have 3 groups (two districts share the same district_id) expect(districtSummary.size).toBe(3) - // Check the group with BigInt(Number.MAX_SAFE_INTEGER + 1) + // Check the group with MAX_SAFE_BIGINT const group1 = Array.from(districtSummary.values()).find( - (d) => d.district_id === BigInt(Number.MAX_SAFE_INTEGER + 1), + (d) => d.district_id === MAX_SAFE_BIGINT, ) expect(group1).toBeDefined() expect(group1?.count).toBe(2) // Districts 1 and 3 - // Check the group with BigInt(Number.MAX_SAFE_INTEGER + 1) + 1n + // Check the group with MAX_SAFE_BIGINT + 1n const group2 = Array.from(districtSummary.values()).find( - (d) => d.district_id === BigInt(Number.MAX_SAFE_INTEGER + 1) + 1n, + (d) => d.district_id === MAX_SAFE_BIGINT + 1n, ) expect(group2).toBeDefined() expect(group2?.count).toBe(1) // District 2 - // Check the group with BigInt(Number.MAX_SAFE_INTEGER + 1) + 2n + // Check the group with MAX_SAFE_BIGINT + 2n const group3 = Array.from(districtSummary.values()).find( - (d) => d.district_id === BigInt(Number.MAX_SAFE_INTEGER + 1) + 2n, + (d) => d.district_id === MAX_SAFE_BIGINT + 2n, ) expect(group3).toBeDefined() expect(group3?.count).toBe(1) // District 4 @@ -1380,22 +1383,25 @@ function createGroupByTests(autoIndex: `off` | `eager`): void { status: string } + // Use BigInt values beyond MAX_SAFE_INTEGER to test BigInt serialization + const MAX_SAFE_BIGINT = BigInt(Number.MAX_SAFE_INTEGER + 1) + const sampleSchools: Array = [ { id: 1, - district_id: BigInt(Number.MAX_SAFE_INTEGER + 1), + district_id: MAX_SAFE_BIGINT, name: 'School A', status: 'active', }, { id: 2, - district_id: BigInt(Number.MAX_SAFE_INTEGER + 1), + district_id: MAX_SAFE_BIGINT, name: 'School B', status: 'active', }, { id: 3, - district_id: BigInt(Number.MAX_SAFE_INTEGER + 1) + 1n, + district_id: MAX_SAFE_BIGINT + 1n, name: 'School C', status: 'inactive', }, @@ -1426,19 +1432,19 @@ function createGroupByTests(autoIndex: `off` | `eager`): void { expect(schoolSummary.size).toBe(2) // Two distinct combinations - // Find the group with BigInt(Number.MAX_SAFE_INTEGER + 1) and 'active' + // Find the group with MAX_SAFE_BIGINT and 'active' const group1 = Array.from(schoolSummary.values()).find( (s) => - s.district_id === BigInt(Number.MAX_SAFE_INTEGER + 1) && + s.district_id === MAX_SAFE_BIGINT && s.status === 'active', ) expect(group1).toBeDefined() expect(group1?.count).toBe(2) // Schools 1 and 2 - // Find the group with BigInt(Number.MAX_SAFE_INTEGER + 1) + 1n and 'inactive' + // Find the group with MAX_SAFE_BIGINT + 1n and 'inactive' const group2 = Array.from(schoolSummary.values()).find( (s) => - s.district_id === BigInt(Number.MAX_SAFE_INTEGER + 1) + 1n && + s.district_id === MAX_SAFE_BIGINT + 1n && s.status === 'inactive', ) expect(group2).toBeDefined()