File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -249,7 +249,7 @@ export function inferAlias(options: any, source: any): any {
249249 options . include = [ options . include ] ;
250250 } else if ( ! options . include . length ) {
251251 delete options . include ;
252- return ;
252+ return options ;
253253 }
254254
255255 // convert all included elements to { model: Model } form
Original file line number Diff line number Diff line change @@ -900,6 +900,36 @@ describe('model', () => {
900900 expect ( u . username ) . to . equal ( 'A fancy name' ) ;
901901 } ) ;
902902 } ) ;
903+
904+ it ( 'should filter based on the where clause even if IFindOptions.include is []' , ( ) => {
905+ @Table ( { paranoid : true , timestamps : true } )
906+ class User extends Model < User > {
907+
908+ @Column
909+ username : string ;
910+ }
911+ sequelize . addModels ( [ User ] ) ;
912+
913+ return User . sync ( { force : true } )
914+ . then ( ( ) => {
915+ return User . create ( { username : 'a1' } ) ;
916+ } )
917+ . then ( ( ) => {
918+ return User . create ( { username : 'a2' } ) ;
919+ } )
920+ . then ( ( ) => {
921+ return User . findOne < User > ( { where : { username : 'a2' } , include : [ ] } ) ;
922+ } )
923+ . then ( ( u ) => {
924+ expect ( u . username ) . to . equal ( 'a2' ) ;
925+ } )
926+ . then ( ( ) => {
927+ return User . findOne < User > ( { where : { username : 'a1' } , include : [ ] } ) ;
928+ } )
929+ . then ( ( u ) => {
930+ expect ( u . username ) . to . equal ( 'a1' ) ;
931+ } )
932+ } ) ;
903933 } ) ;
904934
905935 describe ( 'findOrInitialize' , ( ) => {
You can’t perform that action at this time.
0 commit comments