@@ -124,6 +124,10 @@ const HasManyDissociator = require('../src/services/has-many-dissociator');
124
124
ownerId : { type : Sequelize . INTEGER } ,
125
125
} ) ;
126
126
127
+ models . counter = sequelize . define ( 'counter' , {
128
+ clicks : { type : Sequelize . BIGINT } ,
129
+ } ) ;
130
+
127
131
models . address . belongsTo ( models . user ) ;
128
132
models . addressWithUserAlias . belongsTo ( models . user , { as : 'userAlias' } ) ;
129
133
models . user . hasMany ( models . address ) ;
@@ -316,6 +320,16 @@ const HasManyDissociator = require('../src/services/has-many-dissociator');
316
320
{ field : 'ownerId' , type : 'Number' , reference : 'owner.ownerId' } ,
317
321
] ,
318
322
} ,
323
+ counter : {
324
+ name : 'counter' ,
325
+ idField : 'id' ,
326
+ primaryKeys : [ 'id' ] ,
327
+ isCompositePrimary : false ,
328
+ fields : [
329
+ { field : 'id' , type : 'Number' } ,
330
+ { field : 'clicks' , type : 'Number' } ,
331
+ ] ,
332
+ } ,
319
333
} ,
320
334
} ;
321
335
@@ -1010,6 +1024,34 @@ const HasManyDissociator = require('../src/services/has-many-dissociator');
1010
1024
connectionManager . closeConnection ( ) ;
1011
1025
}
1012
1026
} ) ;
1027
+
1028
+ it ( 'should handle numbers over MAX_SAFE_INTEGER' , async ( ) => {
1029
+ expect . assertions ( 2 ) ;
1030
+ const { models, sequelizeOptions } = initializeSequelize ( ) ;
1031
+
1032
+ // HACK: sequelize-fixtures does not support BigInt in json files,
1033
+ // so we need to update the clicks value manually
1034
+ const counter = await models . counter . findByPk ( 10 ) ;
1035
+ counter . clicks = BigInt ( '9013084467599484828' ) ; // eslint-disable-line no-undef
1036
+ await counter . save ( ) ;
1037
+
1038
+ const params = {
1039
+ fields : {
1040
+ counter : 'id,clicks' ,
1041
+ } ,
1042
+ page : { number : '1' , size : '30' } ,
1043
+ search : '9013084467599484828' ,
1044
+ timezone : 'Europe/Paris' ,
1045
+ } ;
1046
+ try {
1047
+ const result = await new ResourcesGetter ( models . counter , sequelizeOptions , params )
1048
+ . perform ( ) ;
1049
+ expect ( result [ 0 ] ) . toHaveLength ( 1 ) ;
1050
+ expect ( result [ 0 ] [ 0 ] . id ) . toBe ( 10 ) ;
1051
+ } finally {
1052
+ connectionManager . closeConnection ( ) ;
1053
+ }
1054
+ } ) ;
1013
1055
} ) ;
1014
1056
} ) ;
1015
1057
0 commit comments