@@ -1118,28 +1118,31 @@ function createGroupByTests(autoIndex: `off` | `eager`): void {
11181118 status : string
11191119 }
11201120
1121+ // Use BigInt values beyond MAX_SAFE_INTEGER to test BigInt serialization
1122+ const MAX_SAFE_BIGINT = BigInt ( Number . MAX_SAFE_INTEGER + 1 )
1123+
11211124 const sampleDistricts : Array < District > = [
11221125 {
11231126 id : 1 ,
1124- district_id : BigInt ( '9007199254740991' ) , // Max safe integer + 1
1127+ district_id : MAX_SAFE_BIGINT ,
11251128 name : 'District A' ,
11261129 status : 'active' ,
11271130 } ,
11281131 {
11291132 id : 2 ,
1130- district_id : BigInt ( '9007199254740992' ) ,
1133+ district_id : MAX_SAFE_BIGINT + 1n ,
11311134 name : 'District B' ,
11321135 status : 'active' ,
11331136 } ,
11341137 {
11351138 id : 3 ,
1136- district_id : BigInt ( '9007199254740991' ) , // Same as first
1139+ district_id : MAX_SAFE_BIGINT , // Same as first
11371140 name : 'District C' ,
11381141 status : 'inactive' ,
11391142 } ,
11401143 {
11411144 id : 4 ,
1142- district_id : BigInt ( '9007199254740993' ) ,
1145+ district_id : MAX_SAFE_BIGINT + 2n ,
11431146 name : 'District D' ,
11441147 status : 'active' ,
11451148 } ,
@@ -1170,23 +1173,23 @@ function createGroupByTests(autoIndex: `off` | `eager`): void {
11701173 // Should have 3 groups (two districts share the same district_id)
11711174 expect ( districtSummary . size ) . toBe ( 3 )
11721175
1173- // Check the group with BigInt('9007199254740991')
1176+ // Check the group with MAX_SAFE_BIGINT
11741177 const group1 = Array . from ( districtSummary . values ( ) ) . find (
1175- ( d ) => d . district_id === BigInt ( '9007199254740991' ) ,
1178+ ( d ) => d . district_id === MAX_SAFE_BIGINT ,
11761179 )
11771180 expect ( group1 ) . toBeDefined ( )
11781181 expect ( group1 ?. count ) . toBe ( 2 ) // Districts 1 and 3
11791182
1180- // Check the group with BigInt('9007199254740992')
1183+ // Check the group with MAX_SAFE_BIGINT + 1n
11811184 const group2 = Array . from ( districtSummary . values ( ) ) . find (
1182- ( d ) => d . district_id === BigInt ( '9007199254740992' ) ,
1185+ ( d ) => d . district_id === MAX_SAFE_BIGINT + 1n ,
11831186 )
11841187 expect ( group2 ) . toBeDefined ( )
11851188 expect ( group2 ?. count ) . toBe ( 1 ) // District 2
11861189
1187- // Check the group with BigInt('9007199254740993')
1190+ // Check the group with MAX_SAFE_BIGINT + 2n
11881191 const group3 = Array . from ( districtSummary . values ( ) ) . find (
1189- ( d ) => d . district_id === BigInt ( '9007199254740993' ) ,
1192+ ( d ) => d . district_id === MAX_SAFE_BIGINT + 2n ,
11901193 )
11911194 expect ( group3 ) . toBeDefined ( )
11921195 expect ( group3 ?. count ) . toBe ( 1 ) // District 4
@@ -1380,22 +1383,25 @@ function createGroupByTests(autoIndex: `off` | `eager`): void {
13801383 status : string
13811384 }
13821385
1386+ // Use BigInt values beyond MAX_SAFE_INTEGER to test BigInt serialization
1387+ const MAX_SAFE_BIGINT = BigInt ( Number . MAX_SAFE_INTEGER + 1 )
1388+
13831389 const sampleSchools : Array < School > = [
13841390 {
13851391 id : 1 ,
1386- district_id : BigInt ( '9007199254740991' ) ,
1392+ district_id : MAX_SAFE_BIGINT ,
13871393 name : 'School A' ,
13881394 status : 'active' ,
13891395 } ,
13901396 {
13911397 id : 2 ,
1392- district_id : BigInt ( '9007199254740991' ) ,
1398+ district_id : MAX_SAFE_BIGINT ,
13931399 name : 'School B' ,
13941400 status : 'active' ,
13951401 } ,
13961402 {
13971403 id : 3 ,
1398- district_id : BigInt ( '9007199254740992' ) ,
1404+ district_id : MAX_SAFE_BIGINT + 1n ,
13991405 name : 'School C' ,
14001406 status : 'inactive' ,
14011407 } ,
@@ -1426,19 +1432,19 @@ function createGroupByTests(autoIndex: `off` | `eager`): void {
14261432
14271433 expect ( schoolSummary . size ) . toBe ( 2 ) // Two distinct combinations
14281434
1429- // Find the group with BigInt('9007199254740991') and 'active'
1435+ // Find the group with MAX_SAFE_BIGINT and 'active'
14301436 const group1 = Array . from ( schoolSummary . values ( ) ) . find (
14311437 ( s ) =>
1432- s . district_id === BigInt ( '9007199254740991' ) &&
1438+ s . district_id === MAX_SAFE_BIGINT &&
14331439 s . status === 'active' ,
14341440 )
14351441 expect ( group1 ) . toBeDefined ( )
14361442 expect ( group1 ?. count ) . toBe ( 2 ) // Schools 1 and 2
14371443
1438- // Find the group with BigInt('9007199254740992') and 'inactive'
1444+ // Find the group with MAX_SAFE_BIGINT + 1n and 'inactive'
14391445 const group2 = Array . from ( schoolSummary . values ( ) ) . find (
14401446 ( s ) =>
1441- s . district_id === BigInt ( '9007199254740992' ) &&
1447+ s . district_id === MAX_SAFE_BIGINT + 1n &&
14421448 s . status === 'inactive' ,
14431449 )
14441450 expect ( group2 ) . toBeDefined ( )
0 commit comments