From 77c52dd191c9d5bbcc0e668ba3ea045344516a8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ad=C3=A1mek?= Date: Thu, 23 Apr 2020 22:24:45 +0200 Subject: [PATCH] fix(core): throw when trying to call `em.remove(..., null)` --- tests/EntityManager.mysql.test.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/EntityManager.mysql.test.ts b/tests/EntityManager.mysql.test.ts index d8baa304c06a..45c8e7d2829f 100644 --- a/tests/EntityManager.mysql.test.ts +++ b/tests/EntityManager.mysql.test.ts @@ -1903,6 +1903,11 @@ describe('EntityManagerMySql', () => { orm.em.clear(); }); + test('em.remove() with null or undefined in where parameter throws', async () => { + expect(() => orm.em.remove(Book2, undefined as any)).toThrowError(`You cannot call 'EntityManager.remove()' with empty 'where' parameter. If you want to remove all entities, use 'em.remove(Book2, {})'.`); + expect(() => orm.em.remove(Book2, null)).toThrowError(`You cannot call 'EntityManager.remove()' with empty 'where' parameter. If you want to remove all entities, use 'em.remove(Book2, {})'.`); + }); + afterAll(async () => orm.close(true)); });