Skip to content

Commit 87aaf65

Browse files
committed
add a test
1 parent 097267a commit 87aaf65

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

test/specs/model.spec.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff 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', () => {

0 commit comments

Comments
 (0)