@@ -26,7 +26,8 @@ var Superhero,
26
26
Category ,
27
27
UserWithRenamedColumns ,
28
28
PostWithStringIdAndRenamedColumns ,
29
- Employee ;
29
+ Employee ,
30
+ PostWithDisableDefaultSort ;
30
31
31
32
describe ( 'lazyConnect' , function ( ) {
32
33
it ( 'should skip connect phase (lazyConnect = true)' , function ( done ) {
@@ -273,6 +274,18 @@ describe('mongodb connector', function() {
273
274
}
274
275
) ;
275
276
277
+ PostWithDisableDefaultSort = db . define (
278
+ 'PostWithDisableDefaultSort' ,
279
+ {
280
+ id : { type : String , id : true } ,
281
+ title : { type : String , length : 255 , index : true } ,
282
+ content : { type : String } ,
283
+ } ,
284
+ {
285
+ disableDefaultSort : true ,
286
+ }
287
+ ) ;
288
+
276
289
User . hasMany ( Post ) ;
277
290
Post . belongsTo ( User ) ;
278
291
} ) ;
@@ -285,7 +298,9 @@ describe('mongodb connector', function() {
285
298
PostWithNumberId . destroyAll ( function ( ) {
286
299
PostWithNumberUnderscoreId . destroyAll ( function ( ) {
287
300
PostWithStringId . destroyAll ( function ( ) {
288
- done ( ) ;
301
+ PostWithDisableDefaultSort . destroyAll ( function ( ) {
302
+ done ( ) ;
303
+ } ) ;
289
304
} ) ;
290
305
} ) ;
291
306
} ) ;
@@ -2492,21 +2507,19 @@ describe('mongodb connector', function() {
2492
2507
2493
2508
it ( 'find should not order by id if the order is not set for the query filter and settings.disableDefaultSort is true' ,
2494
2509
function ( done ) {
2495
- PostWithStringId . settings . disableDefaultSort = true ;
2496
-
2497
- PostWithStringId . create ( { id : '2' , title : 'c' , content : 'CCC' } , function ( err , post ) {
2498
- PostWithStringId . create ( { id : '1' , title : 'd' , content : 'DDD' } , function ( err , post ) {
2499
- PostWithStringId . find ( { } , function ( err , posts ) {
2510
+ PostWithDisableDefaultSort . create ( { id : '2' , title : 'c' , content : 'CCC' } , function ( err , post ) {
2511
+ PostWithDisableDefaultSort . create ( { id : '1' , title : 'd' , content : 'DDD' } , function ( err , post ) {
2512
+ PostWithDisableDefaultSort . find ( { } , function ( err , posts ) {
2500
2513
should . not . exist ( err ) ;
2501
2514
posts . length . should . be . equal ( 2 ) ;
2502
2515
posts [ 0 ] . id . should . be . equal ( '2' ) ;
2503
2516
2504
- PostWithStringId . find ( { limit : 1 , offset : 0 } , function ( err , posts ) {
2517
+ PostWithDisableDefaultSort . find ( { limit : 1 , offset : 0 } , function ( err , posts ) {
2505
2518
should . not . exist ( err ) ;
2506
2519
posts . length . should . be . equal ( 1 ) ;
2507
2520
posts [ 0 ] . id . should . be . equal ( '2' ) ;
2508
2521
2509
- PostWithStringId . find ( { limit : 1 , offset : 1 } , function ( err , posts ) {
2522
+ PostWithDisableDefaultSort . find ( { limit : 1 , offset : 1 } , function ( err , posts ) {
2510
2523
should . not . exist ( err ) ;
2511
2524
posts . length . should . be . equal ( 1 ) ;
2512
2525
posts [ 0 ] . id . should . be . equal ( '1' ) ;
0 commit comments